diff options
568 files changed, 10625 insertions, 10989 deletions
diff --git a/data/sql/updates/pending_db_characters/rev_1617907126348389400.sql b/data/sql/updates/pending_db_characters/rev_1617907126348389400.sql new file mode 100644 index 0000000000..f6a6e040d3 --- /dev/null +++ b/data/sql/updates/pending_db_characters/rev_1617907126348389400.sql @@ -0,0 +1,29 @@ +INSERT INTO `version_db_characters` (`sql_rev`) VALUES ('1617907126348389400'); + +-- Keep only the highest guid PvE or PvP (not bones) corpse per player guid +DELETE c FROM `corpse` c LEFT JOIN +( + SELECT MAX(`corpseGuid`) AS id + FROM `corpse` + WHERE `corpseType` IN (1,2) + GROUP BY `guid` +) corpsetemp +ON c.`corpseGuid` = corpsetemp.`id` +WHERE corpsetemp.`id` IS NULL; + +-- Remove corpseGUID and set key to player guid +ALTER TABLE `corpse` DROP `corpseGuid`, DROP INDEX `idx_player`, ADD PRIMARY KEY (`guid`); + +UPDATE `auctionhouse` SET `time` = 0, `auctioneerguid` = 7; +ALTER TABLE `auctionhouse` CHANGE `auctioneerguid` `houseid` TINYINT(3) UNSIGNED NOT NULL DEFAULT '7' AFTER `id`; + +ALTER TABLE `characters` CHANGE `transguid` `transguid` MEDIUMINT DEFAULT 0 NOT NULL; + +ALTER TABLE `groups` CHANGE `icon1` `icon1` BIGINT UNSIGNED NOT NULL; +ALTER TABLE `groups` CHANGE `icon2` `icon2` BIGINT UNSIGNED NOT NULL; +ALTER TABLE `groups` CHANGE `icon3` `icon3` BIGINT UNSIGNED NOT NULL; +ALTER TABLE `groups` CHANGE `icon4` `icon4` BIGINT UNSIGNED NOT NULL; +ALTER TABLE `groups` CHANGE `icon5` `icon5` BIGINT UNSIGNED NOT NULL; +ALTER TABLE `groups` CHANGE `icon6` `icon6` BIGINT UNSIGNED NOT NULL; +ALTER TABLE `groups` CHANGE `icon7` `icon7` BIGINT UNSIGNED NOT NULL; +ALTER TABLE `groups` CHANGE `icon8` `icon8` BIGINT UNSIGNED NOT NULL; diff --git a/data/sql/updates/pending_db_world/rev_1618042584624619500.sql b/data/sql/updates/pending_db_world/rev_1618042584624619500.sql new file mode 100644 index 0000000000..d78b082b55 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1618042584624619500.sql @@ -0,0 +1,3 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1618042584624619500'); + +UPDATE `acore_string` SET `content_default` = 'Object GUID is: %s' WHERE `entry`=201; diff --git a/src/common/Containers.h b/src/common/Containers.h index ba47fb1a57..5eaa4d1be3 100644 --- a/src/common/Containers.h +++ b/src/common/Containers.h @@ -142,6 +142,19 @@ namespace acore } } } + + template<class K, class V, template<class, class, class...> class M, class... Rest> + void MultimapErasePair(M<K, V, Rest...>& multimap, K const& key, V const& value) + { + auto range = multimap.equal_range(key); + for (auto itr = range.first; itr != range.second;) + { + if (itr->second == value) + itr = multimap.erase(itr); + else + ++itr; + } + } } //! namespace Containers } diff --git a/src/common/Dynamic/TypeContainer.h b/src/common/Dynamic/TypeContainer.h index ec97269cbd..581076a7c1 100644 --- a/src/common/Dynamic/TypeContainer.h +++ b/src/common/Dynamic/TypeContainer.h @@ -13,6 +13,7 @@ */ #include <map> +#include <unordered_map> #include <vector> #include "Define.h" #include "Dynamic/TypeList.h" @@ -23,37 +24,41 @@ * By itself its meaningless but collaborate along with TypeContainers, * it become the most powerfully container in the whole system. */ -template<class OBJECT> struct ContainerMapList +template<class OBJECT> +struct ContainerMapList { //std::map<OBJECT_HANDLE, OBJECT *> _element; GridRefManager<OBJECT> _element; }; -template<> struct ContainerMapList<TypeNull> /* nothing is in type null */ +template<> +struct ContainerMapList<TypeNull> /* nothing is in type null */ { }; -template<class H, class T> struct ContainerMapList<TypeList<H, T>> + +template<class H, class T> +struct ContainerMapList<TypeList<H, T>> { ContainerMapList<H> _elements; ContainerMapList<T> _TailElements; }; -/* - * @class ContaierArrayList is a multi-type container for - * array of elements. - */ -template<class OBJECT> struct ContainerArrayList +template<class OBJECT, class KEY_TYPE> +struct ContainerUnorderedMap +{ + std::unordered_map<KEY_TYPE, OBJECT*> _element; +}; + +template<class KEY_TYPE> +struct ContainerUnorderedMap<TypeNull, KEY_TYPE> { - std::vector<OBJECT> _element; }; -// termination condition -template<> struct ContainerArrayList<TypeNull> { }; -// recursion -template<class H, class T> struct ContainerArrayList<TypeList<H, T>> +template<class H, class T, class KEY_TYPE> +struct ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE> { - ContainerArrayList<H> _elements; - ContainerArrayList<T> _TailElements; + ContainerUnorderedMap<H, KEY_TYPE> _elements; + ContainerUnorderedMap<T, KEY_TYPE> _TailElements; }; /* @@ -89,14 +94,16 @@ public: template<class SPECIFIC_TYPE> [[nodiscard]] size_t Count() const { return acore::Count(i_elements, (SPECIFIC_TYPE*)nullptr); } /// inserts a specific object into the container - template<class SPECIFIC_TYPE> bool insert(SPECIFIC_TYPE* obj) + template<class SPECIFIC_TYPE> + bool insert(SPECIFIC_TYPE* obj) { SPECIFIC_TYPE* t = acore::Insert(i_elements, obj); return (t != nullptr); } /// Removes the object from the container, and returns the removed object - //template<class SPECIFIC_TYPE> bool remove(SPECIFIC_TYPE* obj) + //template<class SPECIFIC_TYPE> + // bool remove(SPECIFIC_TYPE* obj) //{ // SPECIFIC_TYPE* t = acore::Remove(i_elements, obj); // return (t != nullptr); @@ -108,4 +115,34 @@ public: private: ContainerMapList<OBJECT_TYPES> i_elements; }; + +template<class OBJECT_TYPES, class KEY_TYPE> +class TypeUnorderedMapContainer +{ +public: + template<class SPECIFIC_TYPE> + bool Insert(KEY_TYPE const& handle, SPECIFIC_TYPE* obj) + { + return acore::Insert(_elements, handle, obj); + } + + template<class SPECIFIC_TYPE> + bool Remove(KEY_TYPE const& handle) + { + return acore::Remove(_elements, handle, (SPECIFIC_TYPE*)nullptr); + } + + template<class SPECIFIC_TYPE> + SPECIFIC_TYPE* Find(KEY_TYPE const& handle) + { + return acore::Find(_elements, handle, (SPECIFIC_TYPE*)nullptr); + } + + ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE>& GetElements() { return _elements; } + ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> const& GetElements() const { return _elements; } + +private: + ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> _elements; +}; + #endif diff --git a/src/common/Dynamic/TypeContainerFunctions.h b/src/common/Dynamic/TypeContainerFunctions.h index 687cf7fa65..cb5b18da92 100644 --- a/src/common/Dynamic/TypeContainerFunctions.h +++ b/src/common/Dynamic/TypeContainerFunctions.h @@ -16,57 +16,161 @@ #include "Define.h" #include "Dynamic/TypeList.h" #include <map> +#include <unordered_map> namespace acore { + // Helpers + // Insert helpers + template<class SPECIFIC_TYPE, class KEY_TYPE> + bool Insert(ContainerUnorderedMap<SPECIFIC_TYPE, KEY_TYPE>& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* obj) + { + auto i = elements._element.find(handle); + if (i == elements._element.end()) + { + elements._element[handle] = obj; + return true; + } + else + { + ASSERT(i->second == obj, "Object with certain key already in but objects are different!"); + return false; + } + } + + template<class SPECIFIC_TYPE, class KEY_TYPE> + bool Insert(ContainerUnorderedMap<TypeNull, KEY_TYPE>& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/) + { + return false; + } + + template<class SPECIFIC_TYPE, class KEY_TYPE, class T> + bool Insert(ContainerUnorderedMap<T, KEY_TYPE>& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/) + { + return false; + } + + template<class SPECIFIC_TYPE, class KEY_TYPE, class H, class T> + bool Insert(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE>& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* obj) + { + bool ret = Insert(elements._elements, handle, obj); + return ret ? ret : Insert(elements._TailElements, handle, obj); + } + + // Find helpers + template<class SPECIFIC_TYPE, class KEY_TYPE> + SPECIFIC_TYPE* Find(ContainerUnorderedMap<SPECIFIC_TYPE, KEY_TYPE> const& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* /*obj*/) + { + auto i = elements._element.find(handle); + if (i == elements._element.end()) + return nullptr; + else + return i->second; + } + + template<class SPECIFIC_TYPE, class KEY_TYPE> + SPECIFIC_TYPE* Find(ContainerUnorderedMap<TypeNull, KEY_TYPE> const& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/) + { + return nullptr; + } + + template<class SPECIFIC_TYPE, class KEY_TYPE, class T> + SPECIFIC_TYPE* Find(ContainerUnorderedMap<T, KEY_TYPE> const& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/) + { + return nullptr; + } + + template<class SPECIFIC_TYPE, class KEY_TYPE, class H, class T> + SPECIFIC_TYPE* Find(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE> const& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* /*obj*/) + { + SPECIFIC_TYPE* ret = Find(elements._elements, handle, (SPECIFIC_TYPE*)nullptr); + return ret ? ret : Find(elements._TailElements, handle, (SPECIFIC_TYPE*)nullptr); + } + + // Erase helpers + template<class SPECIFIC_TYPE, class KEY_TYPE> + bool Remove(ContainerUnorderedMap<SPECIFIC_TYPE, KEY_TYPE>& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* /*obj*/) + { + elements._element.erase(handle); + return true; + } + + template<class SPECIFIC_TYPE, class KEY_TYPE> + bool Remove(ContainerUnorderedMap<TypeNull, KEY_TYPE>& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/) + { + return false; + } + + template<class SPECIFIC_TYPE, class KEY_TYPE, class T> + bool Remove(ContainerUnorderedMap<T, KEY_TYPE>& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/) + { + return false; + } + + template<class SPECIFIC_TYPE, class KEY_TYPE, class H, class T> + bool Remove(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE>& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* /*obj*/) + { + bool ret = Remove(elements._elements, handle, (SPECIFIC_TYPE*)nullptr); + return ret ? ret : Remove(elements._TailElements, handle, (SPECIFIC_TYPE*)nullptr); + } + /* ContainerMapList Helpers */ // count functions - template<class SPECIFIC_TYPE> size_t Count(const ContainerMapList<SPECIFIC_TYPE>& elements, SPECIFIC_TYPE* /*fake*/) + template<class SPECIFIC_TYPE> + size_t Count(const ContainerMapList<SPECIFIC_TYPE>& elements, SPECIFIC_TYPE* /*fake*/) { return elements._element.getSize(); } - template<class SPECIFIC_TYPE> size_t Count(const ContainerMapList<TypeNull>& /*elements*/, SPECIFIC_TYPE* /*fake*/) + template<class SPECIFIC_TYPE> + size_t Count(const ContainerMapList<TypeNull>& /*elements*/, SPECIFIC_TYPE* /*fake*/) { return 0; } - template<class SPECIFIC_TYPE, class T> size_t Count(const ContainerMapList<T>& /*elements*/, SPECIFIC_TYPE* /*fake*/) + template<class SPECIFIC_TYPE, class T> + size_t Count(const ContainerMapList<T>& /*elements*/, SPECIFIC_TYPE* /*fake*/) { return 0; } - template<class SPECIFIC_TYPE, class T> size_t Count(const ContainerMapList<TypeList<SPECIFIC_TYPE, T>>& elements, SPECIFIC_TYPE* fake) + template<class SPECIFIC_TYPE, class T> + size_t Count(const ContainerMapList<TypeList<SPECIFIC_TYPE, T>>& elements, SPECIFIC_TYPE* fake) { return Count(elements._elements, fake); } - template<class SPECIFIC_TYPE, class H, class T> size_t Count(const ContainerMapList<TypeList<H, T>>& elements, SPECIFIC_TYPE* fake) + template<class SPECIFIC_TYPE, class H, class T> + size_t Count(const ContainerMapList<TypeList<H, T>>& elements, SPECIFIC_TYPE* fake) { return Count(elements._TailElements, fake); } // non-const insert functions - template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Insert(ContainerMapList<SPECIFIC_TYPE>& elements, SPECIFIC_TYPE* obj) + template<class SPECIFIC_TYPE> + SPECIFIC_TYPE* Insert(ContainerMapList<SPECIFIC_TYPE>& elements, SPECIFIC_TYPE* obj) { //elements._element[hdl] = obj; obj->AddToGrid(elements._element); return obj; } - template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Insert(ContainerMapList<TypeNull>& /*elements*/, SPECIFIC_TYPE* /*obj*/) + template<class SPECIFIC_TYPE> + SPECIFIC_TYPE* Insert(ContainerMapList<TypeNull>& /*elements*/, SPECIFIC_TYPE* /*obj*/) { return nullptr; } // this is a missed - template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Insert(ContainerMapList<T>& /*elements*/, SPECIFIC_TYPE* /*obj*/) + template<class SPECIFIC_TYPE, class T> + SPECIFIC_TYPE* Insert(ContainerMapList<T>& /*elements*/, SPECIFIC_TYPE* /*obj*/) { return nullptr; // a missed } // Recursion - template<class SPECIFIC_TYPE, class H, class T> SPECIFIC_TYPE* Insert(ContainerMapList<TypeList<H, T>>& elements, SPECIFIC_TYPE* obj) + template<class SPECIFIC_TYPE, class H, class T> + SPECIFIC_TYPE* Insert(ContainerMapList<TypeList<H, T>>& elements, SPECIFIC_TYPE* obj) { SPECIFIC_TYPE* t = Insert(elements._elements, obj); return (t != nullptr ? t : Insert(elements._TailElements, obj)); diff --git a/src/common/Dynamic/TypeContainerVisitor.h b/src/common/Dynamic/TypeContainerVisitor.h index d86a4d29f2..57d40d0f29 100644 --- a/src/common/Dynamic/TypeContainerVisitor.h +++ b/src/common/Dynamic/TypeContainerVisitor.h @@ -25,21 +25,6 @@ template<class VISITOR, class TYPE_CONTAINER> void VisitorHelper(VISITOR& v, TYP v.Visit(c); } -// terminate condition for container list -template<class VISITOR> void VisitorHelper(VISITOR& /*v*/, ContainerList<TypeNull>& /*c*/) { } - -template<class VISITOR, class T> void VisitorHelper(VISITOR& v, ContainerList<T>& c) -{ - v.Visit(c._element); -} - -// recursion for container list -template<class VISITOR, class H, class T> void VisitorHelper(VISITOR& v, ContainerList<TypeList<H, T>>& c) -{ - VisitorHelper(v, c._elements); - VisitorHelper(v, c._TailElements); -} - // terminate condition container map list template<class VISITOR> void VisitorHelper(VISITOR& /*v*/, ContainerMapList<TypeNull>& /*c*/) { } @@ -55,23 +40,31 @@ template<class VISITOR, class H, class T> void VisitorHelper(VISITOR& v, Contain VisitorHelper(v, c._TailElements); } -// array list -template<class VISITOR, class T> void VisitorHelper(VISITOR& v, ContainerArrayList<T>& c) +// for TypeMapContainer +template<class VISITOR, class OBJECT_TYPES> void VisitorHelper(VISITOR& v, TypeMapContainer<OBJECT_TYPES>& c) { - v.Visit(c._element); + VisitorHelper(v, c.GetElements()); } -template<class VISITOR> void VisitorHelper(VISITOR& /*v*/, ContainerArrayList<TypeNull>& /*c*/) { } +// TypeUnorderedMapContainer +template<class VISITOR, class KEY_TYPE> +void VisitorHelper(VISITOR& /*v*/, ContainerUnorderedMap<TypeNull, KEY_TYPE>& /*c*/) { } + +template<class VISITOR, class KEY_TYPE, class T> +void VisitorHelper(VISITOR& v, ContainerUnorderedMap<T, KEY_TYPE>& c) +{ + v.Visit(c._element); +} -// recursion -template<class VISITOR, class H, class T> void VisitorHelper(VISITOR& v, ContainerArrayList<TypeList<H, T>>& c) +template<class VISITOR, class KEY_TYPE, class H, class T> +void VisitorHelper(VISITOR& v, ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE>& c) { VisitorHelper(v, c._elements); VisitorHelper(v, c._TailElements); } -// for TypeMapContainer -template<class VISITOR, class OBJECT_TYPES> void VisitorHelper(VISITOR& v, TypeMapContainer<OBJECT_TYPES>& c) +template<class VISITOR, class OBJECT_TYPES, class KEY_TYPE> +void VisitorHelper(VISITOR& v, TypeUnorderedMapContainer<OBJECT_TYPES, KEY_TYPE>& c) { VisitorHelper(v, c.GetElements()); } diff --git a/src/common/Dynamic/TypeList.h b/src/common/Dynamic/TypeList.h index ca514c0d8b..239d261088 100644 --- a/src/common/Dynamic/TypeList.h +++ b/src/common/Dynamic/TypeList.h @@ -23,9 +23,10 @@ struct TypeList }; // enough for now.. can be expand at any point in time as needed -#define TYPELIST_1(T1) TypeList<T1, TypeNull> -#define TYPELIST_2(T1, T2) TypeList<T1, TYPELIST_1(T2) > -#define TYPELIST_3(T1, T2, T3) TypeList<T1, TYPELIST_2(T2, T3) > -#define TYPELIST_4(T1, T2, T3, T4) TypeList<T1, TYPELIST_3(T2, T3, T4) > -#define TYPELIST_5(T1, T2, T3, T4, T5) TypeList<T1, TYPELIST_4(T2, T3, T4, T5) > +#define TYPELIST_1(T1) TypeList<T1, TypeNull> +#define TYPELIST_2(T1, T2) TypeList<T1, TYPELIST_1(T2) > +#define TYPELIST_3(T1, T2, T3) TypeList<T1, TYPELIST_2(T2, T3) > +#define TYPELIST_4(T1, T2, T3, T4) TypeList<T1, TYPELIST_3(T2, T3, T4) > +#define TYPELIST_5(T1, T2, T3, T4, T5) TypeList<T1, TYPELIST_4(T2, T3, T4, T5) > +#define TYPELIST_6(T1, T2, T3, T4, T5, T6) TypeList<T1, TYPELIST_5(T2, T3, T4, T5, T6) > #endif diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp index 3ca55d72f1..c8e0591e5b 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp @@ -105,8 +105,8 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_CHARACTER_ACTIONS_SPEC, "SELECT button, action, type FROM character_action WHERE guid = ? AND spec = ? ORDER BY button", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_MAILITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, item_guid, itemEntry, owner_guid FROM mail_items mi JOIN item_instance ii ON mi.item_guid = ii.guid WHERE mail_id = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_AUCTION_ITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, itemguid, itemEntry FROM auctionhouse ah JOIN item_instance ii ON ah.itemguid = ii.guid", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_AUCTIONS, "SELECT id, auctioneerguid, itemguid, itemEntry, count, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid", CONNECTION_SYNCH); - PrepareStatement(CHAR_INS_AUCTION, "INSERT INTO auctionhouse (id, auctioneerguid, itemguid, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_AUCTIONS, "SELECT id, houseid, itemguid, itemEntry, count, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid", CONNECTION_SYNCH); + PrepareStatement(CHAR_INS_AUCTION, "INSERT INTO auctionhouse (id, houseid, itemguid, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_AUCTION, "DELETE FROM auctionhouse WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_AUCTION_BID, "UPDATE auctionhouse SET buyguid = ?, lastbid = ? WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_MAIL, "INSERT INTO mail(id, messageType, stationery, mailTemplateId, sender, receiver, subject, body, has_items, expire_time, deliver_time, money, cod, checked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); @@ -280,11 +280,11 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_PLAYER_HOMEBIND, "DELETE FROM character_homebind WHERE guid = ?", CONNECTION_ASYNC); // Corpse - PrepareStatement(CHAR_SEL_CORPSES, "SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, corpseGuid, guid FROM corpse WHERE corpseType <> 0", CONNECTION_SYNCH); - PrepareStatement(CHAR_INS_CORPSE, "INSERT INTO corpse (corpseGuid, guid, posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_CORPSE, "DELETE FROM corpse WHERE corpseGuid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_PLAYER_CORPSES, "DELETE FROM corpse WHERE guid = ? AND corpseType <> 0", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_OLD_CORPSES, "DELETE FROM corpse WHERE corpseType = 0 OR time < (UNIX_TIMESTAMP(NOW()) - ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CORPSES, "SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_INS_CORPSE, "INSERT INTO corpse (guid, posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_CORPSE, "DELETE FROM corpse WHERE guid = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_CORPSES_FROM_MAP, "DELETE FROM corpse WHERE mapId = ? AND instanceId = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CORPSE_LOCATION, "SELECT mapId, posX, posY, posZ, orientation FROM corpse WHERE guid = ?", CONNECTION_ASYNC); // Creature respawn PrepareStatement(CHAR_SEL_CREATURE_RESPAWNS, "SELECT guid, respawnTime FROM creature_respawn WHERE mapId = ? AND instanceId = ?", CONNECTION_SYNCH); diff --git a/src/server/database/Database/Implementation/CharacterDatabase.h b/src/server/database/Database/Implementation/CharacterDatabase.h index 9bb529e1a9..4e22362dd3 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.h +++ b/src/server/database/Database/Implementation/CharacterDatabase.h @@ -245,8 +245,8 @@ enum CharacterDatabaseStatements CHAR_SEL_CORPSES, CHAR_INS_CORPSE, CHAR_DEL_CORPSE, - CHAR_DEL_PLAYER_CORPSES, - CHAR_DEL_OLD_CORPSES, + CHAR_DEL_CORPSES_FROM_MAP, + CHAR_SEL_CORPSE_LOCATION, CHAR_SEL_CREATURE_RESPAWNS, CHAR_REP_CREATURE_RESPAWN, diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h index 4120f8ccf9..03a54795af 100644 --- a/src/server/game/AI/CoreAI/GameObjectAI.h +++ b/src/server/game/AI/CoreAI/GameObjectAI.h @@ -30,8 +30,8 @@ public: // Pass parameters between AI virtual void DoAction(int32 /*param = 0 */) {} - virtual void SetGUID(uint64 /*guid*/, int32 /*id = 0 */) {} - virtual uint64 GetGUID(int32 /*id = 0 */) const { return 0; } + virtual void SetGUID(ObjectGuid /*guid*/, int32 /*id = 0 */) {} + virtual ObjectGuid GetGUID(int32 /*id = 0 */) const { return ObjectGuid::Empty; } static int Permissible(GameObject const* go); @@ -43,8 +43,6 @@ public: virtual uint32 GetDialogStatus(Player* /*player*/) { return DIALOG_STATUS_SCRIPTED_NO_STATUS; } virtual void Destroyed(Player* /*player*/, uint32 /*eventId*/) {} virtual uint32 GetData(uint32 /*id*/) const { return 0; } - virtual void SetData64(uint32 /*id*/, uint64 /*value*/) {} - virtual uint64 GetData64(uint32 /*id*/) const { return 0; } virtual void SetData(uint32 /*id*/, uint32 /*value*/) {} virtual void OnGameEvent(bool /*start*/, uint16 /*eventId*/) {} virtual void OnStateChanged(uint32 /*state*/, Unit* /*unit*/) {} diff --git a/src/server/game/AI/CoreAI/PassiveAI.cpp b/src/server/game/AI/CoreAI/PassiveAI.cpp index 021a5ceccb..d92f2dd9a9 100644 --- a/src/server/game/AI/CoreAI/PassiveAI.cpp +++ b/src/server/game/AI/CoreAI/PassiveAI.cpp @@ -76,5 +76,5 @@ void CritterAI::UpdateAI(uint32 diff) void TriggerAI::IsSummonedBy(Unit* summoner) { if (me->m_spells[0]) - me->CastSpell(me, me->m_spells[0], false, 0, 0, summoner ? summoner->GetGUID() : 0); + me->CastSpell(me, me->m_spells[0], false, 0, 0, summoner ? summoner->GetGUID() : ObjectGuid::Empty); } diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index f10759bb43..73b85f3e39 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -59,7 +59,7 @@ void PetAI::_stopAttack() if (!me->IsAlive()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature stoped attacking cuz his dead [guid=%u]", me->GetGUIDLow()); + LOG_DEBUG("server", "Creature stoped attacking cuz his dead [%s]", me->GetGUID().ToString().c_str()); #endif me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); @@ -157,7 +157,7 @@ void PetAI::UpdateAI(uint32 diff) if (_needToStop()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Pet AI stopped attacking [guid=%u]", me->GetGUIDLow()); + LOG_DEBUG("server", "Pet AI stopped attacking [%s]", me->GetGUID().ToString().c_str()); #endif _stopAttack(); return; @@ -250,7 +250,7 @@ void PetAI::UpdateAI(uint32 diff) continue; } - Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0); + Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE); spell->LoadScripts(); // xinef: load for CanAutoCast (calling CheckPetCast) bool spellUsed = false; @@ -272,9 +272,9 @@ void PetAI::UpdateAI(uint32 diff) // No enemy, check friendly if (!spellUsed) { - for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar) + for (ObjectGuid const guid : m_AllySet) { - Unit* ally = ObjectAccessor::GetUnit(*me, *tar); + Unit* ally = ObjectAccessor::GetUnit(*me, guid); //only buff targets that are in combat, unless the spell can only be cast while out of combat if (!ally) @@ -295,7 +295,7 @@ void PetAI::UpdateAI(uint32 diff) } else if (me->GetVictim() && CanAttack(me->GetVictim(), spellInfo) && spellInfo->CanBeUsedInCombat()) { - Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0); + Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE); if (spell->CanAutoCast(me->GetVictim())) targetSpellStore.push_back(std::make_pair(me->GetVictim(), spell)); else @@ -389,7 +389,7 @@ void PetAI::KilledUnit(Unit* victim) return; // Xinef: if pet is channeling a spell and owner killed something different, dont interrupt it - if (me->HasUnitState(UNIT_STATE_CASTING) && me->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT) && me->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT) != victim->GetGUID()) + if (me->HasUnitState(UNIT_STATE_CASTING) && me->GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT) && me->GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT) != victim->GetGUID()) return; // Clear target just in case. May help problem where health / focus / mana @@ -537,7 +537,7 @@ void PetAI::HandleReturnMovement() ClearCharmInfoFlags(); me->GetCharmInfo()->SetIsReturning(true); me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MovePoint(me->GetUInt32Value(OBJECT_FIELD_GUID), x, y, z); + me->GetMotionMaster()->MovePoint(me->GetGUID().GetCounter(), x, y, z); } } } @@ -557,7 +557,7 @@ void PetAI::HandleReturnMovement() } me->GetCharmInfo()->SetForcedSpell(0); - me->GetCharmInfo()->SetForcedTargetGUID(0); + me->GetCharmInfo()->SetForcedTargetGUID(); // xinef: remember that npcs summoned by npcs can also be pets me->DeleteThreatList(); @@ -570,7 +570,7 @@ void PetAI::SpellHit(Unit* caster, const SpellInfo* spellInfo) if (spellInfo->HasAura(SPELL_AURA_MOD_TAUNT) && !me->HasReactState(REACT_PASSIVE)) { me->GetCharmInfo()->SetForcedSpell(0); - me->GetCharmInfo()->SetForcedTargetGUID(0); + me->GetCharmInfo()->SetForcedTargetGUID(); AttackStart(caster); } } @@ -627,7 +627,7 @@ void PetAI::MovementInform(uint32 moveType, uint32 data) { // Pet is returning to where stay was clicked. data should be // pet's GUIDLow since we set that as the waypoint ID - if (data == me->GetGUIDLow() && me->GetCharmInfo()->IsReturning()) + if (data == me->GetGUID().GetCounter() && me->GetCharmInfo()->IsReturning()) { ClearCharmInfoFlags(); me->GetCharmInfo()->SetIsAtStay(true); @@ -640,7 +640,7 @@ void PetAI::MovementInform(uint32 moveType, uint32 data) { // If data is owner's GUIDLow then we've reached follow point, // otherwise we're probably chasing a creature - if (me->GetCharmerOrOwner() && me->GetCharmInfo() && data == me->GetCharmerOrOwner()->GetGUIDLow() && me->GetCharmInfo()->IsReturning()) + if (me->GetCharmerOrOwner() && me->GetCharmInfo() && data == me->GetCharmerOrOwner()->GetGUID().GetCounter() && me->GetCharmInfo()->IsReturning()) { ClearCharmInfoFlags(); me->GetCharmInfo()->SetIsFollowing(true); @@ -681,7 +681,7 @@ bool PetAI::CanAttack(Unit* target, const SpellInfo* spellInfo) // pussywizard: ZOMG! TEMP! if (!me->GetCharmInfo()) { - LOG_INFO("misc", "PetAI::CanAttack (A1) - %u, %u", me->GetEntry(), GUID_LOPART(me->GetOwnerGUID())); + LOG_INFO("misc", "PetAI::CanAttack (A1) - %u, %s", me->GetEntry(), me->GetOwnerGUID().ToString().c_str()); return false; } diff --git a/src/server/game/AI/CoreAI/PetAI.h b/src/server/game/AI/CoreAI/PetAI.h index 22df8a84f1..cae2a7e553 100644 --- a/src/server/game/AI/CoreAI/PetAI.h +++ b/src/server/game/AI/CoreAI/PetAI.h @@ -66,7 +66,7 @@ private: void UpdateAllies(); TimeTracker i_tracker; - std::set<uint64> m_AllySet; + GuidSet m_AllySet; uint32 m_updateAlliesTimer; float combatRange; diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp index 51a4c1885b..2fd9044642 100644 --- a/src/server/game/AI/CoreAI/TotemAI.cpp +++ b/src/server/game/AI/CoreAI/TotemAI.cpp @@ -22,7 +22,7 @@ int TotemAI::Permissible(Creature const* creature) return PERMIT_BASE_NO; } -TotemAI::TotemAI(Creature* c) : CreatureAI(c), i_victimGuid(0) +TotemAI::TotemAI(Creature* c) : CreatureAI(c) { ASSERT(c->IsTotem()); } @@ -87,7 +87,7 @@ void TotemAI::UpdateAI(uint32 /*diff*/) me->CastSpell(victim, me->ToTotem()->GetSpell(), false); } else - i_victimGuid = 0; + i_victimGuid.Clear(); } void TotemAI::AttackStart(Unit* /*victim*/) diff --git a/src/server/game/AI/CoreAI/TotemAI.h b/src/server/game/AI/CoreAI/TotemAI.h index 2bc62085e3..88e070ad10 100644 --- a/src/server/game/AI/CoreAI/TotemAI.h +++ b/src/server/game/AI/CoreAI/TotemAI.h @@ -28,7 +28,7 @@ public: static int Permissible(Creature const* creature); private: - uint64 i_victimGuid; + ObjectGuid i_victimGuid; }; class KillMagnetEvent : public BasicEvent diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 60ba215e06..fe3b5cbba2 100644 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -185,8 +185,8 @@ public: virtual void DoAction(int32 /*param*/) {} virtual uint32 GetData(uint32 /*id = 0*/) const { return 0; } virtual void SetData(uint32 /*id*/, uint32 /*value*/) {} - virtual void SetGUID(uint64 /*guid*/, int32 /*id*/ = 0) {} - virtual uint64 GetGUID(int32 /*id*/ = 0) const { return 0; } + virtual void SetGUID(ObjectGuid /*guid*/, int32 /*id*/ = 0) {} + virtual ObjectGuid GetGUID(int32 /*id*/ = 0) const { return ObjectGuid::Empty; } Unit* SelectTarget(SelectAggroTarget targetType, uint32 position = 0, float dist = 0.0f, bool playerOnly = false, int32 aura = 0); // Select the targets satifying the predicate. diff --git a/src/server/game/AI/CreatureAISelector.cpp b/src/server/game/AI/CreatureAISelector.cpp index 7aa5c21a1b..3291a83f04 100644 --- a/src/server/game/AI/CreatureAISelector.cpp +++ b/src/server/game/AI/CreatureAISelector.cpp @@ -84,7 +84,7 @@ namespace FactorySelector #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) // select NullCreatureAI if not another cases ainame = (ai_factory == nullptr) ? "NullCreatureAI" : ai_factory->key(); - LOG_DEBUG("scripts.ai", "Creature %u used AI is %s.", creature->GetGUIDLow(), ainame.c_str()); + LOG_DEBUG("scripts.ai", "Creature %s used AI is %s.", creature->GetGUID().ToString().c_str(), ainame.c_str()); #endif return (ai_factory == nullptr ? new NullCreatureAI(creature) : ai_factory->Create(creature)); } @@ -131,7 +131,7 @@ namespace FactorySelector #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) std::string ainame = (ai_factory == nullptr || go->GetScriptId()) ? "NullGameObjectAI" : ai_factory->key(); - LOG_DEBUG("scripts.ai", "GameObject %u used AI is %s.", go->GetGUIDLow(), ainame.c_str()); + LOG_DEBUG("scripts.ai", "GameObject %s used AI is %s.", go->GetGUID().ToString().c_str(), ainame.c_str()); #endif return (ai_factory == nullptr ? new NullGameObjectAI(go) : ai_factory->Create(go)); diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 96e9bc6e8b..5b0c8ccd65 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -198,7 +198,7 @@ void ScriptedAI::DoPlaySoundToSet(WorldObject* source, uint32 soundId) if (!sSoundEntriesStore.LookupEntry(soundId)) { - LOG_ERROR("server", "TSCR: Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", soundId, source->GetTypeId(), source->GetGUIDLow()); + LOG_ERROR("server", "TSCR: Invalid soundId %u used in DoPlaySoundToSet (Source: %s)", soundId, source->GetGUID().ToString().c_str()); return; } @@ -359,7 +359,8 @@ void ScriptedAI::DoTeleportPlayer(Unit* unit, float x, float y, float z, float o if (Player* player = unit->ToPlayer()) player->TeleportTo(unit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); else - LOG_ERROR("server", "TSCR: Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), unit->GetTypeId(), unit->GetGUID(), x, y, z, o); + LOG_ERROR("server", "TSCR: Creature %s Tried to teleport non-player unit %s to x: %f y:%f z: %f o: %f. Aborted.", + me->GetGUID().ToString().c_str(), unit->GetGUID().ToString().c_str(), x, y, z, o); } void ScriptedAI::DoTeleportAll(float x, float y, float z, float o) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index 4504c95983..245234ce6d 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -21,7 +21,7 @@ class InstanceScript; class SummonList { public: - typedef std::list<uint64> StorageType; + typedef GuidList StorageType; typedef StorageType::iterator iterator; typedef StorageType::const_iterator const_iterator; typedef StorageType::size_type size_type; @@ -107,7 +107,7 @@ public: // We need to use a copy of SummonList here, otherwise original SummonList would be modified StorageType listCopy = storage_; - acore::Containers::RandomResizeList<uint64, Predicate>(listCopy, predicate, max); + acore::Containers::RandomResizeList<ObjectGuid, Predicate>(listCopy, predicate, max); for (StorageType::iterator i = listCopy.begin(); i != listCopy.end(); ++i) { Creature* summon = ObjectAccessor::GetCreature(*me, *i); @@ -137,7 +137,7 @@ class EntryCheckPredicate { public: EntryCheckPredicate(uint32 entry) : _entry(entry) {} - bool operator()(uint64 guid) { return GUID_ENPART(guid) == _entry; } + bool operator()(ObjectGuid guid) { return guid.GetEntry() == _entry; } private: uint32 _entry; @@ -149,7 +149,7 @@ public: bool operator() (WorldObject* unit) const { if (unit->GetTypeId() != TYPEID_PLAYER) - if (!IS_PLAYER_GUID(unit->ToUnit()->GetOwnerGUID())) + if (!unit->ToUnit()->GetOwnerGUID().IsPlayer()) return true; return false; diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 6cc91503f8..34316eaecf 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -22,7 +22,6 @@ enum ePoints }; npc_escortAI::npc_escortAI(Creature* creature) : ScriptedAI(creature), - m_uiPlayerGUID(0), m_uiWPWaitTimer(1000), m_uiPlayerCheckTimer(0), m_uiEscortState(STATE_ESCORT_NONE), @@ -442,7 +441,7 @@ void npc_escortAI::SetRun(bool on) } //TODO: get rid of this many variables passed in function. -void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false */, uint64 playerGUID /* = 0 */, Quest const* quest /* = nullptr */, bool instantRespawn /* = false */, bool canLoopPath /* = false */, bool resetWaypoints /* = true */) +void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false */, ObjectGuid playerGUID /* = ObjectGuid::Empty */, Quest const* quest /* = nullptr */, bool instantRespawn /* = false */, bool canLoopPath /* = false */, bool resetWaypoints /* = true */) { if (me->GetVictim()) { @@ -503,7 +502,8 @@ void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("scripts.ai", "TSCR: EscortAI started with " UI64FMTD " waypoints. ActiveAttacker = %d, Run = %d, PlayerGUID = " UI64FMTD "", uint64(WaypointList.size()), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID); + LOG_DEBUG("scripts.ai", "TSCR: EscortAI started with " UI64FMTD " waypoints. ActiveAttacker = %d, Run = %d, PlayerGUID = %s", + uint64(WaypointList.size()), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID.ToString().c_str()); #endif CurrentWP = WaypointList.begin(); diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h index 665fe9a94f..35351c3ad4 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h @@ -78,7 +78,7 @@ public: virtual void WaypointReached(uint32 pointId) = 0; virtual void WaypointStart(uint32 /*pointId*/) {} - void Start(bool isActiveAttacker = true, bool run = false, uint64 playerGUID = 0, Quest const* quest = nullptr, bool instantRespawn = false, bool canLoopPath = false, bool resetWaypoints = true); + void Start(bool isActiveAttacker = true, bool run = false, ObjectGuid playerGUID = ObjectGuid::Empty, Quest const* quest = nullptr, bool instantRespawn = false, bool canLoopPath = false, bool resetWaypoints = true); void SetRun(bool on = true); void SetEscortPaused(bool on); @@ -93,7 +93,7 @@ public: void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; } bool GetAttack() { return m_bIsActiveAttacker; }//used in EnterEvadeMode override void SetCanAttack(bool attack) { m_bIsActiveAttacker = attack; } - uint64 GetEventStarterGUID() { return m_uiPlayerGUID; } + ObjectGuid GetEventStarterGUID() { return m_uiPlayerGUID; } void AddEscortState(uint32 escortState) { m_uiEscortState |= escortState; } void RemoveEscortState(uint32 escortState) { m_uiEscortState &= ~escortState; } @@ -106,7 +106,7 @@ private: bool IsPlayerOrGroupInRange(); void FillPointMovementListForCreature(); - uint64 m_uiPlayerGUID; + ObjectGuid m_uiPlayerGUID; uint32 m_uiWPWaitTimer; uint32 m_uiPlayerCheckTimer; uint32 m_uiEscortState; diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index 3f34f96bf3..053d05bef3 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -23,7 +23,6 @@ enum ePoints }; FollowerAI::FollowerAI(Creature* creature) : ScriptedAI(creature), - m_uiLeaderGUID(0), m_uiUpdateFollowTimer(2500), m_uiFollowState(STATE_FOLLOW_NONE), m_pQuestForFollow(nullptr) @@ -301,7 +300,7 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, const Qu me->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("scripts.ai", "TSCR: FollowerAI start follow %s (GUID " UI64FMTD ")", player->GetName().c_str(), m_uiLeaderGUID); + LOG_DEBUG("scripts.ai", "TSCR: FollowerAI start follow %s (%s)", player->GetName().c_str(), m_uiLeaderGUID.ToString().c_str()); #endif } diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h index 68a5b4943a..9dbebf3c9c 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h @@ -58,7 +58,7 @@ private: bool AssistPlayerInCombat(Unit* who); - uint64 m_uiLeaderGUID; + ObjectGuid m_uiLeaderGUID; uint32 m_uiUpdateFollowTimer; uint32 m_uiFollowState; diff --git a/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp b/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp index 9d610fce81..15ea852f7f 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp @@ -31,7 +31,7 @@ void AddGossipItemFor(Player* player, uint32 gossipMenuID, uint32 gossipMenuItem player->PlayerTalkClass->GetGossipMenu().AddMenuItem(gossipMenuID, gossipMenuItemID, sender, action); } -void SendGossipMenuFor(Player* player, uint32 npcTextID, uint64 const& guid) +void SendGossipMenuFor(Player* player, uint32 npcTextID, ObjectGuid const guid) { player->PlayerTalkClass->SendGossipMenu(npcTextID, guid); } diff --git a/src/server/game/AI/ScriptedAI/ScriptedGossip.h b/src/server/game/AI/ScriptedAI/ScriptedGossip.h index 2891a6db3c..3d20f0aea3 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedGossip.h +++ b/src/server/game/AI/ScriptedAI/ScriptedGossip.h @@ -83,7 +83,7 @@ void AddGossipItemFor(Player* player, uint32 icon, std::string const& text, uint void AddGossipItemFor(Player* player, uint32 gossipMenuID, uint32 gossipMenuItemID, uint32 sender, uint32 action); // Send menu text -void SendGossipMenuFor(Player* player, uint32 npcTextID, uint64 const& guid); +void SendGossipMenuFor(Player* player, uint32 npcTextID, ObjectGuid const guid); void SendGossipMenuFor(Player* player, uint32 npcTextID, Creature const* creature); // Close menu @@ -100,7 +100,7 @@ void CloseGossipMenuFor(Player* player); #define ADD_GOSSIP_ITEM(a, b, c, d) PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, a, b, c, d, "", 0) #define ADD_GOSSIP_ITEM_EXTENDED(a, b, c, d, e, f, g) PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, a, b, c, d, e, f, g) -// This fuction Sends the current menu to show to client, a - NPCTEXTID(uint32), b - npc guid(uint64) +// This fuction Sends the current menu to show to client, a - NPCTEXTID(uint32), b - npc guid(ObjectGuid) #define SEND_GOSSIP_MENU(a, b) PlayerTalkClass->SendGossipMenu(a, b) // Closes the Menu diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 1cab89e7aa..33d6d596a9 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -50,7 +50,6 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c) mDespawnState = 0; mEscortInvokerCheckTimer = 1000; - mFollowGuid = 0; mFollowDist = 0; mFollowAngle = 0; mFollowCredit = 0; @@ -297,7 +296,7 @@ void SmartAI::EndPath(bool fail) if (!groupGuy || !player->IsInMap(groupGuy)) continue; - if (!fail && groupGuy->IsAtGroupRewardDistance(me) && !groupGuy->GetCorpse()) + if (!fail && groupGuy->IsAtGroupRewardDistance(me) && !groupGuy->HasCorpse()) groupGuy->AreaExploredOrEventHappens(mEscortQuestID); else if (fail && groupGuy->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE) groupGuy->FailQuest(mEscortQuestID); @@ -305,7 +304,7 @@ void SmartAI::EndPath(bool fail) } else { - if (!fail && player->IsAtGroupRewardDistance(me) && !player->GetCorpse()) + if (!fail && player->IsAtGroupRewardDistance(me) && !player->HasCorpse()) player->GroupEventHappens(mEscortQuestID, me); else if (fail && player->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE) player->FailQuest(mEscortQuestID); @@ -318,7 +317,7 @@ void SmartAI::EndPath(bool fail) if (GetScript()->IsPlayer((*iter))) { Player* player = (*iter)->ToPlayer(); - if (!fail && player->IsAtGroupRewardDistance(me) && !player->GetCorpse()) + if (!fail && player->IsAtGroupRewardDistance(me) && !player->HasCorpse()) player->AreaExploredOrEventHappens(mEscortQuestID); else if (fail && player->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE) player->FailQuest(mEscortQuestID); @@ -616,7 +615,7 @@ void SmartAI::EnterEvadeMode() if (!me->IsAlive() || me->IsInEvadeMode()) return; - if (IS_PLAYER_GUID(me->GetCharmerGUID()) || me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED)) + if (me->GetCharmerGUID().IsPlayer() || me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED)) { me->AttackStop(); return; @@ -688,7 +687,7 @@ bool SmartAI::CanAIAttack(const Unit* /*who*/) const bool SmartAI::AssistPlayerInCombat(Unit* who) { // Xinef: if unit has no victim, or victim is player controlled thing - if (!who->GetVictim() || IS_PLAYER_GUID(who->GetCharmerOrOwnerOrOwnGUID())) + if (!who->GetVictim() || who->GetCharmerOrOwnerOrOwnGUID().IsPlayer()) return false; //experimental (unknown) flag not present @@ -696,7 +695,7 @@ bool SmartAI::AssistPlayerInCombat(Unit* who) return false; // Xinef: victim of unit has to be a player controlled unit - if (!IS_PLAYER_GUID(who->GetVictim()->GetCharmerOrOwnerOrOwnGUID())) + if (!who->GetVictim()->GetCharmerOrOwnerOrOwnGUID().IsPlayer()) return false; // Xinef: Check if victim can be assisted @@ -724,7 +723,7 @@ void SmartAI::JustRespawned() mJustReset = true; JustReachedHome(); GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN); - mFollowGuid = 0;//do not reset follower on Reset(), we need it after combat evade + mFollowGuid.Clear();//do not reset follower on Reset(), we need it after combat evade mFollowDist = 0; mFollowAngle = 0; mFollowCredit = 0; @@ -900,13 +899,13 @@ void SmartAI::SetData(uint32 id, uint32 value) GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, nullptr, id, value); } -void SmartAI::SetGUID(uint64 /*guid*/, int32 /*id*/) +void SmartAI::SetGUID(ObjectGuid /*guid*/, int32 /*id*/) { } -uint64 SmartAI::GetGUID(int32 /*id*/) const +ObjectGuid SmartAI::GetGUID(int32 /*id*/) const { - return 0; + return ObjectGuid::Empty; } void SmartAI::SetRun(bool run) @@ -1014,7 +1013,7 @@ void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, ui void SmartAI::StopFollow(bool complete) { - mFollowGuid = 0; + mFollowGuid.Clear(); mFollowDist = 0; mFollowAngle = 0; mFollowCredit = 0; diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 3f8b42b44e..d32b9ac816 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -144,10 +144,10 @@ public: void SetData(uint32 id, uint32 value) override; // Used in scripts to share variables - void SetGUID(uint64 guid, int32 id = 0) override; + void SetGUID(ObjectGuid guid, int32 id = 0) override; // Used in scripts to share variables - uint64 GetGUID(int32 id = 0) const override; + ObjectGuid GetGUID(int32 id = 0) const override; //core related static int32 Permissible(const Creature*); @@ -194,7 +194,7 @@ private: uint32 mFollowCredit; uint32 mFollowArrivedEntry; bool mFollowArrivedAlive; - uint64 mFollowGuid; + ObjectGuid mFollowGuid; float mFollowDist; float mFollowAngle; diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index c76d6dcc70..5de738de34 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -61,9 +61,6 @@ SmartScript::SmartScript() mUseTextTimer = false; mTalkerEntry = 0; mTemplate = SMARTAI_TEMPLATE_BASIC; - meOrigGUID = 0; - goOrigGUID = 0; - mLastInvoker = 0; mScriptType = SMART_SCRIPT_TYPE_CREATURE; isProcessingTimedActionList = false; @@ -103,7 +100,7 @@ void SmartScript::OnReset() } } ProcessEventsFor(SMART_EVENT_RESET); - mLastInvoker = 0; + mLastInvoker.Clear(); mCounterList.clear(); // Xinef: Fix Combat Movement @@ -146,7 +143,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) if (Unit* tempInvoker = GetLastInvoker()) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: Invoker: %s (guidlow: %u)", tempInvoker->GetName().c_str(), tempInvoker->GetGUIDLow()); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: Invoker: %s (%s)", tempInvoker->GetName().c_str(), tempInvoker->GetGUID().ToString().c_str()); #endif bool isControlled = e.action.MoveToPos.controlled > 0; @@ -202,7 +199,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u mUseTextTimer = true; sCreatureTextMgr->SendChat(talker, uint8(e.action.talk.textGroupID), talkTarget); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: %s (GuidLow: %u), textId: %u", talker->GetName().c_str(), talker->GetGUIDLow(), mLastTextID); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: %s (%s), textId: %u", talker->GetName().c_str(), talker->GetGUID().ToString().c_str(), mLastTextID); #endif break; } @@ -221,8 +218,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u sCreatureTextMgr->SendChat(me, uint8(e.action.talk.textGroupID), IsPlayer(templastInvoker) ? templastInvoker : 0, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, (*itr)->ToPlayer()); } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: %s (GuidLow: %u), textGroupId: %u", - (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), uint8(e.action.talk.textGroupID)); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: %s (%s), textGroupId: %u", + (*itr)->GetName().c_str(), (*itr)->GetGUID().ToString().c_str(), uint8(e.action.talk.textGroupID)); #endif } @@ -241,8 +238,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToUnit()->HandleEmoteCommand(e.action.emote.emote); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: %s (GuidLow: %u), emote: %u", - (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.emote.emote); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: %s (%s), emote: %u", + (*itr)->GetName().c_str(), (*itr)->GetGUID().ToString().c_str(), e.action.emote.emote); #endif } } @@ -262,8 +259,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->SendPlaySound(e.action.sound.sound, e.action.sound.onlySelf > 0); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (GuidLow: %u), sound: %u, onlyself: %u", - (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.sound.sound, e.action.sound.onlySelf); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (%s), sound: %u, onlyself: %u", + (*itr)->GetName().c_str(), (*itr)->GetGUID().ToString().c_str(), e.action.sound.sound, e.action.sound.onlySelf); #endif } } @@ -307,8 +304,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u uint32 sound = temp[urand(0, count - 1)]; (*itr)->SendPlaySound(sound, e.action.randomSound.onlySelf > 0); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: %s (GuidLow: %u), sound: %u, onlyself: %u", - (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), sound, e.action.randomSound.onlySelf); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: %s (%s), sound: %u, onlyself: %u", + (*itr)->GetName().c_str(), (*itr)->GetGUID().ToString().c_str(), sound, e.action.randomSound.onlySelf); #endif } } @@ -357,8 +354,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->SendPlayMusic(e.action.music.sound, e.action.music.onlySelf > 0); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MUSIC: target: %s (GuidLow: %u), sound: %u, onlySelf: %u, type: %u", - (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.music.sound, e.action.music.onlySelf, e.action.music.type); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MUSIC: target: %s (%s), sound: %u, onlySelf: %u, type: %u", + (*itr)->GetName().c_str(), (*itr)->GetGUID().ToString().c_str(), e.action.music.sound, e.action.music.onlySelf, e.action.music.type); #endif } } @@ -432,8 +429,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u uint32 sound = temp[urand(0, count - 1)]; (*itr)->SendPlayMusic(sound, e.action.randomMusic.onlySelf > 0); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_MUSIC: target: %s (GuidLow: %u), sound: %u, onlyself: %u, type: %u", - (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), sound, e.action.randomMusic.onlySelf, e.action.randomMusic.type); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_MUSIC: target: %s (%s), sound: %u, onlyself: %u, type: %u", + (*itr)->GetName().c_str(), (*itr)->GetGUID().ToString().c_str(), sound, e.action.randomMusic.onlySelf, e.action.randomMusic.type); #endif } } @@ -454,8 +451,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToCreature()->setFaction(e.action.faction.factionID); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry %u, GuidLow %u set faction to %u", - (*itr)->GetEntry(), (*itr)->GetGUIDLow(), e.action.faction.factionID); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry %u (%s) set faction to %u", + (*itr)->GetEntry(), (*itr)->GetGUID().ToString().c_str(), e.action.faction.factionID); #endif } else @@ -466,8 +463,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToCreature()->setFaction(ci->faction); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry %u, GuidLow %u set faction to %u", - (*itr)->GetEntry(), (*itr)->GetGUIDLow(), ci->faction); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry %u (%s) set faction to %u", + (*itr)->GetEntry(), (*itr)->GetGUID().ToString().c_str(), ci->faction); #endif } } @@ -500,8 +497,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u uint32 displayId = ObjectMgr::ChooseDisplayId(ci); (*itr)->ToCreature()->SetDisplayId(displayId); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry %u, GuidLow %u set displayid to %u", - (*itr)->GetEntry(), (*itr)->GetGUIDLow(), displayId); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry %u (%s) set displayid to %u", + (*itr)->GetEntry(), (*itr)->GetGUID().ToString().c_str(), displayId); #endif } } @@ -510,8 +507,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToCreature()->SetDisplayId(e.action.morphOrMount.model); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry %u, GuidLow %u set displayid to %u", - (*itr)->GetEntry(), (*itr)->GetGUIDLow(), e.action.morphOrMount.model); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry %u (%s) set displayid to %u", + (*itr)->GetEntry(), (*itr)->GetGUID().ToString().c_str(), e.action.morphOrMount.model); #endif } } @@ -519,8 +516,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToCreature()->DeMorph(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry %u, GuidLow %u demorphs.", - (*itr)->GetEntry(), (*itr)->GetGUIDLow()); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry %u (%s) demorphs.", + (*itr)->GetEntry(), (*itr)->GetGUID().ToString().c_str()); #endif } } @@ -540,8 +537,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToPlayer()->FailQuest(e.action.quest.quest); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_FAIL_QUEST: Player guidLow %u fails quest %u", - (*itr)->GetGUIDLow(), e.action.quest.quest); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_FAIL_QUEST: Player %s fails quest %u", + (*itr)->GetGUID().ToString().c_str(), e.action.quest.quest); #endif } } @@ -569,8 +566,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u PlayerMenu menu(session); menu.SendQuestGiverQuestDetails(q, me->GetGUID(), true); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow %u - offering quest %u", - (*itr)->GetGUIDLow(), e.action.questOffer.questID); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player %s- offering quest %u", + (*itr)->GetGUID().ToString().c_str(), e.action.questOffer.questID); #endif } } @@ -578,8 +575,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToPlayer()->AddQuestAndCheckCompletion(q, nullptr); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow %u - quest %u added", - (*itr)->GetGUIDLow(), e.action.questOffer.questID); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player %s - quest %u added", + (*itr)->GetGUID().ToString().c_str(), e.action.questOffer.questID); #endif } } @@ -643,8 +640,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u uint32 emote = temp[urand(0, count - 1)]; (*itr)->ToUnit()->HandleEmoteCommand(emote); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_EMOTE: Creature guidLow %u handle random emote %u", - (*itr)->GetGUIDLow(), emote); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_EMOTE: Creature %s handle random emote %u", + (*itr)->GetGUID().ToString().c_str(), emote); #endif } } @@ -664,8 +661,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { me->getThreatManager().modifyThreatPercent(target, e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature guidLow %u modify threat for unit %u, value %i", - me->GetGUIDLow(), target->GetGUIDLow(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature %s modify threat for unit %s, value %i", + me->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); #endif } } @@ -686,8 +683,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { me->getThreatManager().modifyThreatPercent((*itr)->ToUnit(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature guidLow %u modify threat for unit %u, value %i", - me->GetGUIDLow(), (*itr)->GetGUIDLow(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature %s modify threat for unit %s, value %i", + me->GetGUID().ToString().c_str(), (*itr)->GetGUID().ToString().c_str(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); #endif } } @@ -715,8 +712,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { player->GroupEventHappens(e.action.quest.quest, me); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: Player guidLow %u credited quest %u", - (*itr)->GetGUIDLow(), e.action.quest.quest); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: Player %s credited quest %u", + (*itr)->GetGUID().ToString().c_str(), e.action.quest.quest); #endif } } @@ -827,8 +824,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToUnit()->AddAura(e.action.cast.spell, (*itr)->ToUnit()); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ADD_AURA: Adding aura %u to unit %u", - e.action.cast.spell, (*itr)->GetGUIDLow()); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ADD_AURA: Adding aura %u to unit %s", + e.action.cast.spell, (*itr)->GetGUID().ToString().c_str()); #endif } } @@ -851,8 +848,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u (*itr)->ToGameObject()->SetLootState(GO_READY); (*itr)->ToGameObject()->UseDoorOrButton(0, !!e.action.activateObject.alternative, unit); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject %u (entry: %u) activated", - (*itr)->GetGUIDLow(), (*itr)->GetEntry()); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject %s activated", + (*itr)->GetGUID().ToString().c_str()); #endif } } @@ -872,8 +869,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToGameObject()->ResetDoorOrButton(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RESET_GOBJECT. Gameobject %u (entry: %u) reset", - (*itr)->GetGUIDLow(), (*itr)->GetEntry()); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RESET_GOBJECT. Gameobject %s reset", + (*itr)->GetGUID().ToString().c_str()); #endif } } @@ -893,8 +890,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToUnit()->SetUInt32Value(UNIT_NPC_EMOTESTATE, e.action.emote.emote); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit %u set emotestate to %u", - (*itr)->GetGUIDLow(), e.action.emote.emote); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit %s set emotestate to %u", + (*itr)->GetGUID().ToString().c_str(), e.action.emote.emote); #endif } } @@ -915,14 +912,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!e.action.unitFlag.type) { (*itr)->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag); - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit %u added flag %u to UNIT_FIELD_FLAGS", - (*itr)->GetGUIDLow(), e.action.unitFlag.flag); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit %s added flag %u to UNIT_FIELD_FLAGS", + (*itr)->GetGUID().ToString().c_str(), e.action.unitFlag.flag); } else { (*itr)->ToUnit()->SetFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag); - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit %u added flag %u to UNIT_FIELD_FLAGS_2", - (*itr)->GetGUIDLow(), e.action.unitFlag.flag); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit %s added flag %u to UNIT_FIELD_FLAGS_2", + (*itr)->GetGUID().ToString().c_str(), e.action.unitFlag.flag); } } } @@ -943,14 +940,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!e.action.unitFlag.type) { (*itr)->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag); - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit %u removed flag %u to UNIT_FIELD_FLAGS", - (*itr)->GetGUIDLow(), e.action.unitFlag.flag); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit %s removed flag %u to UNIT_FIELD_FLAGS", + (*itr)->GetGUID().ToString().c_str(), e.action.unitFlag.flag); } else { (*itr)->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag); - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit %u removed flag %u to UNIT_FIELD_FLAGS_2", - (*itr)->GetGUIDLow(), e.action.unitFlag.flag); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit %s removed flag %u to UNIT_FIELD_FLAGS_2", + (*itr)->GetGUID().ToString().c_str(), e.action.unitFlag.flag); } } } @@ -965,8 +962,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u CAST_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: %u bool on = %u", - me->GetGUIDLow(), e.action.autoAttack.attack); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: %s bool on = %u", + me->GetGUID().ToString().c_str(), e.action.autoAttack.attack); #endif break; } @@ -985,8 +982,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u else CAST_AI(SmartAI, me->AI())->SetCombatMove(move); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ALLOW_COMBAT_MOVEMENT: Creature %u bool on = %u", - me->GetGUIDLow(), e.action.combatMove.move); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ALLOW_COMBAT_MOVEMENT: Creature %s bool on = %u", + me->GetGUID().ToString().c_str(), e.action.combatMove.move); #endif break; } @@ -997,8 +994,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u SetPhase(e.action.setEventPhase.phase); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature %u set event phase %u", - GetBaseObject()->GetGUIDLow(), e.action.setEventPhase.phase); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature %s set event phase %u", + GetBaseObject()->GetGUID().ToString().c_str(), e.action.setEventPhase.phase); #endif break; } @@ -1010,8 +1007,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u IncPhase(e.action.incEventPhase.inc); DecPhase(e.action.incEventPhase.dec); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_INC_EVENT_PHASE: Creature %u inc event phase by %u, " - "decrease by %u", GetBaseObject()->GetGUIDLow(), e.action.incEventPhase.inc, e.action.incEventPhase.dec); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_INC_EVENT_PHASE: Creature %s inc event phase by %u, " + "decrease by %u", GetBaseObject()->GetGUID().ToString().c_str(), e.action.incEventPhase.inc, e.action.incEventPhase.dec); #endif break; } @@ -1045,7 +1042,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE); } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature %u DoFleeToGetAssistance", me->GetGUIDLow()); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature %s DoFleeToGetAssistance", me->GetGUID().ToString().c_str()); #endif break; } @@ -1073,8 +1070,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (Player* player = (*itr)->ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself()) player->GroupEventHappens(e.action.quest.quest, GetBaseObject()); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player %u, group credit for quest %u", - (*itr)->GetGUIDLow(), e.action.quest.quest); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player %s, group credit for quest %u", + (*itr)->GetGUID().ToString().c_str(), e.action.quest.quest); #endif } } @@ -1107,8 +1104,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u (*itr)->ToUnit()->RemoveAllAuras(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit %u, spell %u", - (*itr)->GetGUIDLow(), e.action.removeAura.spell); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit %s, spell %u", + (*itr)->GetGUID().ToString().c_str(), e.action.removeAura.spell); #endif } @@ -1134,8 +1131,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u float angle = e.action.follow.angle > 6 ? (e.action.follow.angle * M_PI / 180.0f) : e.action.follow.angle; CAST_AI(SmartAI, me->AI())->SetFollow((*itr)->ToUnit(), float(int32(e.action.follow.dist)) + 0.1f, angle, e.action.follow.credit, e.action.follow.entry, e.action.follow.creditType, e.action.follow.aliveState); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_FOLLOW: Creature %u following target %u", - me->GetGUIDLow(), (*itr)->GetGUIDLow()); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_FOLLOW: Creature %s following target %s", + me->GetGUID().ToString().c_str(), (*itr)->GetGUID().ToString().c_str()); #endif break; } @@ -1173,8 +1170,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u uint32 phase = temp[urand(0, count - 1)]; SetPhase(phase); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE: Creature %u sets event phase to %u", - GetBaseObject()->GetGUIDLow(), phase); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE: Creature %s sets event phase to %u", + GetBaseObject()->GetGUID().ToString().c_str(), phase); #endif break; } @@ -1186,8 +1183,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u uint32 phase = urand(e.action.randomPhaseRange.phaseMin, e.action.randomPhaseRange.phaseMax); SetPhase(phase); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE_RANGE: Creature %u sets event phase to %u", - GetBaseObject()->GetGUIDLow(), phase); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE_RANGE: Creature %s sets event phase to %u", + GetBaseObject()->GetGUID().ToString().c_str(), phase); #endif break; } @@ -1197,8 +1194,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { unit->ToPlayer()->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, unit); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: (trigger == true) Player %u, Killcredit: %u", - unit->GetGUIDLow(), e.action.killedMonster.creature); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: (trigger == true) Player %s, Killcredit: %u", + unit->GetGUID().ToString().c_str(), e.action.killedMonster.creature); #endif } else if (e.target.type == SMART_TARGET_NONE || e.target.type == SMART_TARGET_SELF) // Loot recipient and his group members @@ -1209,8 +1206,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (Player* player = me->GetLootRecipient()) { player->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, player); - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player %u, Killcredit: %u", - player->GetGUIDLow(), e.action.killedMonster.creature); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player %s, Killcredit: %u", + player->GetGUID().ToString().c_str(), e.action.killedMonster.creature); } } else // Specific target type @@ -1230,8 +1227,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u player->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, player); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player %u, Killcredit: %u", - (*itr)->GetGUIDLow(), e.action.killedMonster.creature); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player %s, Killcredit: %u", + (*itr)->GetGUID().ToString().c_str(), e.action.killedMonster.creature); #endif } @@ -1282,10 +1279,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!targets) break; - instance->SetData64(e.action.setInstanceData64.field, targets->front()->GetGUID()); + instance->SetGuidData(e.action.setInstanceData64.field, targets->front()->GetGUID()); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: %u, data: %lu", - e.action.setInstanceData64.field, targets->front()->GetGUID()); + e.action.setInstanceData64.field, targets->front()->GetGUID().GetRawValue()); #endif delete targets; break; @@ -1309,7 +1306,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { Unit::Kill(me, me); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature %u", me->GetGUIDLow()); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature %s", me->GetGUID().ToString().c_str()); #endif } break; @@ -1368,8 +1365,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { me->SetSheath(SheathState(e.action.setSheath.sheath)); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_SHEATH: Creature %u, State: %u", - me->GetGUIDLow(), e.action.setSheath.sheath); + LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_SHEATH: Creature %s, State: %u", + me->GetGUID().ToString().c_str(), e.action.setSheath.sheath); #endif } break; @@ -2118,9 +2115,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (IsCreature(*itr)) { if (!meOrigGUID) - meOrigGUID = me ? me->GetGUID() : 0; + meOrigGUID = me ? me->GetGUID() : ObjectGuid::Empty; if (!goOrigGUID) - goOrigGUID = go ? go->GetGUID() : 0; + goOrigGUID = go ? go->GetGUID() : ObjectGuid::Empty; go = nullptr; me = (*itr)->ToCreature(); break; @@ -2128,9 +2125,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u else if (IsGameObject(*itr)) { if (!meOrigGUID) - meOrigGUID = me ? me->GetGUID() : 0; + meOrigGUID = me ? me->GetGUID() : ObjectGuid::Empty; if (!goOrigGUID) - goOrigGUID = go ? go->GetGUID() : 0; + goOrigGUID = go ? go->GetGUID() : ObjectGuid::Empty; go = (*itr)->ToGameObject(); me = nullptr; break; @@ -2270,8 +2267,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u (*itr)->ToUnit()->CastSpell((*it)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED)); } else - LOG_DEBUG("sql.sql", "Spell %u not casted because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", - e.action.cast.spell, (*it)->GetGUID(), (*it)->GetEntry(), uint32((*it)->GetTypeId())); + LOG_DEBUG("sql.sql", "Spell %u not casted because it has flag SMARTCAST_AURA_NOT_PRESENT and the target %s already has the aura", + e.action.cast.spell, (*it)->GetGUID().ToString().c_str()); } } @@ -3632,7 +3629,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* // xinef: my addition if (e.target.unitGUID.getFromHashMap) { - if ((target = ObjectAccessor::GetCreature(scriptTrigger ? *scriptTrigger : *GetBaseObject(), MAKE_NEW_GUID(e.target.unitGUID.dbGuid, e.target.unitGUID.entry, HIGHGUID_UNIT)))) + if ((target = ObjectAccessor::GetCreature(scriptTrigger ? *scriptTrigger : *GetBaseObject(), ObjectGuid::Create<HighGuid::Unit>(e.target.unitGUID.entry, e.target.unitGUID.dbGuid)))) l->push_back(target); } else @@ -3655,7 +3652,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* // xinef: my addition if (e.target.goGUID.getFromHashMap) { - if ((target = ObjectAccessor::GetGameObject(scriptTrigger ? *scriptTrigger : *GetBaseObject(), MAKE_NEW_GUID(e.target.goGUID.dbGuid, e.target.goGUID.entry, HIGHGUID_GAMEOBJECT)))) + if ((target = ObjectAccessor::GetGameObject(scriptTrigger ? *scriptTrigger : *GetBaseObject(), ObjectGuid::Create<HighGuid::GameObject>(e.target.goGUID.entry, e.target.goGUID.dbGuid)))) l->push_back(target); } else @@ -4708,14 +4705,14 @@ void SmartScript::GetScript() SmartAIEventList e; if (me) { - e = sSmartScriptMgr->GetScript(-((int32)me->GetDBTableGUIDLow()), mScriptType); + e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType); if (e.empty()) e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType); FillScript(e, me, nullptr); } else if (go) { - e = sSmartScriptMgr->GetScript(-((int32)go->GetDBTableGUIDLow()), mScriptType); + e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType); if (e.empty()) e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType); FillScript(e, go, nullptr); @@ -4824,20 +4821,20 @@ void SmartScript::DoAction(int32 param) uint32 SmartScript::GetData(uint32 id) { -return 0; + return 0; } void SmartScript::SetData(uint32 id, uint32 value) { } -void SmartScript::SetGUID(uint64 guid, int32 id) +void SmartScript::SetGUID(ObjectGuid guid, int32 id) { } -uint64 SmartScript::GetGUID(int32 id) +ObjectGuid SmartScript::GetGUID(int32 id) { -return 0; + return ObjectGuid::Empty; } void SmartScript::MovepointStart(uint32 id) @@ -4852,9 +4849,9 @@ void SmartScript::SetMovePathEndAction(SMART_ACTION action) { } -uint32 SmartScript::DoChat(int8 id, uint64 whisperGuid) +uint32 SmartScript::DoChat(int8 id, ObjectGuid whisperGuid) { -return 0; + return 0; }*/ // SmartScript end diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index 5717755911..56d1da657b 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -156,35 +156,27 @@ public: return 0; } - GameObject* FindGameObjectNear(WorldObject* searchObject, uint32 guid) const + GameObject* FindGameObjectNear(WorldObject* searchObject, ObjectGuid::LowType guid) const { - GameObject* gameObject = nullptr; + auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid); + if (bounds.first == bounds.second) + return nullptr; - CellCoord p(acore::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY())); - Cell cell(p); - - acore::GameObjectWithDbGUIDCheck goCheck(guid); - acore::GameObjectSearcher<acore::GameObjectWithDbGUIDCheck> checker(searchObject, gameObject, goCheck); - - TypeContainerVisitor<acore::GameObjectSearcher<acore::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker); - cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetVisibilityRange()); - - return gameObject; + return bounds.first->second; } - Creature* FindCreatureNear(WorldObject* searchObject, uint32 guid) const + Creature* FindCreatureNear(WorldObject* searchObject, ObjectGuid::LowType guid) const { - Creature* creature = nullptr; - CellCoord p(acore::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY())); - Cell cell(p); - - acore::CreatureWithDbGUIDCheck target_check(guid); - acore::CreatureSearcher<acore::CreatureWithDbGUIDCheck> checker(searchObject, creature, target_check); + auto bounds = searchObject->GetMap()->GetCreatureBySpawnIdStore().equal_range(guid); + if (bounds.first == bounds.second) + return nullptr; - TypeContainerVisitor<acore::CreatureSearcher <acore::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker); - cell.Visit(p, unit_checker, *searchObject->GetMap(), *searchObject, searchObject->GetVisibilityRange()); + auto creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair) + { + return pair.second->IsAlive(); + }); - return creature; + return creatureItr != bounds.second ? creatureItr->second : bounds.first->second; } ObjectListMap* mTargetStorage; @@ -192,30 +184,39 @@ public: void OnReset(); void ResetBaseObject() { - if (meOrigGUID) + WorldObject* lookupRoot = me; + if (!lookupRoot) + lookupRoot = go; + + if (lookupRoot) { - if (Creature* m = HashMapHolder<Creature>::Find(meOrigGUID)) + if (meOrigGUID) { - me = m; - go = nullptr; + if (Creature* m = ObjectAccessor::GetCreature(*lookupRoot, meOrigGUID)) + { + me = m; + go = nullptr; + } } - } - if (goOrigGUID) - { - if (GameObject* o = HashMapHolder<GameObject>::Find(goOrigGUID)) + + if (goOrigGUID) { - me = nullptr; - go = o; + if (GameObject* o = ObjectAccessor::GetGameObject(*lookupRoot, goOrigGUID)) + { + me = nullptr; + go = o; + } } } - goOrigGUID = 0; - meOrigGUID = 0; + + goOrigGUID.Clear(); + meOrigGUID.Clear(); } //TIMED_ACTIONLIST (script type 9 aka script9) void SetScript9(SmartScriptHolder& e, uint32 entry); Unit* GetLastInvoker(Unit* invoker = nullptr); - uint64 mLastInvoker; + ObjectGuid mLastInvoker; typedef std::unordered_map<uint32, uint32> CounterMap; CounterMap mCounterList; @@ -262,9 +263,9 @@ private: SmartAIEventList mTimedActionList; bool isProcessingTimedActionList; Creature* me; - uint64 meOrigGUID; + ObjectGuid meOrigGUID; GameObject* go; - uint64 goOrigGUID; + ObjectGuid goOrigGUID; AreaTrigger const* trigger; SmartScriptType mScriptType; uint32 mEventPhase; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 955cd1c34d..680838fa91 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1705,7 +1705,6 @@ public: typedef std::unordered_map<uint32, WayPoint*> WPPath; typedef std::list<WorldObject*> ObjectList; -typedef std::list<uint64> GuidList; class ObjectGuidList { @@ -1739,7 +1738,7 @@ public: if (WorldObject* obj = ObjectAccessor::GetWorldObject(*m_baseObject, *itr)) m_objectList->push_back(obj); //else - // TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: " UI64FMTD, *itr); + // TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: %s", (*itr).ToString().c_str()); } } diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp index f894d7b348..9801aecbac 100644 --- a/src/server/game/Accounts/AccountMgr.cpp +++ b/src/server/game/Accounts/AccountMgr.cpp @@ -69,8 +69,7 @@ namespace AccountMgr { do { - uint32 guidLow = (*result)[0].GetUInt32(); - uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER); + ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].GetUInt32()); // Kick if player is online if (Player* p = ObjectAccessor::FindPlayer(guid)) @@ -80,7 +79,7 @@ namespace AccountMgr s->LogoutPlayer(false); // logout player without waiting next session list update } - Player::DeleteFromDB(guid, accountId, false, true); // no need to update realm characters + Player::DeleteFromDB(guid.GetCounter(), accountId, false, true); // no need to update realm characters } while (result->NextRow()); } diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 2dcd51aa40..60fddefdec 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -486,7 +486,7 @@ void AchievementMgr::Reset() m_completedAchievements.clear(); m_criteriaProgress.clear(); - DeleteFromDB(m_player->GetGUIDLow()); + DeleteFromDB(m_player->GetGUID().GetCounter()); // re-fill data CheckAllAchievementCriteria(); @@ -519,7 +519,7 @@ void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaCondition condi } } -void AchievementMgr::DeleteFromDB(uint32 lowguid) +void AchievementMgr::DeleteFromDB(ObjectGuid::LowType lowguid) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -545,11 +545,11 @@ void AchievementMgr::SaveToDB(SQLTransaction& trans) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT); stmt->setUInt16(0, iter->first); - stmt->setUInt32(1, GetPlayer()->GetGUID()); + stmt->setUInt32(1, GetPlayer()->GetGUID().GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT); - stmt->setUInt32(0, GetPlayer()->GetGUID()); + stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter()); stmt->setUInt16(1, iter->first); stmt->setUInt32(2, uint32(iter->second.date)); trans->Append(stmt); @@ -568,7 +568,7 @@ void AchievementMgr::SaveToDB(SQLTransaction& trans) continue; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA); - stmt->setUInt32(0, GetPlayer()->GetGUID()); + stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter()); stmt->setUInt16(1, iter->first); trans->Append(stmt); @@ -576,7 +576,7 @@ void AchievementMgr::SaveToDB(SQLTransaction& trans) if (iter->second.counter) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS); - stmt->setUInt32(0, GetPlayer()->GetGUID()); + stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter()); stmt->setUInt16(1, iter->first); stmt->setUInt32(2, iter->second.counter); stmt->setUInt32(3, uint32(iter->second.date)); @@ -681,7 +681,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) { WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, guild->GetName().size() + 1 + 8 + 4 + 4); data << guild->GetName(); - data << uint64(GetPlayer()->GetGUID()); + data << GetPlayer()->GetGUID(); data << uint32(achievement->ID); data << uint32(0); // display name as plain string in chat (always 0 for guild) sWorld->SendGlobalMessage(&data); @@ -693,7 +693,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) // broadcast realm first reached WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, GetPlayer()->GetName().size() + 1 + 8 + 4 + 4); data << GetPlayer()->GetName(); - data << uint64(GetPlayer()->GetGUID()); + data << GetPlayer()->GetGUID(); data << uint32(achievement->ID); std::size_t linkTypePos = data.wpos(); data << uint32(1); // display name as clickable link in chat @@ -719,7 +719,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) } WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8 + 4 + 8); - data.append(GetPlayer()->GetPackGUID()); + data << GetPlayer()->GetPackGUID(); data << uint32(achievement->ID); data.AppendPackedTime(time(nullptr)); data << uint32(0); @@ -734,7 +734,7 @@ void AchievementMgr::SendCriteriaUpdate(AchievementCriteriaEntry const* entry, C // the counter is packed like a packed Guid data.appendPackGUID(progress->counter); - data.append(GetPlayer()->GetPackGUID()); + data << GetPlayer()->GetPackGUID(); if (!entry->timeLimit) data << uint32(0); else @@ -2026,7 +2026,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry, return; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("achievement", "AchievementMgr::SetCriteriaProgress(%u, %u) for (GUID:%u)", entry->ID, changeValue, m_player->GetGUIDLow()); + LOG_DEBUG("achievement", "AchievementMgr::SetCriteriaProgress(%u, %u) for %s", entry->ID, changeValue, m_player->GetGUID().ToString().c_str()); #endif CriteriaProgress* progress = GetCriteriaProgress(entry); @@ -2289,7 +2289,7 @@ void AchievementMgr::SendAllAchievementData() const void AchievementMgr::SendRespondInspectAchievements(Player* player) const { WorldPacket data(SMSG_RESPOND_INSPECT_ACHIEVEMENTS, 9 + m_completedAchievements.size() * 8 + 4 + 4); - data.append(GetPlayer()->GetPackGUID()); + data << GetPlayer()->GetPackGUID(); BuildAllDataPacket(&data, true); player->GetSession()->SendPacket(&data); } @@ -2320,7 +2320,7 @@ void AchievementMgr::BuildAllDataPacket(WorldPacket* data, bool inspect) const { *data << uint32(iter->first); data->appendPackGUID(iter->second.counter); - data->append(GetPlayer()->GetPackGUID()); + *data << GetPlayer()->GetPackGUID(); *data << uint32(0); data->AppendPackedTime(iter->second.date); *data << uint32(0); diff --git a/src/server/game/Achievements/AchievementMgr.h b/src/server/game/Achievements/AchievementMgr.h index 5a43d788a8..1db2dcbade 100644 --- a/src/server/game/Achievements/AchievementMgr.h +++ b/src/server/game/Achievements/AchievementMgr.h @@ -14,6 +14,7 @@ #include "DatabaseEnv.h" #include "DBCEnums.h" #include "DBCStores.h" +#include "ObjectGuid.h" typedef std::list<AchievementCriteriaEntry const*> AchievementCriteriaEntryList; typedef std::list<AchievementEntry const*> AchievementEntryList; @@ -258,7 +259,7 @@ public: ~AchievementMgr(); void Reset(); - static void DeleteFromDB(uint32 lowguid); + static void DeleteFromDB(ObjectGuid::LowType lowguid); void LoadFromDB(PreparedQueryResult achievementResult, PreparedQueryResult criteriaResult); void SaveToDB(SQLTransaction& trans); void ResetAchievementCriteria(AchievementCriteriaCondition condition, uint32 value, bool evenIfCriteriaComplete = false); diff --git a/src/server/game/ArenaSpectator/ArenaSpectator.h b/src/server/game/ArenaSpectator/ArenaSpectator.h index 2013af566d..e1bfb38a1f 100644 --- a/src/server/game/ArenaSpectator/ArenaSpectator.h +++ b/src/server/game/ArenaSpectator/ArenaSpectator.h @@ -27,14 +27,14 @@ namespace ArenaSpectator inline void SendPacketTo(const Player* p, const char* m); inline void SendPacketTo(const Map* map, const char* m); inline void HandleResetCommand(Player* p); - inline bool ShouldSendAura(Aura* aura, uint8 effMask, uint64 targetGUID, bool remove); + inline bool ShouldSendAura(Aura* aura, uint8 effMask, ObjectGuid targetGUID, bool remove); - template<class T> inline void SendCommand_String(T* p, uint64 targetGUID, const char* prefix, const std::string& c); - template<class T> inline void SendCommand_UInt32Value(T* o, uint64 targetGUID, const char* prefix, uint32 t); - template<class T> inline void SendCommand_GUID(T* o, uint64 targetGUID, const char* prefix, uint64 t); - template<class T> inline void SendCommand_Spell(T* o, uint64 targetGUID, const char* prefix, uint32 id, int32 casttime); - template<class T> inline void SendCommand_Cooldown(T* o, uint64 targetGUID, const char* prefix, uint32 id, uint32 dur, uint32 maxdur); - template<class T> inline void SendCommand_Aura(T* o, uint64 targetGUID, const char* prefix, uint64 caster, uint32 id, bool isDebuff, uint32 dispel, int32 dur, int32 maxdur, uint32 stack, bool remove); + template<class T> inline void SendCommand_String(T* p, ObjectGuid targetGUID, const char* prefix, const std::string& c); + template<class T> inline void SendCommand_UInt32Value(T* o, ObjectGuid targetGUID, const char* prefix, uint32 t); + template<class T> inline void SendCommand_GUID(T* o, ObjectGuid targetGUID, const char* prefix, ObjectGuid t); + template<class T> inline void SendCommand_Spell(T* o, ObjectGuid targetGUID, const char* prefix, uint32 id, int32 casttime); + template<class T> inline void SendCommand_Cooldown(T* o, ObjectGuid targetGUID, const char* prefix, uint32 id, uint32 dur, uint32 maxdur); + template<class T> inline void SendCommand_Aura(T* o, ObjectGuid targetGUID, const char* prefix, ObjectGuid caster, uint32 id, bool isDebuff, uint32 dispel, int32 dur, int32 maxdur, uint32 stack, bool remove); bool HandleSpectatorSpectateCommand(ChatHandler* handler, char const* args); bool HandleSpectatorWatchCommand(ChatHandler* handler, char const* args); @@ -88,54 +88,54 @@ namespace ArenaSpectator } template<class T> - void SendCommand_String(T* o, uint64 targetGUID, const char* prefix, const char* c) + void SendCommand_String(T* o, ObjectGuid targetGUID, const char* prefix, const char* c) { - if (!IS_PLAYER_GUID(targetGUID)) + if (!targetGUID.IsPlayer()) return; - SendCommand(o, "%s0x%016llX;%s=%s;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID, prefix, c); + SendCommand(o, "%s0x%016llX;%s=%s;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID.GetRawValue(), prefix, c); } template<class T> - void SendCommand_UInt32Value(T* o, uint64 targetGUID, const char* prefix, uint32 t) + void SendCommand_UInt32Value(T* o, ObjectGuid targetGUID, const char* prefix, uint32 t) { - if (!IS_PLAYER_GUID(targetGUID)) + if (!targetGUID.IsPlayer()) return; - SendCommand(o, "%s0x%016llX;%s=%u;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID, prefix, t); + SendCommand(o, "%s0x%016llX;%s=%u;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID.GetRawValue(), prefix, t); } template<class T> - void SendCommand_GUID(T* o, uint64 targetGUID, const char* prefix, uint64 t) + void SendCommand_GUID(T* o, ObjectGuid targetGUID, const char* prefix, ObjectGuid t) { - if (!IS_PLAYER_GUID(targetGUID)) + if (!targetGUID.IsPlayer()) return; - SendCommand(o, "%s0x%016llX;%s=0x%016llX;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID, prefix, (unsigned long long)t); + SendCommand(o, "%s0x%016llX;%s=0x%016llX;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID.GetRawValue(), prefix, (unsigned long long)t.GetRawValue()); } template<class T> - void SendCommand_Spell(T* o, uint64 targetGUID, const char* prefix, uint32 id, int32 casttime) + void SendCommand_Spell(T* o, ObjectGuid targetGUID, const char* prefix, uint32 id, int32 casttime) { - if (!IS_PLAYER_GUID(targetGUID)) + if (!targetGUID.IsPlayer()) return; - SendCommand(o, "%s0x%016llX;%s=%u,%i;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID, prefix, id, casttime); + SendCommand(o, "%s0x%016llX;%s=%u,%i;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID.GetRawValue(), prefix, id, casttime); } template<class T> - void SendCommand_Cooldown(T* o, uint64 targetGUID, const char* prefix, uint32 id, uint32 dur, uint32 maxdur) + void SendCommand_Cooldown(T* o, ObjectGuid targetGUID, const char* prefix, uint32 id, uint32 dur, uint32 maxdur) { - if (!IS_PLAYER_GUID(targetGUID)) + if (!targetGUID.IsPlayer()) return; if (const SpellInfo* si = sSpellMgr->GetSpellInfo(id)) if (si->SpellIconID == 1) return; - SendCommand(o, "%s0x%016llX;%s=%u,%u,%u;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID, prefix, id, dur, maxdur); + SendCommand(o, "%s0x%016llX;%s=%u,%u,%u;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID.GetRawValue(), prefix, id, dur, maxdur); } template<class T> - void SendCommand_Aura(T* o, uint64 targetGUID, const char* prefix, uint64 caster, uint32 id, bool isDebuff, uint32 dispel, int32 dur, int32 maxdur, uint32 stack, bool remove) + void SendCommand_Aura(T* o, ObjectGuid targetGUID, const char* prefix, ObjectGuid caster, uint32 id, bool isDebuff, uint32 dispel, int32 dur, int32 maxdur, uint32 stack, bool remove) { - if (!IS_PLAYER_GUID(targetGUID)) + if (!targetGUID.IsPlayer()) return; - SendCommand(o, "%s0x%016llX;%s=%u,%u,%i,%i,%u,%u,%u,0x%016llX;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID, prefix, remove ? 1 : 0, stack, dur, maxdur, id, dispel, isDebuff ? 1 : 0, (unsigned long long)caster); + SendCommand(o, "%s0x%016llX;%s=%u,%u,%i,%i,%u,%u,%u,0x%016llX;", SPECTATOR_ADDON_PREFIX, (unsigned long long)targetGUID.GetRawValue(), prefix, remove ? 1 : 0, stack, dur, maxdur, id, dispel, isDebuff ? 1 : 0, (unsigned long long)caster.GetRawValue()); } void HandleResetCommand(Player* p) @@ -148,11 +148,11 @@ namespace ArenaSpectator Battleground::BattlegroundPlayerMap const& pl = bg->GetPlayers(); for (Battleground::BattlegroundPlayerMap::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) { - if (p->HasReceivedSpectatorResetFor(GUID_LOPART(itr->first))) + if (p->HasReceivedSpectatorResetFor(itr->first)) continue; Player* plr = itr->second; - p->AddReceivedSpectatorResetFor(GUID_LOPART(itr->first)); + p->AddReceivedSpectatorResetFor(itr->first); SendCommand_String(p, itr->first, "NME", plr->GetName().c_str()); // Xinef: addon compatibility @@ -192,7 +192,7 @@ namespace ArenaSpectator } } - bool ShouldSendAura(Aura* aura, uint8 effMask, uint64 targetGUID, bool remove) + bool ShouldSendAura(Aura* aura, uint8 effMask, ObjectGuid targetGUID, bool remove) { if (aura->GetSpellInfo()->SpellIconID == 1 || aura->GetSpellInfo()->HasAttribute(SPELL_ATTR1_DONT_DISPLAY_IN_AURA_BAR)) return false; diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index ae73d804ae..3fa26943df 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -56,8 +56,26 @@ AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(uint32 factionTemplateId) return &mAllianceAuctions; else if (u_entry->ourMask & FACTION_MASK_HORDE) return &mHordeAuctions; - else + + return &mNeutralAuctions; +} + +AuctionHouseObject* AuctionHouseMgr::GetAuctionsMapByHouseId(uint8 auctionHouseId) +{ + if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) return &mNeutralAuctions; + + switch(auctionHouseId) + { + case AUCTIONHOUSE_ALLIANCE: + return &mAllianceAuctions; + case AUCTIONHOUSE_HORDE: + return &mHordeAuctions; + break; + } + + return &mNeutralAuctions; + } uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item* pItem, uint32 count) @@ -87,17 +105,16 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 //does not clear ram void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction& trans, bool sendNotification, bool updateAchievementCriteria, bool sendMail) { - Item* pItem = GetAItem(auction->item_guidlow); + Item* pItem = GetAItem(auction->item_guid); if (!pItem) return; - uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); uint32 bidder_accId = 0; - Player* bidder = ObjectAccessor::FindPlayerInOrOutOfWorld(bidder_guid); + Player* bidder = ObjectAccessor::FindConnectedPlayer(auction->bidder); if (bidder) bidder_accId = bidder->GetSession()->GetAccountId(); else - bidder_accId = sObjectMgr->GetPlayerAccountIdByGUID(bidder_guid); + bidder_accId = sObjectMgr->GetPlayerAccountIdByGUID(auction->bidder.GetCounter()); // receiver exist if (bidder || bidder_accId) @@ -106,14 +123,14 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction& // set owner to bidder (to prevent delete item with sender char deleting) // owner in `data` will set at mail receive and item extracting PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER); - stmt->setUInt32(0, auction->bidder); - stmt->setUInt32(1, pItem->GetGUIDLow()); + stmt->setUInt32(0, auction->bidder.GetCounter()); + stmt->setUInt32(1, pItem->GetGUID().GetCounter()); trans->Append(stmt); if (bidder) { if (sendNotification) // can be changed in the hook - bidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, bidder_guid, 0, 0, auction->item_template); + bidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, auction->bidder, 0, 0, auction->item_template); // FIXME: for offline player need also if (updateAchievementCriteria) // can be changed in the hook bidder->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS, 1); @@ -122,33 +139,31 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction& if (sendMail) // can be changed in the hook MailDraft(auction->BuildAuctionMailSubject(AUCTION_WON), AuctionEntry::BuildAuctionMailBody(auction->owner, auction->bid, auction->buyout, 0, 0)) .AddItem(pItem) - .SendMailTo(trans, MailReceiver(bidder, auction->bidder), auction, MAIL_CHECK_MASK_COPIED); + .SendMailTo(trans, MailReceiver(bidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED); } else - sAuctionMgr->RemoveAItem(auction->item_guidlow, true); + sAuctionMgr->RemoveAItem(auction->item_guid, true); } void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry* auction, SQLTransaction& trans, bool sendMail) { - uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); - Player* owner = ObjectAccessor::FindPlayerInOrOutOfWorld(owner_guid); - uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid); + Player* owner = ObjectAccessor::FindConnectedPlayer(auction->owner); + uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(auction->owner.GetCounter()); // owner exist (online or offline) if (owner || owner_accId) { sScriptMgr->OnBeforeAuctionHouseMgrSendAuctionSalePendingMail(this, auction, owner, owner_accId, sendMail); if (sendMail) // can be changed in the hook MailDraft(auction->BuildAuctionMailSubject(AUCTION_SALE_PENDING), AuctionEntry::BuildAuctionMailBody(auction->bidder, auction->bid, auction->buyout, auction->deposit, auction->GetAuctionCut())) - .SendMailTo(trans, MailReceiver(owner, auction->owner), auction, MAIL_CHECK_MASK_COPIED); + .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED); } } //call this method to send mail to auction owner, when auction is successful, it does not clear ram void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction, SQLTransaction& trans, bool sendNotification, bool updateAchievementCriteria, bool sendMail) { - uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); - Player* owner = ObjectAccessor::FindPlayerInOrOutOfWorld(owner_guid); - uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid); + Player* owner = ObjectAccessor::FindConnectedPlayer(auction->owner); + uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(auction->owner.GetCounter()); // owner exist if (owner || owner_accId) { @@ -170,21 +185,21 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction, SQLTransa if (sendMail) // can be changed in the hook MailDraft(auction->BuildAuctionMailSubject(AUCTION_SUCCESSFUL), AuctionEntry::BuildAuctionMailBody(auction->bidder, auction->bid, auction->buyout, auction->deposit, auction->GetAuctionCut())) .AddMoney(profit) - .SendMailTo(trans, MailReceiver(owner, auction->owner), auction, MAIL_CHECK_MASK_COPIED, sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY)); + .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED, sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY)); if (auction->bid >= 500 * GOLD) - if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(auction->bidder)) + if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(auction->bidder.GetCounter())) { - uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); - Player* bidder = ObjectAccessor::FindPlayerInOrOutOfWorld(bidder_guid); + Player* bidder = ObjectAccessor::FindConnectedPlayer(auction->bidder); std::string owner_name = ""; uint8 owner_level = 0; - if (const GlobalPlayerData* gpd_owner = sWorld->GetGlobalPlayerData(auction->owner)) + if (const GlobalPlayerData* gpd_owner = sWorld->GetGlobalPlayerData(auction->owner.GetCounter())) { owner_name = gpd_owner->name; owner_level = gpd_owner->level; } - CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<AH> profit: %ug, bidder: %s %u lvl (guid: %u), seller: %s %u lvl (guid: %u), item %u (%u)\", NOW())", gpd->accountId, auction->bidder, gpd->name.c_str(), bidder ? bidder->GetSession()->GetRemoteAddress().c_str() : "", owner_accId, owner_name.c_str(), auction->bid, (profit / GOLD), gpd->name.c_str(), gpd->level, auction->bidder, owner_name.c_str(), owner_level, auction->owner, auction->item_template, auction->itemCount); + CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<AH> profit: %ug, bidder: %s %u lvl (guid: %u), seller: %s %u lvl (guid: %u), item %u (%u)\", NOW())", + gpd->accountId, auction->bidder.GetCounter(), gpd->name.c_str(), bidder ? bidder->GetSession()->GetRemoteAddress().c_str() : "", owner_accId, owner_name.c_str(), auction->bid, (profit / GOLD), gpd->name.c_str(), gpd->level, auction->bidder.GetCounter(), owner_name.c_str(), owner_level, auction->owner.GetCounter(), auction->item_template, auction->itemCount); } } } @@ -193,13 +208,12 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction, SQLTransa void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransaction& trans, bool sendNotification, bool sendMail) { //return an item in auction to its owner by mail - Item* pItem = GetAItem(auction->item_guidlow); + Item* pItem = GetAItem(auction->item_guid); if (!pItem) return; - uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); - Player* owner = ObjectAccessor::FindPlayerInOrOutOfWorld(owner_guid); - uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid); + Player* owner = ObjectAccessor::FindConnectedPlayer(auction->owner); + uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(auction->owner.GetCounter()); // owner exist if (owner || owner_accId) @@ -210,23 +224,22 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransacti owner->GetSession()->SendAuctionOwnerNotification(auction); if (sendMail) // can be changed in the hook - MailDraft(auction->BuildAuctionMailSubject(AUCTION_EXPIRED), AuctionEntry::BuildAuctionMailBody(0, 0, auction->buyout, auction->deposit, 0)) + MailDraft(auction->BuildAuctionMailSubject(AUCTION_EXPIRED), AuctionEntry::BuildAuctionMailBody(ObjectGuid::Empty, 0, auction->buyout, auction->deposit, 0)) .AddItem(pItem) - .SendMailTo(trans, MailReceiver(owner, auction->owner), auction, MAIL_CHECK_MASK_COPIED, 0); + .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED, 0); } else - sAuctionMgr->RemoveAItem(auction->item_guidlow, true); + sAuctionMgr->RemoveAItem(auction->item_guid, true); } //this function sends mail to old bidder void AuctionHouseMgr::SendAuctionOutbiddedMail(AuctionEntry* auction, uint32 newPrice, Player* newBidder, SQLTransaction& trans, bool sendNotification, bool sendMail) { - uint64 oldBidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); - Player* oldBidder = ObjectAccessor::FindPlayerInOrOutOfWorld(oldBidder_guid); + Player* oldBidder = ObjectAccessor::FindConnectedPlayer(auction->bidder); uint32 oldBidder_accId = 0; if (!oldBidder) - oldBidder_accId = sObjectMgr->GetPlayerAccountIdByGUID(oldBidder_guid); + oldBidder_accId = sObjectMgr->GetPlayerAccountIdByGUID(auction->bidder.GetCounter()); // old bidder exist if (oldBidder || oldBidder_accId) @@ -239,19 +252,18 @@ void AuctionHouseMgr::SendAuctionOutbiddedMail(AuctionEntry* auction, uint32 new if (sendMail) // can be changed in the hook MailDraft(auction->BuildAuctionMailSubject(AUCTION_OUTBIDDED), AuctionEntry::BuildAuctionMailBody(auction->owner, auction->bid, auction->buyout, auction->deposit, auction->GetAuctionCut())) .AddMoney(auction->bid) - .SendMailTo(trans, MailReceiver(oldBidder, auction->bidder), auction, MAIL_CHECK_MASK_COPIED); + .SendMailTo(trans, MailReceiver(oldBidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED); } } //this function sends mail, when auction is cancelled to old bidder void AuctionHouseMgr::SendAuctionCancelledToBidderMail(AuctionEntry* auction, SQLTransaction& trans, bool sendMail) { - uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); - Player* bidder = ObjectAccessor::FindPlayerInOrOutOfWorld(bidder_guid); + Player* bidder = ObjectAccessor::FindConnectedPlayer(auction->bidder); uint32 bidder_accId = 0; if (!bidder) - bidder_accId = sObjectMgr->GetPlayerAccountIdByGUID(bidder_guid); + bidder_accId = sObjectMgr->GetPlayerAccountIdByGUID(auction->bidder.GetCounter()); // bidder exist if (bidder || bidder_accId) @@ -260,7 +272,7 @@ void AuctionHouseMgr::SendAuctionCancelledToBidderMail(AuctionEntry* auction, SQ if (sendMail) // can be changed in the hook MailDraft(auction->BuildAuctionMailSubject(AUCTION_CANCELLED_TO_BIDDER), AuctionEntry::BuildAuctionMailBody(auction->owner, auction->bid, auction->buyout, auction->deposit, 0)) .AddMoney(auction->bid) - .SendMailTo(trans, MailReceiver(bidder, auction->bidder), auction, MAIL_CHECK_MASK_COPIED); + .SendMailTo(trans, MailReceiver(bidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED); } } @@ -294,8 +306,8 @@ void AuctionHouseMgr::LoadAuctionItems() { Field* fields = result->Fetch(); - uint32 item_guid = fields[11].GetUInt32(); - uint32 item_template = fields[12].GetUInt32(); + ObjectGuid::LowType item_guid = fields[11].GetUInt32(); + uint32 item_template = fields[12].GetUInt32(); ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item_template); if (!proto) @@ -305,7 +317,7 @@ void AuctionHouseMgr::LoadAuctionItems() } Item* item = NewItemOrBag(proto); - if (!item->LoadFromDB(item_guid, 0, fields, item_template)) + if (!item->LoadFromDB(item_guid, ObjectGuid::Empty, fields, item_template)) { delete item; continue; @@ -348,7 +360,7 @@ void AuctionHouseMgr::LoadAuctions() continue; } - GetAuctionsMap(aItem->factionTemplateId)->AddAuction(aItem); + GetAuctionsMapByHouseId(aItem->houseId)->AddAuction(aItem); count++; } while (result->NextRow()); @@ -361,13 +373,13 @@ void AuctionHouseMgr::LoadAuctions() void AuctionHouseMgr::AddAItem(Item* it) { ASSERT(it); - ASSERT(mAitems.find(it->GetGUIDLow()) == mAitems.end()); - mAitems[it->GetGUIDLow()] = it; + ASSERT(mAitems.find(it->GetGUID()) == mAitems.end()); + mAitems[it->GetGUID()] = it; } -bool AuctionHouseMgr::RemoveAItem(uint32 id, bool deleteFromDB) +bool AuctionHouseMgr::RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB) { - ItemMap::iterator i = mAitems.find(id); + ItemMap::iterator i = mAitems.find(itemGuid); if (i == mAitems.end()) return false; @@ -393,64 +405,32 @@ void AuctionHouseMgr::Update() AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTemplateId) { - uint32 houseid = 7; // goblin auction house + uint32 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) { //FIXME: found way for proper auctionhouse selection by another way // AuctionHouse.dbc have faction field with _player_ factions associated with auction house races. // but no easy way convert creature faction to player race faction for specific city - switch (factionTemplateId) - { - case 12: - houseid = 1; - break; // human - case 29: - houseid = 6; - break; // orc, and generic for horde - case 55: - houseid = 2; - break; // dwarf, and generic for alliance - case 68: - houseid = 4; - break; // undead - case 80: - houseid = 3; - break; // n-elf - case 104: - houseid = 5; - break; // trolls - case 120: - houseid = 7; - break; // booty bay, neutral - case 474: - houseid = 7; - break; // gadgetzan, neutral - case 855: - houseid = 7; - break; // everlook, neutral - case 1604: - houseid = 6; - break; // b-elfs, - default: // for unknown case - { - FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId); - if (!u_entry) - houseid = 7; // goblin auction house - else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) - houseid = 1; // human auction house - else if (u_entry->ourMask & FACTION_MASK_HORDE) - houseid = 6; // orc auction house - else - houseid = 7; // goblin auction house - break; - } - } + FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId); + if (!u_entry) + houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house + else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) + houseid = AUCTIONHOUSE_ALLIANCE; // human auction house + else if (u_entry->ourMask & FACTION_MASK_HORDE) + houseid = AUCTIONHOUSE_HORDE; // orc auction house + else + houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house } return sAuctionHouseStore.LookupEntry(houseid); } +AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntryFromHouse(uint8 houseId) +{ + return (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) ? sAuctionHouseStore.LookupEntry(AUCTIONHOUSE_NEUTRAL) : sAuctionHouseStore.LookupEntry(houseId); +} + void AuctionHouseObject::AddAuction(AuctionEntry* auction) { ASSERT(auction); @@ -492,7 +472,7 @@ void AuctionHouseObject::Update() continue; ///- Either cancel the auction if there was no bidder - if (auction->bidder == 0) + if (!auction->bidder) { sAuctionMgr->SendAuctionExpiredMail(auction, trans); sScriptMgr->OnAuctionExpire(this, auction); @@ -511,7 +491,7 @@ void AuctionHouseObject::Update() ///- In any case clear the auction auction->DeleteFromDB(trans); - sAuctionMgr->RemoveAItem(auction->item_guidlow); + sAuctionMgr->RemoveAItem(auction->item_guid); RemoveAuction(auction); } CharacterDatabase.CommitTransaction(trans); @@ -522,7 +502,7 @@ void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr) { AuctionEntry* Aentry = itr->second; - if (Aentry && Aentry->bidder == player->GetGUIDLow()) + if (Aentry && Aentry->bidder == player->GetGUID()) { if (itr->second->BuildAuctionInfo(data)) ++count; @@ -537,7 +517,7 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr) { AuctionEntry* Aentry = itr->second; - if (Aentry && Aentry->owner == player->GetGUIDLow()) + if (Aentry && Aentry->owner == player->GetGUID()) { if (Aentry->BuildAuctionInfo(data)) ++count; @@ -589,7 +569,7 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player if (Aentry->expire_time < curTime) continue; - Item* item = sAuctionMgr->GetAItem(Aentry->item_guidlow); + Item* item = sAuctionMgr->GetAItem(Aentry->item_guid); if (!item) continue; @@ -693,10 +673,10 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player //this function inserts to WorldPacket auction's data bool AuctionEntry::BuildAuctionInfo(WorldPacket& data) const { - Item* item = sAuctionMgr->GetAItem(item_guidlow); + Item* item = sAuctionMgr->GetAItem(item_guid); if (!item) { - LOG_ERROR("server", "AuctionEntry::BuildAuctionInfo: Auction %u has a non-existent item: %u", Id, item_guidlow); + LOG_ERROR("server", "AuctionEntry::BuildAuctionInfo: Auction %u has a non-existent item: %s", Id, item_guid.ToString().c_str()); return false; } data << uint32(Id); @@ -714,13 +694,13 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket& data) const data << uint32(item->GetCount()); // item->count data << uint32(item->GetSpellCharges()); // item->charge FFFFFFF data << uint32(0); // Unknown - data << uint64(owner); // Auction->owner + data << owner; // Auction->owner data << uint32(startbid); // Auction->startbid (not sure if useful) data << uint32(bid ? GetAuctionOutBid() : 0); // Minimal outbid data << uint32(buyout); // Auction->buyout - data << uint32((expire_time - time(nullptr)) * IN_MILLISECONDS); // time left - data << uint64(bidder); // auction->bidder current + data << uint32((expire_time - time(nullptr)) * IN_MILLISECONDS); // time left + data << bidder; // auction->bidder current data << uint32(bid); // current bid return true; } @@ -749,12 +729,12 @@ void AuctionEntry::SaveToDB(SQLTransaction& trans) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AUCTION); stmt->setUInt32(0, Id); - stmt->setUInt32(1, auctioneer); - stmt->setUInt32(2, item_guidlow); - stmt->setUInt32(3, owner); + stmt->setUInt8(1, houseId); + stmt->setUInt32(2, item_guid.GetCounter()); + stmt->setUInt32(3, owner.GetCounter()); stmt->setUInt32 (4, buyout); stmt->setUInt32(5, uint32(expire_time)); - stmt->setUInt32(6, bidder); + stmt->setUInt32(6, bidder.GetCounter()); stmt->setUInt32 (7, bid); stmt->setUInt32 (8, startbid); stmt->setUInt32 (9, deposit); @@ -764,95 +744,35 @@ void AuctionEntry::SaveToDB(SQLTransaction& trans) const bool AuctionEntry::LoadFromDB(Field* fields) { Id = fields[0].GetUInt32(); - auctioneer = fields[1].GetUInt32(); - item_guidlow = fields[2].GetUInt32(); + houseId = fields[1].GetUInt8(); + item_guid = ObjectGuid::Create<HighGuid::Item>(fields[2].GetUInt32()); item_template = fields[3].GetUInt32(); itemCount = fields[4].GetUInt32(); - owner = fields[5].GetUInt32(); + owner = ObjectGuid::Create<HighGuid::Player>(fields[5].GetUInt32()); buyout = fields[6].GetUInt32(); expire_time = fields[7].GetUInt32(); - bidder = fields[8].GetUInt32(); + bidder = ObjectGuid::Create<HighGuid::Player>(fields[8].GetUInt32()); bid = fields[9].GetUInt32(); startbid = fields[10].GetUInt32(); deposit = fields[11].GetUInt32(); - CreatureData const* auctioneerData = sObjectMgr->GetCreatureData(auctioneer); - if (!auctioneerData) - { - LOG_ERROR("server", "Auction %u has not a existing auctioneer (GUID : %u)", Id, auctioneer); - return false; - } - - CreatureTemplate const* auctioneerInfo = sObjectMgr->GetCreatureTemplate(auctioneerData->id); - if (!auctioneerInfo) - { - LOG_ERROR("server", "Auction %u has not a existing auctioneer (GUID : %u Entry: %u)", Id, auctioneer, auctioneerData->id); - return false; - } - - factionTemplateId = auctioneerInfo->faction; - auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(factionTemplateId); + auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntryFromHouse(houseId); if (!auctionHouseEntry) { - LOG_ERROR("server", "Auction %u has auctioneer (GUID : %u Entry: %u) with wrong faction %u", Id, auctioneer, auctioneerData->id, factionTemplateId); + LOG_ERROR("server", "Auction %u has invalid house id %u", Id, houseId); return false; } // check if sold item exists for guid // and item_template in fact (GetAItem will fail if problematic in result check in AuctionHouseMgr::LoadAuctionItems) - if (!sAuctionMgr->GetAItem(item_guidlow)) + if (!sAuctionMgr->GetAItem(item_guid)) { - LOG_ERROR("server", "Auction %u has not a existing item : %u", Id, item_guidlow); + LOG_ERROR("server", "Auction %u has not a existing item : %s", Id, item_guid.ToString().c_str()); return false; } return true; } -bool AuctionEntry::LoadFromFieldList(Field* fields) -{ - // Loads an AuctionEntry item from a field list. Unlike "LoadFromDB()", this one - // does not require the AuctionEntryMap to have been loaded with items. It simply - // acts as a wrapper to fill out an AuctionEntry struct from a field list - - Id = fields[0].GetUInt32(); - auctioneer = fields[1].GetUInt32(); - item_guidlow = fields[2].GetUInt32(); - item_template = fields[3].GetUInt32(); - itemCount = fields[4].GetUInt32(); - owner = fields[5].GetUInt32(); - buyout = fields[6].GetUInt32(); - expire_time = fields[7].GetUInt32(); - bidder = fields[8].GetUInt32(); - bid = fields[9].GetUInt32(); - startbid = fields[10].GetUInt32(); - deposit = fields[11].GetUInt32(); - - CreatureData const* auctioneerData = sObjectMgr->GetCreatureData(auctioneer); - if (!auctioneerData) - { - LOG_ERROR("server", "AuctionEntry::LoadFromFieldList() - Auction %u has not a existing auctioneer (GUID : %u)", Id, auctioneer); - return false; - } - - CreatureTemplate const* auctioneerInfo = sObjectMgr->GetCreatureTemplate(auctioneerData->id); - if (!auctioneerInfo) - { - LOG_ERROR("server", "AuctionEntry::LoadFromFieldList() - Auction %u has not a existing auctioneer (GUID : %u Entry: %u)", Id, auctioneer, auctioneerData->id); - return false; - } - - factionTemplateId = auctioneerInfo->faction; - auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(factionTemplateId); - - if (!auctionHouseEntry) - { - LOG_ERROR("server", "AuctionEntry::LoadFromFieldList() - Auction %u has auctioneer (GUID : %u Entry: %u) with wrong faction %u", Id, auctioneer, auctioneerData->id, factionTemplateId); - return false; - } - - return true; -} - std::string AuctionEntry::BuildAuctionMailSubject(MailAuctionAnswers response) const { std::ostringstream strm; @@ -860,11 +780,11 @@ std::string AuctionEntry::BuildAuctionMailSubject(MailAuctionAnswers response) c return strm.str(); } -std::string AuctionEntry::BuildAuctionMailBody(uint32 lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut) +std::string AuctionEntry::BuildAuctionMailBody(ObjectGuid guid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut) { std::ostringstream strm; strm.width(16); - strm << std::right << std::hex << MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER); // HIGHGUID_PLAYER always present, even for empty guids + strm << guid.ToString(); strm << std::dec << ':' << bid << ':' << buyout; strm << ':' << deposit << ':' << cut; return strm.str(); diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h index abf598b4f5..22f43d2d82 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.h +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h @@ -11,6 +11,7 @@ #include "DatabaseEnv.h" #include "DBCStructure.h" #include "EventProcessor.h" +#include "ObjectGuid.h" #include "WorldPacket.h" class Item; @@ -50,35 +51,39 @@ enum MailAuctionAnswers AUCTION_SALE_PENDING = 6 }; +enum AuctionHouses +{ + AUCTIONHOUSE_ALLIANCE = 2, + AUCTIONHOUSE_HORDE = 6, + AUCTIONHOUSE_NEUTRAL = 7 +}; + struct AuctionEntry { uint32 Id; - uint32 auctioneer; // creature low guid - uint32 item_guidlow; + uint8 houseId; + ObjectGuid item_guid; uint32 item_template; uint32 itemCount; - uint32 owner; + ObjectGuid owner; uint32 startbid; //maybe useless uint32 bid; uint32 buyout; time_t expire_time; - uint32 bidder; + ObjectGuid bidder; uint32 deposit; //deposit can be calculated only when creating auction AuctionHouseEntry const* auctionHouseEntry; // in AuctionHouse.dbc - uint32 factionTemplateId; // helpers - [[nodiscard]] uint32 GetHouseId() const { return auctionHouseEntry->houseId; } - [[nodiscard]] uint32 GetHouseFaction() const { return auctionHouseEntry->faction; } + [[nodiscard]] uint8 GetHouseId() const { return houseId; } [[nodiscard]] uint32 GetAuctionCut() const; [[nodiscard]] uint32 GetAuctionOutBid() const; bool BuildAuctionInfo(WorldPacket& data) const; void DeleteFromDB(SQLTransaction& trans) const; void SaveToDB(SQLTransaction& trans) const; bool LoadFromDB(Field* fields); - bool LoadFromFieldList(Field* fields); [[nodiscard]] std::string BuildAuctionMailSubject(MailAuctionAnswers response) const; - static std::string BuildAuctionMailBody(uint32 lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut); + static std::string BuildAuctionMailBody(ObjectGuid guid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut); }; //this class is used as auctionhouse instance @@ -133,16 +138,17 @@ private: ~AuctionHouseMgr(); public: - typedef std::unordered_map<uint32, Item*> ItemMap; + typedef std::unordered_map<ObjectGuid, Item*> ItemMap; static AuctionHouseMgr* instance(); AuctionHouseObject* GetAuctionsMap(uint32 factionTemplateId); + AuctionHouseObject* GetAuctionsMapByHouseId(uint8 auctionHouseId); AuctionHouseObject* GetBidsMap(uint32 factionTemplateId); - Item* GetAItem(uint32 id) + Item* GetAItem(ObjectGuid itemGuid) { - ItemMap::const_iterator itr = mAitems.find(id); + ItemMap::const_iterator itr = mAitems.find(itemGuid); if (itr != mAitems.end()) return itr->second; @@ -159,6 +165,7 @@ public: static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item* pItem, uint32 count); static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId); + static AuctionHouseEntry const* GetAuctionHouseEntryFromHouse(uint8 houseId); public: //load first auction items, because of check if item exists, when loading @@ -166,7 +173,7 @@ public: void LoadAuctions(); void AddAItem(Item* it); - bool RemoveAItem(uint32 id, bool deleteFromDB = false); + bool RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB = false); void Update(); diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 33de2e98f4..fe741f0026 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -30,6 +30,7 @@ Battlefield::Battlefield() m_TypeId = 0; m_BattleId = 0; m_ZoneId = 0; + m_Map = nullptr; m_MapId = 0; m_MaxPlayer = 0; m_MinPlayer = 0; @@ -45,13 +46,12 @@ Battlefield::Battlefield() m_LastResurectTimer = RESURRECTION_INTERVAL; m_StartGroupingTimer = 0; m_StartGrouping = false; - StalkerGuid = 0; } Battlefield::~Battlefield() { - for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - delete itr->second; + for (BfCapturePointVector::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) + delete *itr; for (GraveyardVect::const_iterator itr = m_GraveyardList.begin(); itr != m_GraveyardList.end(); ++itr) delete *itr; @@ -110,8 +110,8 @@ void Battlefield::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/) } } - for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - itr->second->HandlePlayerLeave(player); + for (BfCapturePointVector::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) + (*itr)->HandlePlayerLeave(player); m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID()); m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID()); @@ -182,8 +182,8 @@ bool Battlefield::Update(uint32 diff) else m_uiKickDontAcceptTimer -= diff; - for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - if (itr->second->Update(diff)) + for (BfCapturePointVector::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) + if ((*itr)->Update(diff)) objective_changed = true; } @@ -203,7 +203,7 @@ bool Battlefield::Update(uint32 diff) void Battlefield::InvitePlayersInZoneToQueue() { for (uint8 team = 0; team < 2; ++team) - for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) InvitePlayerToQueue(player); } @@ -221,8 +221,8 @@ void Battlefield::InvitePlayersInQueueToWar() { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) { - GuidSet copy(m_PlayersInQueue[team]); - for (GuidSet::const_iterator itr = copy.begin(); itr != copy.end(); ++itr) + GuidUnorderedSet copy(m_PlayersInQueue[team]); + for (GuidUnorderedSet::const_iterator itr = copy.begin(); itr != copy.end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) { @@ -241,7 +241,7 @@ void Battlefield::InvitePlayersInQueueToWar() void Battlefield::InvitePlayersInZoneToWar() { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) { @@ -299,13 +299,13 @@ void Battlefield::KickAfkPlayers() { // xinef: optimization, dont lookup player twice for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) if (player->isAFK() && player->GetZoneId() == GetZoneId() && !player->IsGameMaster()) player->TeleportTo(KickPosition); } -void Battlefield::KickPlayerFromBattlefield(uint64 guid) +void Battlefield::KickPlayerFromBattlefield(ObjectGuid guid) { if (Player* player = ObjectAccessor::FindPlayer(guid)) { @@ -367,7 +367,7 @@ void Battlefield::DoPlaySoundToAll(uint32 SoundID) data << uint32(SoundID); for (int team = 0; team < BG_TEAMS_COUNT; team++) - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->GetSession()->SendPacket(&data); } @@ -423,13 +423,13 @@ void Battlefield::TeamCastSpell(TeamId team, int32 spellId) { if (spellId > 0) { - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->CastSpell(player, uint32(spellId), true); } else { - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->RemoveAuraFromStack(uint32(-spellId)); } @@ -438,7 +438,7 @@ void Battlefield::TeamCastSpell(TeamId team, int32 spellId) void Battlefield::BroadcastPacketToZone(WorldPacket& data) const { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->GetSession()->SendPacket(&data); } @@ -446,7 +446,7 @@ void Battlefield::BroadcastPacketToZone(WorldPacket& data) const void Battlefield::BroadcastPacketToQueue(WorldPacket& data) const { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->GetSession()->SendPacket(&data); } @@ -454,22 +454,23 @@ void Battlefield::BroadcastPacketToQueue(WorldPacket& data) const void Battlefield::BroadcastPacketToWar(WorldPacket& data) const { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->GetSession()->SendPacket(&data); } void Battlefield::SendWarningToAllInZone(uint32 entry) { - if (Unit* unit = ObjectAccessor::FindUnit(StalkerGuid)) - if (Creature* stalker = unit->ToCreature()) - sCreatureTextMgr->SendChat(stalker, (uint8)entry, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); + if (Map* map = sMapMgr->CreateBaseMap(m_MapId)) + if (Unit* unit = map->GetCreature(StalkerGuid)) + if (Creature* stalker = unit->ToCreature()) + sCreatureTextMgr->SendChat(stalker, (uint8)entry, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); } void Battlefield::SendWarningToPlayer(Player* player, uint32 entry) { if (player) - if (Unit* unit = ObjectAccessor::FindUnit(StalkerGuid)) + if (Unit* unit = ObjectAccessor::GetCreature(*player, StalkerGuid)) if (Creature* stalker = unit->ToCreature()) sCreatureTextMgr->SendChat(stalker, (uint8)entry, player); } @@ -477,7 +478,7 @@ void Battlefield::SendWarningToPlayer(Player* player, uint32 entry) void Battlefield::SendUpdateWorldState(uint32 field, uint32 value) { for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i) - for (GuidSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) + for (GuidUnorderedSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->SendUpdateWorldState(field, value); } @@ -518,18 +519,18 @@ void Battlefield::ShowNpc(Creature* creature, bool aggressive) // **************************************************** Group* Battlefield::GetFreeBfRaid(TeamId TeamId) { - for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) - if (Group* group = sGroupMgr->GetGroupByGUID(*itr)) + for (GuidUnorderedSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) + if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter())) if (!group->IsFull()) return group; return nullptr; } -Group* Battlefield::GetGroupPlayer(uint64 guid, TeamId TeamId) +Group* Battlefield::GetGroupPlayer(ObjectGuid guid, TeamId TeamId) { - for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) - if (Group* group = sGroupMgr->GetGroupByGUID(*itr)) + for (GuidUnorderedSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) + if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter())) if (group->IsMember(guid)) return group; @@ -617,7 +618,7 @@ GraveyardStruct const* Battlefield::GetClosestGraveyard(Player* player) return nullptr; } -void Battlefield::AddPlayerToResurrectQueue(uint64 npcGuid, uint64 playerGuid) +void Battlefield::AddPlayerToResurrectQueue(ObjectGuid npcGuid, ObjectGuid playerGuid) { for (uint8 i = 0; i < m_GraveyardList.size(); i++) { @@ -632,7 +633,7 @@ void Battlefield::AddPlayerToResurrectQueue(uint64 npcGuid, uint64 playerGuid) } } -void Battlefield::RemovePlayerFromResurrectQueue(uint64 playerGuid) +void Battlefield::RemovePlayerFromResurrectQueue(ObjectGuid playerGuid) { for (uint8 i = 0; i < m_GraveyardList.size(); i++) { @@ -647,7 +648,7 @@ void Battlefield::RemovePlayerFromResurrectQueue(uint64 playerGuid) } } -void Battlefield::SendAreaSpiritHealerQueryOpcode(Player* player, const uint64& guid) +void Battlefield::SendAreaSpiritHealerQueryOpcode(Player* player, const ObjectGuid& guid) { WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12); uint32 time = m_LastResurectTimer; // resurrect every 30 seconds @@ -665,8 +666,6 @@ BfGraveyard::BfGraveyard(Battlefield* battlefield) m_Bf = battlefield; m_GraveyardId = 0; m_ControlTeam = TEAM_NEUTRAL; - m_SpiritGuide[0] = 0; - m_SpiritGuide[1] = 0; m_ResurrectQueue.clear(); } @@ -694,7 +693,7 @@ float BfGraveyard::GetDistance(Player* player) return player->GetDistance2d(safeLoc->x, safeLoc->y); } -void BfGraveyard::AddPlayer(uint64 playerGuid) +void BfGraveyard::AddPlayer(ObjectGuid playerGuid) { if (!m_ResurrectQueue.count(playerGuid)) { @@ -705,7 +704,7 @@ void BfGraveyard::AddPlayer(uint64 playerGuid) } } -void BfGraveyard::RemovePlayer(uint64 playerGuid) +void BfGraveyard::RemovePlayer(ObjectGuid playerGuid) { m_ResurrectQueue.erase(m_ResurrectQueue.find(playerGuid)); @@ -718,7 +717,7 @@ void BfGraveyard::Resurrect() if (m_ResurrectQueue.empty()) return; - for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr) { // Get player object from his guid Player* player = ObjectAccessor::FindPlayer(*itr); @@ -727,7 +726,7 @@ void BfGraveyard::Resurrect() // Check if the player is in world and on the good graveyard if (player->IsInWorld()) - if (Unit* spirit = ObjectAccessor::FindUnit(m_SpiritGuide[m_ControlTeam])) + if (Unit* spirit = ObjectAccessor::GetCreature(*player, m_SpiritGuide[m_ControlTeam])) spirit->CastSpell(spirit, SPELL_SPIRIT_HEAL, true); // Resurect player @@ -736,7 +735,7 @@ void BfGraveyard::Resurrect() player->CastSpell(player, 6962, true); player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true); - sObjectAccessor->ConvertCorpseForPlayer(player->GetGUID()); + player->SpawnCorpseBones(false); } m_ResurrectQueue.clear(); @@ -753,7 +752,7 @@ void BfGraveyard::GiveControlTo(TeamId team) void BfGraveyard::RelocateDeadPlayers() { GraveyardStruct const* closestGrave = nullptr; - for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr) { Player* player = ObjectAccessor::FindPlayer(*itr); if (!player) @@ -792,7 +791,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl } Creature* creature = new Creature(true); - if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o)) + if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o)) { LOG_ERROR("server", "Battlefield::SpawnCreature: Can't create creature entry: %u", entry); delete creature; @@ -828,7 +827,7 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z // Create gameobject GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject(); - if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(), 100, GO_STATE_READY)) + if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(), 100, GO_STATE_READY)) { LOG_ERROR("sql.sql", "Battlefield::SpawnGameObject: Gameobject template %u not found in database! Battlefield not created!", entry); LOG_ERROR("server", "Battlefield::SpawnGameObject: Cannot create gameobject template %u! Battlefield not created!", entry); @@ -843,11 +842,27 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z return go; } +Creature* Battlefield::GetCreature(ObjectGuid const guid) +{ + if (!m_Map) + return nullptr; + + return m_Map->GetCreature(guid); +} + +GameObject* Battlefield::GetGameObject(ObjectGuid const guid) +{ + if (!m_Map) + return nullptr; + + return m_Map->GetGameObject(guid); +} + // ******************************************************* // ******************* CapturePoint ********************** // ******************************************************* -BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePoint(0) +BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield) { m_team = TEAM_NEUTRAL; m_value = 0; @@ -871,12 +886,12 @@ bool BfCapturePoint::HandlePlayerEnter(Player* player) return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second; } -GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player) +GuidUnorderedSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player) { if (GameObject* go = GetCapturePointGo(player)) player->SendUpdateWorldState(go->GetGOInfo()->capturePoint.worldState1, 0); - GuidSet::iterator current = m_activePlayers[player->GetTeamId()].find(player->GetGUID()); + GuidUnorderedSet::iterator current = m_activePlayers[player->GetTeamId()].find(player->GetGUID()); if (current == m_activePlayers[player->GetTeamId()].end()) return current; // return end() @@ -892,7 +907,7 @@ void BfCapturePoint::SendChangePhase() return; for (uint8 team = 0; team < 2; ++team) - for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) // send to all players present in the area + for (GuidUnorderedSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) // send to all players present in the area if (Player* player = ObjectAccessor::FindPlayer(*itr)) { // send this too, sometimes the slider disappears, dunno why :( @@ -948,12 +963,22 @@ bool BfCapturePoint::DelCapturePoint() { capturePoint->SetRespawnTime(0); // not save respawn time capturePoint->Delete(); - m_capturePoint = 0; + m_capturePoint.Clear(); } return true; } +GameObject* BfCapturePoint::GetCapturePointGo() +{ + return m_Bf->GetGameObject(m_capturePoint); +} + +GameObject* BfCapturePoint::GetCapturePointGo(WorldObject* obj) +{ + return ObjectAccessor::GetGameObject(*obj, m_capturePoint); +} + bool BfCapturePoint::Update(uint32 diff) { GameObject* capturePoint = GetCapturePointGo(); @@ -964,7 +989,7 @@ bool BfCapturePoint::Update(uint32 diff) for (uint8 team = 0; team < 2; ++team) { - for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) + for (GuidUnorderedSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) if (!capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) @@ -1076,12 +1101,12 @@ bool BfCapturePoint::Update(uint32 diff) void BfCapturePoint::SendUpdateWorldState(uint32 field, uint32 value) { for (uint8 team = 0; team < 2; ++team) - for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) // send to all players present in the area + for (GuidUnorderedSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) // send to all players present in the area if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->SendUpdateWorldState(field, value); } -void BfCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid) +void BfCapturePoint::SendObjectiveComplete(uint32 id, ObjectGuid guid) { uint8 team; switch (m_State) @@ -1097,7 +1122,7 @@ void BfCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid) } // send to all players present in the area - for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) + for (GuidUnorderedSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->KilledMonsterCredit(id, guid); } diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index 3505d2c39e..5c158e5bc8 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -65,9 +65,8 @@ class Unit; class Battlefield; class BfGraveyard; -typedef std::unordered_set<uint64> GuidSet; typedef std::vector<BfGraveyard*> GraveyardVect; -typedef std::map<uint64, time_t> PlayerTimerMap; +typedef std::map<ObjectGuid, time_t> PlayerTimerMap; class BfCapturePoint { @@ -82,11 +81,11 @@ public: void SendUpdateWorldState(uint32 field, uint32 value); // Send kill notify to players in the controlling faction - void SendObjectiveComplete(uint32 id, uint64 guid); + void SendObjectiveComplete(uint32 id, ObjectGuid guid); // Used when player is activated/inactivated in the area virtual bool HandlePlayerEnter(Player* player); - virtual GuidSet::iterator HandlePlayerLeave(Player* player); + virtual GuidUnorderedSet::iterator HandlePlayerLeave(Player* player); //virtual void HandlePlayerActivityChanged(Player* player); // Checks if player is in range of a capture credit marker @@ -98,15 +97,15 @@ public: virtual void SendChangePhase(); bool SetCapturePointData(GameObject* capturePoint); - GameObject* GetCapturePointGo() { return ObjectAccessor::GetObjectInWorld(m_capturePoint, (GameObject*)nullptr); } - GameObject* GetCapturePointGo(WorldObject* obj) { return ObjectAccessor::GetGameObject(*obj, m_capturePoint); } + GameObject* GetCapturePointGo(); + GameObject* GetCapturePointGo(WorldObject* obj); TeamId GetTeamId() { return m_team; } protected: bool DelCapturePoint(); // active Players in the area of the objective, 0 - alliance, 1 - horde - GuidSet m_activePlayers[2]; + GuidUnorderedSet m_activePlayers[2]; // Total shift needed to capture the objective float m_maxValue; @@ -133,7 +132,7 @@ protected: uint32 m_capturePointEntry; // Gameobject related to that capture point - uint64 m_capturePoint; + ObjectGuid m_capturePoint; }; class BfGraveyard @@ -155,10 +154,10 @@ public: void SetSpirit(Creature* spirit, TeamId team); // Add a player to the graveyard - void AddPlayer(uint64 player_guid); + void AddPlayer(ObjectGuid player_guid); // Remove a player from the graveyard - void RemovePlayer(uint64 player_guid); + void RemovePlayer(ObjectGuid player_guid); // Resurrect players void Resurrect(); @@ -167,7 +166,7 @@ public: void RelocateDeadPlayers(); // Check if this graveyard has a spirit guide - bool HasNpc(uint64 guid) + bool HasNpc(ObjectGuid guid) { if (!m_SpiritGuide[0] && !m_SpiritGuide[1]) return false; @@ -181,7 +180,7 @@ public: } // Check if a player is in this graveyard's resurrect queue - bool HasPlayer(uint64 guid) const { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); } + bool HasPlayer(ObjectGuid guid) const { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); } // Get the graveyard's ID. uint32 GetGraveyardId() const { return m_GraveyardId; } @@ -189,8 +188,8 @@ public: protected: TeamId m_ControlTeam; uint32 m_GraveyardId; - uint64 m_SpiritGuide[2]; - GuidSet m_ResurrectQueue; + ObjectGuid m_SpiritGuide[2]; + GuidUnorderedSet m_ResurrectQueue; Battlefield* m_Bf; }; @@ -205,7 +204,7 @@ public: ~Battlefield() override; /// typedef of map witch store capturepoint and the associate gameobject entry - typedef std::map<uint32 /*lowguid */, BfCapturePoint*> BfCapturePointMap; + typedef std::vector<BfCapturePoint*> BfCapturePointVector; /// Call this to init the Battlefield virtual bool SetupBattlefield() { return true; } @@ -249,7 +248,7 @@ public: * \brief Kick player from battlefield and teleport him to kick-point location * \param guid : guid of player who must be kick */ - void KickPlayerFromBattlefield(uint64 guid); + void KickPlayerFromBattlefield(ObjectGuid guid); /// Called when player (player) enter in zone void HandlePlayerEnterZone(Player* player, uint32 zone); @@ -278,7 +277,7 @@ public: */ Group* GetFreeBfRaid(TeamId TeamId); /// Return battlefield group where player is. - Group* GetGroupPlayer(uint64 guid, TeamId TeamId); + Group* GetGroupPlayer(ObjectGuid guid, TeamId TeamId); /// Force player to join a battlefield group bool AddOrSetPlayerToCorrectBfGroup(Player* player); @@ -286,8 +285,8 @@ public: // Find which graveyard the player must be teleported to to be resurrected by spiritguide GraveyardStruct const* GetClosestGraveyard(Player* player); - virtual void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid); - void RemovePlayerFromResurrectQueue(uint64 player_guid); + virtual void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid); + void RemovePlayerFromResurrectQueue(ObjectGuid player_guid); void SetGraveyardNumber(uint32 number) { m_GraveyardList.resize(number); } BfGraveyard* GetGraveyardById(uint32 id) const; @@ -296,6 +295,9 @@ public: Creature* SpawnCreature(uint32 entry, Position pos, TeamId teamId); GameObject* SpawnGameObject(uint32 entry, float x, float y, float z, float o); + Creature* GetCreature(ObjectGuid const guid); + GameObject* GetGameObject(ObjectGuid const guid); + // Script-methods /// Called on start @@ -331,7 +333,7 @@ public: /// Return if we can use mount in battlefield bool CanFlyIn() { return !m_isActive; } - void SendAreaSpiritHealerQueryOpcode(Player* player, const uint64& guid); + void SendAreaSpiritHealerQueryOpcode(Player* player, const ObjectGuid& guid); void StartBattle(); void EndBattle(bool endByTimer); @@ -352,19 +354,19 @@ public: void InitStalker(uint32 entry, float x, float y, float z, float o); protected: - uint64 StalkerGuid; + ObjectGuid StalkerGuid; uint32 m_Timer; // Global timer for event bool m_IsEnabled; bool m_isActive; TeamId m_DefenderTeam; // Map of the objectives belonging to this OutdoorPvP - BfCapturePointMap m_capturePoints; + BfCapturePointVector m_capturePoints; // Players info maps - GuidSet m_players[BG_TEAMS_COUNT]; // Players in zone - GuidSet m_PlayersInQueue[BG_TEAMS_COUNT]; // Players in the queue - GuidSet m_PlayersInWar[BG_TEAMS_COUNT]; // Players in WG combat + GuidUnorderedSet m_players[BG_TEAMS_COUNT]; // Players in zone + GuidUnorderedSet m_PlayersInQueue[BG_TEAMS_COUNT]; // Players in the queue + GuidUnorderedSet m_PlayersInWar[BG_TEAMS_COUNT]; // Players in WG combat PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT]; PlayerTimerMap m_PlayersWillBeKick[BG_TEAMS_COUNT]; @@ -373,6 +375,7 @@ protected: uint32 m_BattleId; // BattleID (for packet) uint32 m_ZoneId; // ZoneID of Wintergrasp = 4197 uint32 m_MapId; // MapId where is Battlefield + Map* m_Map; uint32 m_MaxPlayer; // Maximum number of player that participated to Battlefield uint32 m_MinPlayer; // Minimum number of player for Battlefield start uint32 m_MinLevel; // Required level to participate at Battlefield @@ -392,7 +395,7 @@ protected: uint32 m_StartGroupingTimer; // Timer for invite players in area 15 minute before start battle bool m_StartGrouping; // bool for know if all players in area has been invited - GuidSet m_Groups[BG_TEAMS_COUNT]; // Contain different raid group + GuidUnorderedSet m_Groups[BG_TEAMS_COUNT]; // Contain different raid group std::vector<uint64> m_Data64; std::vector<uint32> m_Data32; @@ -408,15 +411,7 @@ protected: void BroadcastPacketToWar(WorldPacket& data) const; // CapturePoint system - void AddCapturePoint(BfCapturePoint* cp, GameObject* go) { m_capturePoints[go->GetEntry()] = cp; } - - BfCapturePoint* GetCapturePoint(uint32 lowguid) const - { - Battlefield::BfCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid); - if (itr != m_capturePoints.end()) - return itr->second; - return nullptr; - } + void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints.push_back(cp); } void RegisterZone(uint32 zoneid); bool HasPlayer(Player* player) const; diff --git a/src/server/game/Battlefield/BattlefieldMgr.cpp b/src/server/game/Battlefield/BattlefieldMgr.cpp index b1a4d9e2ae..4447f53c4b 100644 --- a/src/server/game/Battlefield/BattlefieldMgr.cpp +++ b/src/server/game/Battlefield/BattlefieldMgr.cpp @@ -82,7 +82,7 @@ void BattlefieldMgr::HandlePlayerEnterZone(Player* player, uint32 zoneid) itr->second->HandlePlayerEnterZone(player, zoneid); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("bg.battlefield", "Player %u entered outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId()); + LOG_DEBUG("bg.battlefield", "Player %s entered outdoorpvp id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId()); #endif } @@ -97,7 +97,7 @@ void BattlefieldMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneid) return; itr->second->HandlePlayerLeaveZone(player, zoneid); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("bg.battlefield", "Player %u left outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId()); + LOG_DEBUG("bg.battlefield", "Player %s left outdoorpvp id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId()); #endif } diff --git a/src/server/game/Battlefield/BattlefieldMgr.h b/src/server/game/Battlefield/BattlefieldMgr.h index acedaf481c..df19f5c735 100644 --- a/src/server/game/Battlefield/BattlefieldMgr.h +++ b/src/server/game/Battlefield/BattlefieldMgr.h @@ -44,7 +44,7 @@ public: void Update(uint32 diff); - void HandleGossipOption(Player* player, uint64 guid, uint32 gossipid); + void HandleGossipOption(Player* player, ObjectGuid guid, uint32 gossipid); bool CanTalkTo(Player* player, Creature* creature, GossipMenuItems gso); diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 959aea89b5..1836c7adf7 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -9,6 +9,7 @@ // TODO: Add proper implement of achievement #include "BattlefieldWG.h" +#include "MapManager.h" #include "ObjectMgr.h" #include "Opcodes.h" #include "Player.h" @@ -32,6 +33,7 @@ bool BattlefieldWG::SetupBattlefield() m_BattleId = BATTLEFIELD_BATTLEID_WG; m_ZoneId = BATTLEFIELD_WG_ZONEID; m_MapId = BATTLEFIELD_WG_MAPID; + m_Map = sMapMgr->FindMap(m_MapId, 0); // init stalker AFTER setting map id... we spawn it at map=random memory value?... InitStalker(BATTLEFIELD_WG_NPC_STALKER, WintergraspStalkerPos[0], WintergraspStalkerPos[1], WintergraspStalkerPos[2], WintergraspStalkerPos[3]); @@ -49,7 +51,7 @@ bool BattlefieldWG::SetupBattlefield() m_StartGrouping = false; m_tenacityStack = 0; - m_titansRelic = 0; + m_titansRelic.Clear(); KickPosition.Relocate(5728.117f, 2714.346f, 697.733f, 0); KickPosition.m_mapId = m_MapId; @@ -121,10 +123,9 @@ bool BattlefieldWG::SetupBattlefield() } // Hide NPCs from the Attacker's team in the keep - for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - HideNpc(creature); + for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr) + if (Creature* creature = GetCreature(*itr)) + HideNpc(creature); // Spawn Horde NPCs outside the keep for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; i++) @@ -137,10 +138,9 @@ bool BattlefieldWG::SetupBattlefield() OutsideCreature[TEAM_ALLIANCE].insert(creature->GetGUID()); // Hide units outside the keep that are defenders - for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - HideNpc(creature); + for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr) + if (Creature* creature = GetCreature(*itr)) + HideNpc(creature); // Spawn turrets and hide them per default for (uint8 i = 0; i < WG_MAX_TURRET; i++) @@ -223,15 +223,12 @@ void BattlefieldWG::OnBattleStart() LOG_ERROR("server", "WG: Failed to spawn titan relic."); // Update tower visibility and update faction - for (GuidSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr) { - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) + if (Creature* creature = GetCreature(*itr)) { - if (Creature* creature = unit->ToCreature()) - { - ShowNpc(creature, true); - creature->setFaction(WintergraspFaction[GetDefenderTeam()]); - } + ShowNpc(creature, true); + creature->setFaction(WintergraspFaction[GetDefenderTeam()]); } } @@ -255,7 +252,7 @@ void BattlefieldWG::OnBattleStart() (*itr)->UpdateGraveyardAndWorkshop(); for (uint8 team = 0; team < 2; ++team) - for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) { // Kick player in orb room, TODO: offline player ? if (Player* player = ObjectAccessor::FindPlayer(*itr)) @@ -308,7 +305,7 @@ void BattlefieldWG::UpdateCounterVehicle(bool init) void BattlefieldWG::UpdateVehicleCountWG() { for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i) - for (GuidSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) + for (GuidUnorderedSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) { player->SendUpdateWorldState(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_H, GetData(BATTLEFIELD_WG_DATA_VEHICLE_H)); @@ -321,7 +318,7 @@ void BattlefieldWG::UpdateVehicleCountWG() void BattlefieldWG::CapturePointTaken(uint32 areaId) { for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i) - for (GuidSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) + for (GuidUnorderedSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) if (player->GetAreaId() == areaId) player->UpdateAreaDependentAuras(areaId); @@ -332,43 +329,37 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) // Remove relic if (GameObject* go = GetRelic()) go->RemoveFromWorld(); - m_titansRelic = 0; + + m_titansRelic.Clear(); // Remove turret - for (GuidSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr) { - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) + if (Creature* creature = GetCreature(*itr)) { - if (Creature* creature = unit->ToCreature()) - { - if (!endByTimer) - creature->setFaction(WintergraspFaction[GetDefenderTeam()]); - HideNpc(creature); - } + if (!endByTimer) + creature->setFaction(WintergraspFaction[GetDefenderTeam()]); + HideNpc(creature); } } // Change all npc in keep - for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - HideNpc(creature); + for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr) + if (Creature* creature = GetCreature(*itr)) + HideNpc(creature); - for (GuidSet::const_iterator itr = KeepCreature[GetDefenderTeam()].begin(); itr != KeepCreature[GetDefenderTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - ShowNpc(creature, true); + for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetDefenderTeam()].begin(); itr != KeepCreature[GetDefenderTeam()].end(); ++itr) + if (Creature* creature = GetCreature(*itr)) + ShowNpc(creature, true); // Change all npc out of keep - for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - HideNpc(creature); + for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr) + if (Creature* creature = GetCreature(*itr)) + HideNpc(creature); - for (GuidSet::const_iterator itr = OutsideCreature[GetAttackerTeam()].begin(); itr != OutsideCreature[GetAttackerTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - ShowNpc(creature, true); + for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetAttackerTeam()].begin(); itr != OutsideCreature[GetAttackerTeam()].end(); ++itr) + if (Creature* creature = GetCreature(*itr)) + ShowNpc(creature, true); // Update all graveyard, control is to defender when no wartime for (uint8 i = 0; i < BATTLEFIELD_WG_GY_HORDE; i++) @@ -398,10 +389,9 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) for (uint8 team = 0; team < 2; ++team) { - for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - creature->DespawnOrUnsummon(1); + for (GuidUnorderedSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) + if (Creature* creature = GetCreature(*itr)) + creature->DespawnOrUnsummon(1); m_vehicles[team].clear(); } @@ -425,7 +415,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) spellFullAtt = SPELL_DESTROYED_TOWER; } - for (GuidSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) { @@ -443,7 +433,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) } } - for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) { player->CastSpell(player, SPELL_DEFEAT_REWARD, true); @@ -459,7 +449,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) { for (uint8 team = 0; team < 2; ++team) { - for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) { @@ -682,7 +672,7 @@ void BattlefieldWG::OnGameObjectCreate(GameObject* go) capturePoint->SetCapturePointData(go); capturePoint->LinkToWorkshop(workshop); - AddCapturePoint(capturePoint, go); + AddCapturePoint(capturePoint); break; } } @@ -700,7 +690,7 @@ void BattlefieldWG::HandleKill(Player* killer, Unit* victim) // xinef: tower cannons also grant rank if (victim->GetTypeId() == TYPEID_PLAYER || IsKeepNpc(victim->GetEntry()) || victim->GetEntry() == NPC_WINTERGRASP_TOWER_CANNON) { - for (GuidSet::const_iterator itr = m_PlayersInWar[killerTeam].begin(); itr != m_PlayersInWar[killerTeam].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[killerTeam].begin(); itr != m_PlayersInWar[killerTeam].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) if (player->GetDistance2d(killer) < 40) PromotePlayer(player); @@ -712,10 +702,10 @@ void BattlefieldWG::HandleKill(Player* killer, Unit* victim) else if (victim->IsVehicle() && !killer->IsFriendlyTo(victim)) { // Quest - Wintergrasp - PvP Kill - Vehicle - for (GuidSet::const_iterator itr = m_PlayersInWar[killerTeam].begin(); itr != m_PlayersInWar[killerTeam].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[killerTeam].begin(); itr != m_PlayersInWar[killerTeam].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) if (player->GetDistance2d(killer) < 40) - player->KilledMonsterCredit(NPC_QUEST_PVP_KILL_VEHICLE, 0); + player->KilledMonsterCredit(NPC_QUEST_PVP_KILL_VEHICLE); } } @@ -918,7 +908,7 @@ void BattlefieldWG::SendInitWorldStatesTo(Player* player) void BattlefieldWG::SendInitWorldStatesToAll() { for (uint8 team = 0; team < 2; team++) - for (GuidSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) + for (GuidUnorderedSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) SendInitWorldStatesTo(player); } @@ -928,7 +918,7 @@ void BattlefieldWG::BrokenWallOrTower(TeamId /*team*/) // might be some use for this in the future. old code commented out below. KL /* if (team == GetDefenderTeam()) { - for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) IncrementQuest(player, WGQuest[player->GetTeamId()][2], true); @@ -947,17 +937,17 @@ void BattlefieldWG::UpdatedDestroyedTowerCount(TeamId team, GameObject* go) UpdateData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT, 1); // Remove buff stack on attackers - for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->RemoveAuraFromStack(SPELL_TOWER_CONTROL); // Add buff stack to defenders - for (GuidSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) { // Quest - Wintergrasp - Southern Tower Kill if (go && player->GetDistance2d(go) < 200.0f) - player->KilledMonsterCredit(NPC_QUEST_SOUTHERN_TOWER_KILL, 0); + player->KilledMonsterCredit(NPC_QUEST_SOUTHERN_TOWER_KILL); player->CastSpell(player, SPELL_TOWER_CONTROL, true); player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_LEANING_TOWER_ACHIEVEMENT, 0, 0); @@ -976,12 +966,12 @@ void BattlefieldWG::UpdatedDestroyedTowerCount(TeamId team, GameObject* go) else { // Xinef: rest of structures, quest credit - for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) { // Quest - Wintergrasp - Vehicle Protected if (go && player->GetDistance2d(go) < 100.0f) - player->KilledMonsterCredit(NPC_QUEST_VEHICLE_PROTECTED, 0); + player->KilledMonsterCredit(NPC_QUEST_VEHICLE_PROTECTED); } } } @@ -1053,7 +1043,7 @@ void BattlefieldWG::AddUpdateTenacity(Player* player) void BattlefieldWG::RemoveUpdateTenacity(Player* player) { m_updateTenacityList.erase(player->GetGUID()); - m_updateTenacityList.insert(0); + m_updateTenacityList.insert(ObjectGuid::Empty); } void BattlefieldWG::UpdateTenacity() @@ -1074,7 +1064,7 @@ void BattlefieldWG::UpdateTenacity() // Return if no change in stack and apply tenacity to new player if (newStack == m_tenacityStack) { - for (GuidSet::const_iterator itr = m_updateTenacityList.begin(); itr != m_updateTenacityList.end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_updateTenacityList.begin(); itr != m_updateTenacityList.end(); ++itr) if (Player* newPlayer = ObjectAccessor::FindPlayer(*itr)) if ((newPlayer->GetTeamId() == TEAM_ALLIANCE && m_tenacityStack > 0) || (newPlayer->GetTeamId() == TEAM_HORDE && m_tenacityStack < 0)) { @@ -1099,13 +1089,13 @@ void BattlefieldWG::UpdateTenacity() // Remove old buff if (team != TEAM_NEUTRAL) { - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->RemoveAurasDueToSpell(SPELL_TENACITY); - for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - unit->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE); + for (GuidUnorderedSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) + if (Creature* creature = GetCreature(*itr)) + creature->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE); } // Apply new buff @@ -1115,7 +1105,7 @@ void BattlefieldWG::UpdateTenacity() newStack = std::min(abs(newStack), 20); uint32 buff_honor = GetHonorBuff(newStack); - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) { player->SetAuraStack(SPELL_TENACITY, player, newStack); @@ -1123,12 +1113,12 @@ void BattlefieldWG::UpdateTenacity() player->CastSpell(player, buff_honor, true); } - for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) + for (GuidUnorderedSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) + if (Creature* creature = GetCreature(*itr)) { - unit->SetAuraStack(SPELL_TENACITY_VEHICLE, unit, newStack); + creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, newStack); if (buff_honor) - unit->CastSpell(unit, buff_honor, true); + creature->CastSpell(creature, buff_honor, true); } } } diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.h b/src/server/game/Battlefield/Zones/BattlefieldWG.h index 6de29b184a..c174ae4de7 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.h +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.h @@ -373,7 +373,7 @@ public: bool SetupBattlefield() override; /// Return pointer to relic object - GameObject* GetRelic() { return ObjectAccessor::GetObjectInWorld(m_titansRelic, (GameObject*)nullptr); } + GameObject* GetRelic() { return GetGameObject(m_titansRelic); } /// Define relic object //void SetRelic(GameObject* relic) { m_titansRelic = relic; } @@ -450,17 +450,17 @@ protected: GameObjectSet m_KeepGameObject[2]; GameObjectBuilding BuildingsInZone; - GuidSet m_vehicles[2]; - GuidSet CanonList; - GuidSet KeepCreature[2]; - GuidSet OutsideCreature[2]; - GuidSet m_updateTenacityList; + GuidUnorderedSet m_vehicles[2]; + GuidUnorderedSet CanonList; + GuidUnorderedSet KeepCreature[2]; + GuidUnorderedSet OutsideCreature[2]; + GuidUnorderedSet m_updateTenacityList; int32 m_tenacityStack; uint32 m_tenacityUpdateTimer; uint32 m_saveTimer; - uint64 m_titansRelic; + ObjectGuid m_titansRelic; }; const uint8 WG_MAX_OBJ = 32; @@ -1079,7 +1079,6 @@ struct BfWGGameObjectBuilding { m_WG = WG; m_Team = TEAM_ALLIANCE; - m_Build = 0; m_Type = 0; m_WorldState = 0; m_State = 0; @@ -1094,7 +1093,7 @@ struct BfWGGameObjectBuilding BattlefieldWG* m_WG; // Linked gameobject - uint64 m_Build; + ObjectGuid m_Build; // eWGGameObjectBuildingType uint32 m_Type; @@ -1113,10 +1112,10 @@ struct BfWGGameObjectBuilding GameObjectSet m_GameObjectList[2]; // Creature associations - GuidSet m_CreatureBottomList[2]; - GuidSet m_CreatureTopList[2]; - GuidSet m_TowerCannonBottomList; - GuidSet m_TurretTopList; + GuidUnorderedSet m_CreatureBottomList[2]; + GuidUnorderedSet m_CreatureTopList[2]; + GuidUnorderedSet m_TowerCannonBottomList; + GuidUnorderedSet m_TurretTopList; void Rebuild() { @@ -1136,7 +1135,7 @@ struct BfWGGameObjectBuilding break; } - GameObject* go = ObjectAccessor::GetObjectInWorld(m_Build, (GameObject*)nullptr); + GameObject* go = m_WG->GetGameObject(m_Build); if (go) { // Rebuild gameobject @@ -1161,15 +1160,13 @@ struct BfWGGameObjectBuilding if (m_damagedText) // tower damage + name m_WG->SendWarningToAllInZone(m_damagedText); - for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->HideNpc(creature); + for (GuidUnorderedSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr) + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->HideNpc(creature); - for (GuidSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->HideNpc(creature); + for (GuidUnorderedSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr) + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->HideNpc(creature); if (m_Type == BATTLEFIELD_WG_OBJECTTYPE_TOWER) m_WG->UpdateDamagedTowerCount(m_WG->GetAttackerTeam()); @@ -1190,7 +1187,7 @@ struct BfWGGameObjectBuilding { // Inform the global wintergrasp script of the destruction of this object case BATTLEFIELD_WG_OBJECTTYPE_TOWER: - m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team), ObjectAccessor::GetObjectInWorld(m_Build, (GameObject*)nullptr)); + m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team), m_WG->GetGameObject(m_Build)); break; case BATTLEFIELD_WG_OBJECTTYPE_DOOR_LAST: m_WG->SetRelicInteractible(true); @@ -1202,7 +1199,7 @@ struct BfWGGameObjectBuilding case BATTLEFIELD_WG_OBJECTTYPE_DOOR: case BATTLEFIELD_WG_OBJECTTYPE_WALL: case BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER: - m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team), ObjectAccessor::GetObjectInWorld(m_Build, (GameObject*)nullptr)); + m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team), m_WG->GetGameObject(m_Build)); break; } @@ -1355,25 +1352,21 @@ struct BfWGGameObjectBuilding void UpdateCreatureAndGo() { - for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureTopList[m_WG->GetDefenderTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->HideNpc(creature); + for (GuidUnorderedSet::const_iterator itr = m_CreatureTopList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureTopList[m_WG->GetDefenderTeam()].end(); ++itr) + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->HideNpc(creature); - for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->ShowNpc(creature, true); + for (GuidUnorderedSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr) + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->ShowNpc(creature, true); - for (GuidSet::const_iterator itr = m_CreatureBottomList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetDefenderTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->HideNpc(creature); + for (GuidUnorderedSet::const_iterator itr = m_CreatureBottomList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetDefenderTeam()].end(); ++itr) + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->HideNpc(creature); - for (GuidSet::const_iterator itr = m_CreatureBottomList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetAttackerTeam()].end(); ++itr) - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->ShowNpc(creature, true); + for (GuidUnorderedSet::const_iterator itr = m_CreatureBottomList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetAttackerTeam()].end(); ++itr) + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->ShowNpc(creature, true); for (GameObjectSet::const_iterator itr = m_GameObjectList[m_WG->GetDefenderTeam()].begin(); itr != m_GameObjectList[m_WG->GetDefenderTeam()].end(); ++itr) (*itr)->SetRespawnTime(RESPAWN_ONE_DAY); @@ -1384,7 +1377,7 @@ struct BfWGGameObjectBuilding void UpdateTurretAttack(bool disable) { - GameObject* build = ObjectAccessor::GetObjectInWorld(m_Build, (GameObject*)nullptr); + GameObject* build = m_WG->GetGameObject(m_Build); if (!build) return; @@ -1404,33 +1397,27 @@ struct BfWGGameObjectBuilding break; } - for (GuidSet::const_iterator itr = m_TowerCannonBottomList.begin(); itr != m_TowerCannonBottomList.end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_TowerCannonBottomList.begin(); itr != m_TowerCannonBottomList.end(); ++itr) { - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) + if (Creature* creature = m_WG->GetCreature(*itr)) { - if (Creature* creature = unit->ToCreature()) - { - creature->setFaction(faction); - if (disable) - m_WG->HideNpc(creature); - else - m_WG->ShowNpc(creature, true); - } + creature->setFaction(faction); + if (disable) + m_WG->HideNpc(creature); + else + m_WG->ShowNpc(creature, true); } } - for (GuidSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr) { - if (Unit* unit = ObjectAccessor::FindUnit(*itr)) + if (Creature* creature = m_WG->GetCreature(*itr)) { - if (Creature* creature = unit->ToCreature()) - { - creature->setFaction(faction); - if (disable) - m_WG->HideNpc(creature); - else - m_WG->ShowNpc(creature, true); - } + creature->setFaction(faction); + if (disable) + m_WG->HideNpc(creature); + else + m_WG->ShowNpc(creature, true); } } } diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index 482749f159..fd318e7539 100644 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -17,7 +17,7 @@ #include "WorldSession.h" ArenaTeam::ArenaTeam() - : TeamId(0), Type(0), TeamName(), CaptainGuid(0), BackgroundColor(0), EmblemStyle(0), EmblemColor(0), + : TeamId(0), Type(0), TeamName(), BackgroundColor(0), EmblemStyle(0), EmblemColor(0), BorderStyle(0), BorderColor(0) { Stats.WeekGames = 0; @@ -32,10 +32,10 @@ ArenaTeam::~ArenaTeam() { } -bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor) +bool ArenaTeam::Create(ObjectGuid captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor) { // Check if captain is present - if (!ObjectAccessor::FindPlayerInOrOutOfWorld(captainGuid)) + if (!ObjectAccessor::FindConnectedPlayer(captainGuid)) return false; // Check if arena team name is already taken @@ -54,13 +54,12 @@ bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& teamNa EmblemColor = emblemColor; BorderStyle = borderStyle; BorderColor = borderColor; - uint32 captainLowGuid = GUID_LOPART(captainGuid); // Save arena team to db PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM); stmt->setUInt32(0, TeamId); stmt->setString(1, TeamName); - stmt->setUInt32(2, captainLowGuid); + stmt->setUInt32(2, captainGuid.GetCounter()); stmt->setUInt8(3, Type); stmt->setUInt16(4, Stats.Rating); stmt->setUInt32(5, BackgroundColor); @@ -75,7 +74,7 @@ bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& teamNa return true; } -bool ArenaTeam::AddMember(uint64 playerGuid) +bool ArenaTeam::AddMember(ObjectGuid playerGuid) { std::string playerName; uint8 playerClass; @@ -85,7 +84,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid) return false; // xinef: Get player name and class from player storage or global data storage - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(playerGuid); + Player* player = ObjectAccessor::FindConnectedPlayer(playerGuid); if (player) { playerClass = player->getClass(); @@ -93,7 +92,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid) } else { - GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(playerGuid)); + GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(playerGuid.GetCounter()); if (!playerData) return false; @@ -105,9 +104,9 @@ bool ArenaTeam::AddMember(uint64 playerGuid) return false; // Check if player is already in a similar arena team - if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromStorage(GUID_LOPART(playerGuid), GetSlot()) != 0) + if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromStorage(playerGuid.GetCounter(), GetSlot()) != 0) { - LOG_ERROR("server", "Arena: Player %s (guid: %u) already has an arena team of type %u", playerName.c_str(), GUID_LOPART(playerGuid), GetType()); + LOG_ERROR("server", "Arena: Player %s (%s) already has an arena team of type %u", playerName.c_str(), playerGuid.ToString().c_str(), GetType()); return false; } @@ -122,7 +121,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid) // xinef: zomg! sync query // Try to get player's match maker rating from db and fall back to config setting if not found PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MATCH_MAKER_RATING); - stmt->setUInt32(0, GUID_LOPART(playerGuid)); + stmt->setUInt32(0, playerGuid.GetCounter()); stmt->setUInt8(1, GetSlot()); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -158,12 +157,12 @@ bool ArenaTeam::AddMember(uint64 playerGuid) newMember.MaxMMR = maxMMR; Members.push_back(newMember); - sWorld->UpdateGlobalPlayerArenaTeam(GUID_LOPART(playerGuid), GetSlot(), GetId()); + sWorld->UpdateGlobalPlayerArenaTeam(playerGuid.GetCounter(), GetSlot(), GetId()); // Save player's arena team membership to db stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM_MEMBER); stmt->setUInt32(0, TeamId); - stmt->setUInt32(1, GUID_LOPART(playerGuid)); + stmt->setUInt32(1, playerGuid.GetCounter()); CharacterDatabase.Execute(stmt); // Inform player if online @@ -189,7 +188,7 @@ bool ArenaTeam::LoadArenaTeamFromDB(QueryResult result) TeamId = fields[0].GetUInt32(); TeamName = fields[1].GetString(); - CaptainGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER); + CaptainGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32()); Type = fields[3].GetUInt8(); BackgroundColor = fields[4].GetUInt32(); EmblemStyle = fields[5].GetUInt8(); @@ -228,7 +227,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result) break; ArenaTeamMember newMember; - newMember.Guid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER); + newMember.Guid = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32()); newMember.WeekGames = fields[2].GetUInt16(); newMember.WeekWins = fields[3].GetUInt16(); newMember.SeasonGames = fields[4].GetUInt16(); @@ -242,7 +241,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result) // Delete member if character information is missing if (fields[6].GetString().empty()) { - LOG_ERROR("sql.sql", "ArenaTeam %u has member with empty name - probably player %u doesn't exist, deleting him from memberlist!", arenaTeamId, GUID_LOPART(newMember.Guid)); + LOG_ERROR("sql.sql", "ArenaTeam %u has member with empty name - probably player %s doesn't exist, deleting him from memberlist!", arenaTeamId, newMember.Guid.ToString().c_str()); this->DelMember(newMember.Guid, true); continue; } @@ -253,7 +252,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result) // Put the player in the team Members.push_back(newMember); - sWorld->UpdateGlobalPlayerArenaTeam(GUID_LOPART(newMember.Guid), GetSlot(), GetId()); + sWorld->UpdateGlobalPlayerArenaTeam(newMember.Guid.GetCounter(), GetSlot(), GetId()); } while (result->NextRow()); if (Empty() || !captainPresentInTeam) @@ -281,10 +280,10 @@ bool ArenaTeam::SetName(std::string const& name) return true; } -void ArenaTeam::SetCaptain(uint64 guid) +void ArenaTeam::SetCaptain(ObjectGuid guid) { // Disable remove/promote buttons - Player* oldCaptain = ObjectAccessor::FindPlayerInOrOutOfWorld(GetCaptain()); + Player* oldCaptain = ObjectAccessor::FindConnectedPlayer(GetCaptain()); if (oldCaptain) oldCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1); @@ -293,33 +292,33 @@ void ArenaTeam::SetCaptain(uint64 guid) // Update database PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ARENA_TEAM_CAPTAIN); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt32(1, GetId()); CharacterDatabase.Execute(stmt); // Enable remove/promote buttons - if (Player* newCaptain = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* newCaptain = ObjectAccessor::FindConnectedPlayer(guid)) { newCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 0); /*if (oldCaptain) { - LOG_DEBUG("bg.battleground", "Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u] [Type: %u].", - oldCaptain->GetName().c_str(), oldCaptain->GetGUIDLow(), newCaptain->GetName().c_str(), - newCaptain->GetGUIDLow(), GetId(), GetType()); + LOG_DEBUG("bg.battleground", "Player: %s [%s] promoted player: %s [%s] to leader of arena team [Id: %u] [Type: %u].", + oldCaptain->GetName().c_str(), oldCaptain->GetGUID().ToString().c_str(), newCaptain->GetName().c_str(), + newCaptain->GetGUID().ToString().c_str(), GetId(), GetType()); }*/ } } -void ArenaTeam::DelMember(uint64 guid, bool cleanDb) +void ArenaTeam::DelMember(ObjectGuid guid, bool cleanDb) { - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* player = ObjectAccessor::FindConnectedPlayer(guid); Group* group = (player && player->GetGroup()) ? player->GetGroup() : nullptr; // Remove member from team for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr) { // Remove queues of members - if (Player* playerMember = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid)) + if (Player* playerMember = ObjectAccessor::FindConnectedPlayer(itr->Guid)) { if (group && playerMember->GetGroup() && group->GetGUID() == playerMember->GetGroup()->GetGUID()) { @@ -345,7 +344,7 @@ void ArenaTeam::DelMember(uint64 guid, bool cleanDb) if (itr->Guid == guid) { Members.erase(itr); - sWorld->UpdateGlobalPlayerArenaTeam(GUID_LOPART(guid), GetSlot(), 0); + sWorld->UpdateGlobalPlayerArenaTeam(guid.GetCounter(), GetSlot(), 0); break; } } @@ -364,7 +363,7 @@ void ArenaTeam::DelMember(uint64 guid, bool cleanDb) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM_MEMBER); stmt->setUInt32(0, GetId()); - stmt->setUInt32(1, GUID_LOPART(guid)); + stmt->setUInt32(1, guid.GetCounter()); CharacterDatabase.Execute(stmt); } } @@ -378,7 +377,7 @@ void ArenaTeam::Disband(WorldSession* session) // Broadcast update if (session) { - BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName(), GetName(), ""); + BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, ObjectGuid::Empty, 2, session->GetPlayerName(), GetName(), ""); } // Update database @@ -436,12 +435,12 @@ void ArenaTeam::Roster(WorldSession* session) for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) { - player = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid); + player = ObjectAccessor::FindConnectedPlayer(itr->Guid); - data << uint64(itr->Guid); // guid - data << uint8((player ? 1 : 0)); // online flag + data << itr->Guid; // guid + data << uint8((player ? 1 : 0)); // online flag tempName = ""; - sObjectMgr->GetPlayerNameByGUID(itr->Guid, tempName); + sObjectMgr->GetPlayerNameByGUID(itr->Guid.GetCounter(), tempName); data << tempName; // member name data << uint32((itr->Guid == GetCaptain() ? 0 : 1));// captain flag 0 captain 1 member data << uint8((player ? player->getLevel() : 0)); // unknown, level? @@ -499,18 +498,18 @@ void ArenaTeam::NotifyStatsChanged() // This is called after a rated match ended // Updates arena team stats for every member of the team (not only the ones who participated!) for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(itr->Guid)) SendStats(player->GetSession()); } -void ArenaTeam::Inspect(WorldSession* session, uint64 guid) +void ArenaTeam::Inspect(WorldSession* session, ObjectGuid guid) { ArenaTeamMember* member = GetMember(guid); if (!member || GetSlot() >= MAX_ARENA_SLOT) return; WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8 + 1 + 4 * 6); - data << uint64(guid); // player guid + data << guid; // player guid data << uint8(GetSlot()); // slot (0...2) data << uint32(GetId()); // arena team id data << uint32(Stats.Rating); // rating @@ -556,11 +555,11 @@ void ArenaTeamMember::ModifyMatchmakerRating(int32 mod, uint32 /*slot*/) void ArenaTeam::BroadcastPacket(WorldPacket* packet) { for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(itr->Guid)) player->GetSession()->SendPacket(packet); } -void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3) +void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3) { WorldPacket data(SMSG_ARENA_TEAM_EVENT, 1 + 1 + 1); data << uint8(event); @@ -584,7 +583,7 @@ void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCoun } if (guid) - data << uint64(guid); + data << guid; BroadcastPacket(&data); @@ -602,7 +601,7 @@ void ArenaTeam::MassInviteToEvent(WorldSession* session) { if (itr->Guid != session->GetPlayer()->GetGUID()) { - data.appendPackGUID(itr->Guid); + data << itr->Guid.WriteAsPacked(); data << uint8(0); // unk } } @@ -635,7 +634,7 @@ uint8 ArenaTeam::GetSlotByType(uint32 type) return 0xFF; } -bool ArenaTeam::IsMember(uint64 guid) const +bool ArenaTeam::IsMember(ObjectGuid guid) const { for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) if (itr->Guid == guid) @@ -684,7 +683,7 @@ uint32 ArenaTeam::GetAverageMMR(Group* group) const for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) { // Skip if player is not online - if (!ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid)) + if (!ObjectAccessor::FindConnectedPlayer(itr->Guid)) continue; // Skip if player is not member of group @@ -778,7 +777,7 @@ void ArenaTeam::FinishGame(int32 mod, const Map* bgMap) // Check if rating related achivements are met for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr) - if (Player* member = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid)) + if (Player* member = ObjectAccessor::FindConnectedPlayer(itr->Guid)) if (member->FindMap() == bgMap) member->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING, Stats.Rating, Type); } @@ -892,7 +891,7 @@ void ArenaTeam::MemberWon(Player* player, uint32 againstMatchmakerRating, int32 } } -void ArenaTeam::UpdateArenaPointsHelper(std::map<uint32, uint32>& playerPoints) +void ArenaTeam::UpdateArenaPointsHelper(std::map<ObjectGuid, uint32>& playerPoints) { // Called after a match has ended and the stats are already modified // Helper function for arena point distribution (this way, when distributing, no actual calculation is required, just a few comparisons) @@ -910,15 +909,15 @@ void ArenaTeam::UpdateArenaPointsHelper(std::map<uint32, uint32>& playerPoints) if (itr->WeekGames >= requiredGames) pointsToAdd = GetPoints(itr->PersonalRating); - std::map<uint32, uint32>::iterator plr_itr = playerPoints.find(GUID_LOPART(itr->Guid)); + std::map<ObjectGuid, uint32>::iterator plr_itr = playerPoints.find(itr->Guid); if (plr_itr != playerPoints.end()) { // Check if there is already more points if (plr_itr->second < pointsToAdd) - playerPoints[GUID_LOPART(itr->Guid)] = pointsToAdd; + playerPoints[itr->Guid] = pointsToAdd; } else - playerPoints[GUID_LOPART(itr->Guid)] = pointsToAdd; + playerPoints[itr->Guid] = pointsToAdd; } } @@ -951,11 +950,11 @@ void ArenaTeam::SaveToDB() stmt->setUInt16(3, itr->SeasonGames); stmt->setUInt16(4, itr->SeasonWins); stmt->setUInt32(5, GetId()); - stmt->setUInt32(6, GUID_LOPART(itr->Guid)); + stmt->setUInt32(6, itr->Guid.GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHARACTER_ARENA_STATS); - stmt->setUInt32(0, GUID_LOPART(itr->Guid)); + stmt->setUInt32(0, itr->Guid.GetCounter()); stmt->setUInt8(1, GetSlot()); stmt->setUInt16(2, itr->MatchMakerRating); stmt->setUInt16(3, itr->MaxMMR); @@ -994,7 +993,7 @@ ArenaTeamMember* ArenaTeam::GetMember(const std::string& name) return GetMember(sObjectMgr->GetPlayerGUIDByName(name)); } -ArenaTeamMember* ArenaTeam::GetMember(uint64 guid) +ArenaTeamMember* ArenaTeam::GetMember(ObjectGuid guid) { for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr) if (itr->Guid == guid) diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h index 2fd3c9d5bd..6d6c72519a 100644 --- a/src/server/game/Battlegrounds/ArenaTeam.h +++ b/src/server/game/Battlegrounds/ArenaTeam.h @@ -95,7 +95,7 @@ enum ArenaSlot struct ArenaTeamMember { - uint64 Guid; + ObjectGuid Guid; std::string Name; uint8 Class; uint16 WeekGames; @@ -128,7 +128,7 @@ public: ArenaTeam(); ~ArenaTeam(); - bool Create(uint64 captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor); + bool Create(ObjectGuid captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor); void Disband(WorldSession* session); void Disband(); @@ -139,7 +139,7 @@ public: [[nodiscard]] uint8 GetSlot() const { return GetSlotByType(GetType()); } static uint8 GetSlotByType(uint32 type); static uint8 GetReqPlayersForType(uint32 type); - [[nodiscard]] uint64 GetCaptain() const { return CaptainGuid; } + [[nodiscard]] ObjectGuid GetCaptain() const { return CaptainGuid; } [[nodiscard]] std::string const& GetName() const { return TeamName; } [[nodiscard]] const ArenaTeamStats& GetStats() const { return Stats; } void SetArenaTeamStats(ArenaTeamStats& stats) { Stats = stats; } @@ -147,22 +147,22 @@ public: [[nodiscard]] uint32 GetRating() const { return Stats.Rating; } uint32 GetAverageMMR(Group* group) const; - void SetCaptain(uint64 guid); + void SetCaptain(ObjectGuid guid); bool SetName(std::string const& name); - bool AddMember(uint64 playerGuid); + bool AddMember(ObjectGuid playerGuid); - // Shouldn't be uint64 ed, because than can reference guid from members on Disband + // Shouldn't be ObjectGuid, because than can reference guid from members on Disband // and this method removes given record from list. So invalid reference can happen. - void DelMember(uint64 guid, bool cleanDb); + void DelMember(ObjectGuid guid, bool cleanDb); [[nodiscard]] size_t GetMembersSize() const { return Members.size(); } [[nodiscard]] bool Empty() const { return Members.empty(); } MemberList::iterator m_membersBegin() { return Members.begin(); } MemberList::iterator m_membersEnd() { return Members.end(); } MemberList& GetMembers() { return Members; } - [[nodiscard]] bool IsMember(uint64 guid) const; + [[nodiscard]] bool IsMember(ObjectGuid guid) const; - ArenaTeamMember* GetMember(uint64 guid); + ArenaTeamMember* GetMember(ObjectGuid guid); ArenaTeamMember* GetMember(std::string const& name); [[nodiscard]] bool IsFighting() const; @@ -173,7 +173,7 @@ public: void SaveToDB(); void BroadcastPacket(WorldPacket* packet); - void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3); + void BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3); void NotifyStatsChanged(); void MassInviteToEvent(WorldSession* session); @@ -181,7 +181,7 @@ public: void Roster(WorldSession* session); void Query(WorldSession* session); void SendStats(WorldSession* session); - void Inspect(WorldSession* session, uint64 guid); + void Inspect(WorldSession* session, ObjectGuid guid); uint32 GetPoints(uint32 MemberRating); int32 GetMatchmakerRatingMod(uint32 ownRating, uint32 opponentRating, bool won); @@ -192,7 +192,7 @@ public: int32 LostAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32& rating_change, const Map* bgMap); void MemberLost(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12); - void UpdateArenaPointsHelper(std::map<uint32, uint32>& PlayerPoints); + void UpdateArenaPointsHelper(std::map<ObjectGuid, uint32>& PlayerPoints); void FinishWeek(); void FinishGame(int32 mod, const Map* bgMap); @@ -207,7 +207,7 @@ protected: uint32 TeamId; uint8 Type; std::string TeamName; - uint64 CaptainGuid; + ObjectGuid CaptainGuid; uint32 BackgroundColor; // ARGB format uint8 EmblemStyle; // icon id diff --git a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp index 12f32698b2..87cb424e46 100644 --- a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp +++ b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp @@ -82,7 +82,7 @@ ArenaTeam* ArenaTeamMgr::GetArenaTeamByName(std::string const& arenaTeamName, co return nullptr; } -ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(uint64 guid) const +ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(ObjectGuid guid) const { for (ArenaTeamContainer::const_iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr) { @@ -94,7 +94,7 @@ ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(uint64 guid) const return nullptr; } -ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(uint64 guid, const uint32 type) const +ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(ObjectGuid guid, const uint32 type) const { for (ArenaTeamContainer::const_iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr) { @@ -191,7 +191,7 @@ void ArenaTeamMgr::DistributeArenaPoints() sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_START); // Temporary structure for storing maximum points to add values for all players - std::map<uint32, uint32> PlayerPoints; + std::map<ObjectGuid, uint32> PlayerPoints; // At first update all points for all team members for (ArenaTeamContainer::iterator teamItr = GetArenaTeamMapBegin(); teamItr != GetArenaTeamMapEnd(); ++teamItr) @@ -206,16 +206,16 @@ void ArenaTeamMgr::DistributeArenaPoints() PreparedStatement* stmt; // Cycle that gives points to all players - for (std::map<uint32, uint32>::iterator playerItr = PlayerPoints.begin(); playerItr != PlayerPoints.end(); ++playerItr) + for (std::map<ObjectGuid, uint32>::iterator playerItr = PlayerPoints.begin(); playerItr != PlayerPoints.end(); ++playerItr) { // Add points to player if online - if (Player* player = HashMapHolder<Player>::Find(playerItr->first)) + if (Player* player = ObjectAccessor::FindPlayer(playerItr->first)) player->ModifyArenaPoints(playerItr->second, &trans); else // Update database { stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ARENA_POINTS); stmt->setUInt32(0, playerItr->second); - stmt->setUInt32(1, playerItr->first); + stmt->setUInt32(1, playerItr->first.GetCounter()); trans->Append(stmt); } } diff --git a/src/server/game/Battlegrounds/ArenaTeamMgr.h b/src/server/game/Battlegrounds/ArenaTeamMgr.h index b2363b9b81..9af6b4a6d7 100644 --- a/src/server/game/Battlegrounds/ArenaTeamMgr.h +++ b/src/server/game/Battlegrounds/ArenaTeamMgr.h @@ -21,9 +21,9 @@ public: ArenaTeam* GetArenaTeamById(uint32 arenaTeamId) const; ArenaTeam* GetArenaTeamByName(std::string const& arenaTeamName) const; - ArenaTeam* GetArenaTeamByCaptain(uint64 guid) const; + ArenaTeam* GetArenaTeamByCaptain(ObjectGuid guid) const; ArenaTeam* GetArenaTeamByName(std::string const& arenaTeamName, const uint32 type) const; - ArenaTeam* GetArenaTeamByCaptain(uint64 guid, const uint32 type) const; + ArenaTeam* GetArenaTeamByCaptain(ObjectGuid guid, const uint32 type) const; void LoadArenaTeams(); void AddArenaTeam(ArenaTeam* arenaTeam); diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 3d233eef70..18b6436caa 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -328,12 +328,12 @@ inline void Battleground::_ProcessResurrect(uint32 diff) { if (GetReviveQueueSize()) { - for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr) + for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr) { Creature* sh = nullptr; - for (std::vector<uint64>::const_iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2) + for (ObjectGuid const guid : itr->second) { - Player* player = ObjectAccessor::FindPlayer(*itr2); + Player* player = ObjectAccessor::FindPlayer(guid); if (!player) continue; @@ -348,9 +348,10 @@ inline void Battleground::_ProcessResurrect(uint32 diff) // Resurrection visual player->CastSpell(player, SPELL_RESURRECTION_VISUAL, true); - m_ResurrectQueue.push_back(*itr2); + m_ResurrectQueue.push_back(guid); } - (itr->second).clear(); + + itr->second.clear(); } m_ReviveQueue.clear(); @@ -362,15 +363,15 @@ inline void Battleground::_ProcessResurrect(uint32 diff) } else if (m_LastResurrectTime > 500) // Resurrect players only half a second later, to see spirit heal effect on NPC { - for (std::vector<uint64>::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr) + for (ObjectGuid const guid : m_ResurrectQueue) { - Player* player = ObjectAccessor::FindPlayer(*itr); + Player* player = ObjectAccessor::FindPlayer(guid); if (!player) continue; player->ResurrectPlayer(1.0f); player->CastSpell(player, 6962, true); player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true); - sObjectAccessor->ConvertCorpseForPlayer(*itr); + player->SpawnCorpseBones(false); } m_ResurrectQueue.clear(); } @@ -557,7 +558,7 @@ inline void Battleground::_ProcessJoin(uint32 diff) if (GetStatus() == STATUS_IN_PROGRESS) { for (ToBeTeleportedMap::const_iterator itr = m_ToBeTeleported.begin(); itr != m_ToBeTeleported.end(); ++itr) - if (Player* p = ObjectAccessor::GetObjectInOrOutOfWorld(itr->first, (Player*)nullptr)) + if (Player* p = ObjectAccessor::FindConnectedPlayer(itr->first)) if (Player* t = ObjectAccessor::FindPlayer(itr->second)) { if (!t->FindMap() || t->FindMap() != GetBgMap()) @@ -566,7 +567,7 @@ inline void Battleground::_ProcessJoin(uint32 diff) p->SetSummonPoint(t->GetMapId(), t->GetPositionX(), t->GetPositionY(), t->GetPositionZ(), 15, true); WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); - data << uint64(t->GetGUID()); + data << t->GetGUID(); data << uint32(t->GetZoneId()); data << uint32(15 * IN_MILLISECONDS); p->GetSession()->SendPacket(&data); @@ -1019,7 +1020,7 @@ void Battleground::EndBattleground(TeamId winnerTeamId) BattlegroundScoreMap::const_iterator score = PlayerScores.find(player->GetGUID()); stmt->setUInt32(0, battlegroundId); - stmt->setUInt32(1, player->GetGUIDLow()); + stmt->setUInt32(1, player->GetGUID().GetCounter()); stmt->setBool(2, bgTeamId == winnerTeamId); stmt->setUInt32(3, score->second->GetKillingBlows()); stmt->setUInt32(4, score->second->GetDeaths()); @@ -1205,7 +1206,7 @@ void Battleground::AddPlayer(Player* player) // score struct must be created in inherited class - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); TeamId teamId = player->GetBgTeamId(); // Add to list/maps @@ -1282,7 +1283,7 @@ void Battleground::AddOrSetPlayerToCorrectBgGroup(Player* player, TeamId teamId) return; } - uint64 playerGuid = player->GetGUID(); + ObjectGuid playerGuid = player->GetGUID(); Group* group = GetBgRaid(teamId); if (!group) // first player joined { @@ -1380,7 +1381,7 @@ void Battleground::ReadyMarkerClicked(Player* p) { if (!isArena() || GetStatus() >= STATUS_IN_PROGRESS || GetStartDelayTime() <= BG_START_DELAY_15S || (m_Events & BG_STARTING_EVENT_3) || p->IsSpectator()) return; - readyMarkerClickedSet.insert(p->GetGUIDLow()); + readyMarkerClickedSet.insert(p->GetGUID()); uint32 count = readyMarkerClickedSet.size(); uint32 req = ArenaTeam::GetReqPlayersForType(GetArenaType()); p->GetSession()->SendNotification("You are marked as ready %u/%u", count, req); @@ -1453,7 +1454,7 @@ void Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value, } } -void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid) +void Battleground::AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid) { m_ReviveQueue[npc_guid].push_back(player_guid); @@ -1466,26 +1467,26 @@ void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid void Battleground::RemovePlayerFromResurrectQueue(Player* player) { - for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr) - for (std::vector<uint64>::iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2) + for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr) + for (GuidVector::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) if (*itr2 == player->GetGUID()) { - (itr->second).erase(itr2); + itr->second.erase(itr2); player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT); return; } } -void Battleground::RelocateDeadPlayers(uint64 queueIndex) +void Battleground::RelocateDeadPlayers(ObjectGuid queueIndex) { // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard - std::vector<uint64>& ghostList = m_ReviveQueue[queueIndex]; + GuidVector& ghostList = m_ReviveQueue[queueIndex]; if (!ghostList.empty()) { GraveyardStruct const* closestGrave = nullptr; - for (std::vector<uint64>::const_iterator itr = ghostList.begin(); itr != ghostList.end(); ++itr) + for (ObjectGuid const guid : ghostList) { - Player* player = ObjectAccessor::FindPlayer(*itr); + Player* player = ObjectAccessor::FindPlayer(guid); if (!player) continue; @@ -1495,6 +1496,7 @@ void Battleground::RelocateDeadPlayers(uint64 queueIndex) if (closestGrave) player->TeleportTo(GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation()); } + ghostList.clear(); } } @@ -1511,7 +1513,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float // and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created // So we must create it specific for this instance GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject(); - if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, GetBgMap(), + if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, GetBgMap(), PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, goState)) { LOG_ERROR("sql.sql", "Battleground::AddObject: cannot create gameobject (entry: %u) for BG (map: %u, instance id: %u)!", @@ -1522,11 +1524,11 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float return false; } /* - uint32 guid = go->GetGUIDLow(); + ObjectGuid::LowType spawnId = go->GetSpawnId(); // without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata // iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed - GameObjectData& data = sObjectMgr->NewGOData(guid); + GameObjectData& data = sObjectMgr->NewGOData(spawnId); data.id = entry; data.mapid = GetMapId(); @@ -1567,8 +1569,8 @@ void Battleground::DoorClose(uint32 type) } } else - LOG_ERROR("server", "Battleground::DoorClose: door gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID); + LOG_ERROR("server", "Battleground::DoorClose: door gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!", + type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID); } void Battleground::DoorOpen(uint32 type) @@ -1579,16 +1581,16 @@ void Battleground::DoorOpen(uint32 type) obj->SetGoState(GO_STATE_ACTIVE); } else - LOG_ERROR("server", "Battleground::DoorOpen: door gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID); + LOG_ERROR("server", "Battleground::DoorOpen: door gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!", + type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID); } GameObject* Battleground::GetBGObject(uint32 type) { GameObject* obj = GetBgMap()->GetGameObject(BgObjects[type]); if (!obj) - LOG_ERROR("server", "Battleground::GetBGObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID); + LOG_ERROR("server", "Battleground::GetBGObject: gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!", + type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID); return obj; } @@ -1596,8 +1598,8 @@ Creature* Battleground::GetBGCreature(uint32 type) { Creature* creature = GetBgMap()->GetCreature(BgCreatures[type]); if (!creature) - LOG_ERROR("server", "Battleground::GetBGCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID); + LOG_ERROR("server", "Battleground::GetBGCreature: creature (type: %u, %s) not found for BG (map: %u, instance id: %u)!", + type, BgCreatures[type].ToString().c_str(), m_MapId, m_InstanceID); return creature; } @@ -1639,7 +1641,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, float x, float y, } Creature* creature = new Creature(); - if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o)) + if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o)) { LOG_ERROR("server", "Battleground::AddCreature: cannot create creature (entry: %u) for BG (map: %u, instance id: %u)!", entry, m_MapId, m_InstanceID); @@ -1687,13 +1689,14 @@ bool Battleground::DelCreature(uint32 type) if (Creature* creature = GetBgMap()->GetCreature(BgCreatures[type])) { creature->AddObjectToRemoveList(); - BgCreatures[type] = 0; + BgCreatures[type].Clear(); return true; } - LOG_ERROR("server", "Battleground::DelCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID); - BgCreatures[type] = 0; + LOG_ERROR("server", "Battleground::DelCreature: creature (type: %u, %s) not found for BG (map: %u, instance id: %u)!", + type, BgCreatures[type].ToString().c_str(), m_MapId, m_InstanceID); + + BgCreatures[type].Clear(); return false; } @@ -1706,12 +1709,14 @@ bool Battleground::DelObject(uint32 type) { obj->SetRespawnTime(0); // not save respawn time obj->Delete(); - BgObjects[type] = 0; + BgObjects[type].Clear(); return true; } - LOG_ERROR("server", "Battleground::DelObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID); - BgObjects[type] = 0; + + LOG_ERROR("server", "Battleground::DelObject: gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!", + type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID); + + BgObjects[type].Clear(); return false; } @@ -1722,7 +1727,7 @@ bool Battleground::AddSpiritGuide(uint32 type, float x, float y, float z, float if (Creature* creature = AddCreature(entry, type, x, y, z, o)) { creature->setDeathState(DEAD); - creature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, creature->GetGUID()); + creature->SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, creature->GetGUID()); // aura // TODO: Fix display here // creature->SetVisibleAura(0, SPELL_SPIRIT_HEAL_CHANNEL); @@ -1878,7 +1883,7 @@ TeamId Battleground::GetOtherTeamId(TeamId teamId) return teamId != TEAM_NEUTRAL ? (teamId == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE) : TEAM_NEUTRAL; } -bool Battleground::IsPlayerInBattleground(uint64 guid) const +bool Battleground::IsPlayerInBattleground(ObjectGuid guid) const { BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid); if (itr != m_Players.end()) @@ -1916,13 +1921,15 @@ void Battleground::SetHoliday(bool is_holiday) m_HonorMode = is_holiday ? BG_HOLIDAY : BG_NORMAL; } -int32 Battleground::GetObjectType(uint64 guid) +int32 Battleground::GetObjectType(ObjectGuid guid) { for (uint32 i = 0; i < BgObjects.size(); ++i) if (BgObjects[i] == guid) return i; - LOG_ERROR("server", "Battleground::GetObjectType: player used gameobject (GUID: %u) which is not in internal data for BG (map: %u, instance id: %u), cheating?", - GUID_LOPART(guid), m_MapId, m_InstanceID); + + LOG_ERROR("server", "Battleground::GetObjectType: player used gameobject (%s) which is not in internal data for BG (map: %u, instance id: %u), cheating?", + guid.ToString().c_str(), m_MapId, m_InstanceID); + return -1; } diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 7288301bff..8d772846af 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -274,7 +274,7 @@ class ArenaLogEntryData { public: ArenaLogEntryData() {} - void Fill(const char* name, uint32 guid, uint32 acc, uint32 arenaTeamId, std::string ip) + void Fill(const char* name, ObjectGuid::LowType guid, uint32 acc, uint32 arenaTeamId, std::string ip) { Name = std::string(name); Guid = guid; @@ -284,7 +284,7 @@ public: } std::string Name; - uint32 Guid{0}; + ObjectGuid::LowType Guid{0}; uint32 Acc; uint32 ArenaTeamId{0}; std::string IP; @@ -400,28 +400,28 @@ public: [[nodiscard]] uint32 GetMaxFreeSlots() const; typedef std::set<Player*> SpectatorList; - typedef std::map<uint64, uint64> ToBeTeleportedMap; + typedef std::map<ObjectGuid, ObjectGuid> ToBeTeleportedMap; void AddSpectator(Player* p) { m_Spectators.insert(p); } void RemoveSpectator(Player* p) { m_Spectators.erase(p); } bool HaveSpectators() { return !m_Spectators.empty(); } [[nodiscard]] const SpectatorList& GetSpectators() const { return m_Spectators; } - void AddToBeTeleported(uint64 spectator, uint64 participant) { m_ToBeTeleported[spectator] = participant; } - void RemoveToBeTeleported(uint64 spectator) { ToBeTeleportedMap::iterator itr = m_ToBeTeleported.find(spectator); if (itr != m_ToBeTeleported.end()) m_ToBeTeleported.erase(itr); } + void AddToBeTeleported(ObjectGuid spectator, ObjectGuid participant) { m_ToBeTeleported[spectator] = participant; } + void RemoveToBeTeleported(ObjectGuid spectator) { ToBeTeleportedMap::iterator itr = m_ToBeTeleported.find(spectator); if (itr != m_ToBeTeleported.end()) m_ToBeTeleported.erase(itr); } void SpectatorsSendPacket(WorldPacket& data); [[nodiscard]] bool isArena() const { return m_IsArena; } [[nodiscard]] bool isBattleground() const { return !m_IsArena; } [[nodiscard]] bool isRated() const { return m_IsRated; } - typedef std::map<uint64, Player*> BattlegroundPlayerMap; + typedef std::map<ObjectGuid, Player*> BattlegroundPlayerMap; [[nodiscard]] BattlegroundPlayerMap const& GetPlayers() const { return m_Players; } [[nodiscard]] uint32 GetPlayersSize() const { return m_Players.size(); } void ReadyMarkerClicked(Player* p); // pussywizard - std::set<uint32> readyMarkerClickedSet; // pussywizard + GuidSet readyMarkerClickedSet; // pussywizard - typedef std::map<uint64, BattlegroundScore*> BattlegroundScoreMap; - typedef std::map<uint64, ArenaLogEntryData> ArenaLogEntryDataMap;// pussywizard + typedef std::map<ObjectGuid, BattlegroundScore*> BattlegroundScoreMap; + typedef std::map<ObjectGuid, ArenaLogEntryData> ArenaLogEntryDataMap;// pussywizard ArenaLogEntryDataMap ArenaLogEntries; // pussywizard [[nodiscard]] BattlegroundScoreMap::const_iterator GetPlayerScoresBegin() const { return PlayerScores.begin(); } [[nodiscard]] BattlegroundScoreMap::const_iterator GetPlayerScoresEnd() const { return PlayerScores.end(); } @@ -429,11 +429,11 @@ public: [[nodiscard]] uint32 GetReviveQueueSize() const { return m_ReviveQueue.size(); } - void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid); + void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid); void RemovePlayerFromResurrectQueue(Player* player); /// Relocate all players in ReviveQueue to the closest graveyard - void RelocateDeadPlayers(uint64 queueIndex); + void RelocateDeadPlayers(ObjectGuid queueIndex); void StartBattleground(); @@ -532,7 +532,7 @@ public: virtual void EventPlayerUsedGO(Player* /*player*/, GameObject* /*go*/) {} // this function can be used by spell to interact with the BG map - virtual void DoAction(uint32 /*action*/, uint64 /*var*/) {} + virtual void DoAction(uint32 /*action*/, ObjectGuid /*var*/) {} virtual void HandlePlayerResurrect(Player* /*player*/) {} @@ -550,8 +550,8 @@ public: void SetHoliday(bool is_holiday); // TODO: make this protected: - typedef std::vector<uint64> BGObjects; - typedef std::vector<uint64> BGCreatures; + typedef GuidVector BGObjects; + typedef GuidVector BGCreatures; BGObjects BgObjects; BGCreatures BgCreatures; void SpawnBGObject(uint32 type, uint32 respawntime); @@ -560,7 +560,7 @@ public: bool DelCreature(uint32 type); bool DelObject(uint32 type); bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, TeamId teamId); - int32 GetObjectType(uint64 guid); + int32 GetObjectType(ObjectGuid guid); void DoorOpen(uint32 type); void DoorClose(uint32 type); @@ -571,15 +571,15 @@ public: // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player static TeamId GetOtherTeamId(TeamId teamId); - [[nodiscard]] bool IsPlayerInBattleground(uint64 guid) const; + [[nodiscard]] bool IsPlayerInBattleground(ObjectGuid guid) const; [[nodiscard]] bool ToBeDeleted() const { return m_SetDeleteThis; } //void SetDeleteThis() { m_SetDeleteThis = true; } void RewardXPAtKill(Player* killer, Player* victim); - [[nodiscard]] virtual uint64 GetFlagPickerGUID(TeamId /*teamId*/ = TEAM_NEUTRAL) const { return 0; } - virtual void SetDroppedFlagGUID(uint64 /*guid*/, TeamId /*teamId*/ = TEAM_NEUTRAL) {} + [[nodiscard]] virtual ObjectGuid GetFlagPickerGUID(TeamId /*teamId*/ = TEAM_NEUTRAL) const { return ObjectGuid::Empty; } + virtual void SetDroppedFlagGUID(ObjectGuid /*guid*/, TeamId /*teamId*/ = TEAM_NEUTRAL) {} [[nodiscard]] uint32 GetTeamScore(TeamId teamId) const; virtual TeamId GetPrematureWinner(); @@ -637,9 +637,9 @@ protected: virtual void RemovePlayer(Player* /*player*/) {} // Player lists, those need to be accessible by inherited classes - BattlegroundPlayerMap m_Players; + BattlegroundPlayerMap m_Players; // Spirit Guide guid + Player list GUIDS - std::map<uint64, std::vector<uint64> > m_ReviveQueue; + std::map<ObjectGuid, GuidVector> m_ReviveQueue; // these are important variables used for starting messages uint8 m_Events; @@ -708,8 +708,8 @@ private: virtual void PostUpdateImpl(uint32 /* diff */) { } // Player lists - std::vector<uint64> m_ResurrectQueue; // Player GUID - std::deque<uint64> m_OfflineQueue; // Player GUID + GuidVector m_ResurrectQueue; // Player GUID + GuidDeque m_OfflineQueue; // Player GUID // Invited counters are useful for player invitation to BG - do not allow, if BG is started to one faction to have 2 more players than another faction // Invited counters will be changed only when removing already invited player from queue, removing player from battleground and inviting player to BG diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 13719e2893..93fffd16b3 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -248,11 +248,11 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg) itr2 = itr++; if (!bg->IsPlayerInBattleground(itr2->first)) { - LOG_ERROR("server", "Player " UI64FMTD " has scoreboard entry for battleground %u but is not in battleground!", itr->first, bg->GetBgTypeID()); + LOG_ERROR("server", "Player %s has scoreboard entry for battleground %u but is not in battleground!", itr->first.ToString().c_str(), bg->GetBgTypeID()); continue; } - *data << uint64(itr2->first); + *data << itr2->first; *data << uint32(itr2->second->KillingBlows); if (type == 0) { @@ -392,16 +392,16 @@ void BattlegroundMgr::BuildPlaySoundPacket(WorldPacket* data, uint32 soundid) *data << uint32(soundid); } -void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint64 guid) +void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, ObjectGuid guid) { data->Initialize(SMSG_BATTLEGROUND_PLAYER_LEFT, 8); - *data << uint64(guid); + *data << guid; } void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* player) { data->Initialize(SMSG_BATTLEGROUND_PLAYER_JOINED, 8); - *data << uint64(player->GetGUID()); + *data << player->GetGUID(); } Battleground* BattlegroundMgr::GetBattleground(uint32 instanceId) @@ -646,7 +646,7 @@ void BattlegroundMgr::InitAutomaticArenaPointDistribution() LOG_INFO("server", "AzerothCore Battleground: Automatic Arena Point Distribution initialized."); } -void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere) +void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere) { if (!player) return; @@ -659,7 +659,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid loser_kills = acore::Honor::hk_honor_at_level(player->getLevel(), float(loser_kills)); data->Initialize(SMSG_BATTLEFIELD_LIST); - *data << uint64(guid); // battlemaster guid + *data << guid; // battlemaster guid *data << uint8(fromWhere); // from where you joined *data << uint32(bgTypeId); // battleground id *data << uint8(0); // unk @@ -714,7 +714,7 @@ void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, Batt } } -void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid) +void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid) { WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12); uint32 time_ = RESURRECTION_INTERVAL - bg->GetLastResurrectTime(); // resurrect every X seconds @@ -1021,7 +1021,7 @@ void BattlegroundMgr::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, T for (auto itr : ginfo->Players) { // get the player - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(itr); + Player* player = ObjectAccessor::FindConnectedPlayer(itr); if (!player) continue; @@ -1049,7 +1049,7 @@ void BattlegroundMgr::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, T // pussywizard: if (bg->isArena() && bg->isRated()) - bg->ArenaLogEntries[player->GetGUID()].Fill(player->GetName().c_str(), player->GetGUIDLow(), player->GetSession()->GetAccountId(), ginfo->ArenaTeamId, player->GetSession()->GetRemoteAddress()); + bg->ArenaLogEntries[player->GetGUID()].Fill(player->GetName().c_str(), player->GetGUID().GetCounter(), player->GetSession()->GetAccountId(), ginfo->ArenaTeamId, player->GetSession()->GetRemoteAddress()); } } diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index 7eb9d7ae65..1f65e33b85 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -61,14 +61,14 @@ public: /* Packet Building */ void BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* player); - void BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint64 guid); - void BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere); + void BuildPlayerLeftBattlegroundPacket(WorldPacket* data, ObjectGuid guid); + void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere); void BuildGroupJoinedBattlegroundPacket(WorldPacket* data, GroupJoinBattlegroundResult result); void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value); void BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg); void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE); void BuildPlaySoundPacket(WorldPacket* data, uint32 soundid); - void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid); + void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid); /* Battlegrounds */ Battleground* GetBattleground(uint32 InstanceID); diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 9dee21b767..678f4011e7 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -18,7 +18,7 @@ #include "ScriptMgr.h" #include <unordered_map> -std::unordered_map<uint64, uint32> BGSpamProtection; +std::unordered_map<ObjectGuid, uint32> BGSpamProtection; /*********************************************************/ /*** BATTLEGROUND QUEUE SYSTEM ***/ @@ -240,11 +240,11 @@ uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo) const } //remove player from queue and from group info, if group info is empty then remove it too -void BattlegroundQueue::RemovePlayer(uint64 guid, bool sentToBg, uint32 playerQueueSlot) +void BattlegroundQueue::RemovePlayer(ObjectGuid guid, bool sentToBg, uint32 playerQueueSlot) { // pussywizard: leave queue packet if (playerQueueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) - if (Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* p = ObjectAccessor::FindConnectedPlayer(guid)) { WorldPacket data; sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, nullptr, playerQueueSlot, STATUS_NONE, 0, 0, 0, TEAM_NEUTRAL); @@ -302,7 +302,7 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool sentToBg, uint32 playerQu if (groupInfo->IsInvitedToBGInstanceGUID && groupInfo->IsRated && !sentToBg) if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(groupInfo->ArenaTeamId)) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) at->MemberLost(player, groupInfo->OpponentsMatchmakerRating); at->SaveToDB(); } @@ -321,7 +321,7 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool sentToBg, uint32 playerQu { uint32 queueSlot = PLAYER_MAX_BATTLEGROUND_QUEUES; - if (Player* plr = ObjectAccessor::FindPlayerInOrOutOfWorld(*(groupInfo->Players.begin()))) + if (Player* plr = ObjectAccessor::FindConnectedPlayer(*(groupInfo->Players.begin()))) { BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(groupInfo->BgTypeId, groupInfo->ArenaType); queueSlot = plr->GetBattlegroundQueueIndex(bgQueueTypeId); @@ -338,20 +338,20 @@ void BattlegroundQueue::AddEvent(BasicEvent* Event, uint64 e_time) m_events.AddEvent(Event, m_events.CalculateTime(e_time)); } -bool BattlegroundQueue::IsPlayerInvitedToRatedArena(uint64 pl_guid) +bool BattlegroundQueue::IsPlayerInvitedToRatedArena(ObjectGuid pl_guid) { auto qItr = m_QueuedPlayers.find(pl_guid); return qItr != m_QueuedPlayers.end() && qItr->second->IsRated && qItr->second->IsInvitedToBGInstanceGUID; } //returns true when player pl_guid is in queue and is invited to bgInstanceGuid -bool BattlegroundQueue::IsPlayerInvited(uint64 pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime) +bool BattlegroundQueue::IsPlayerInvited(ObjectGuid pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime) { auto qItr = m_QueuedPlayers.find(pl_guid); return qItr != m_QueuedPlayers.end() && qItr->second->IsInvitedToBGInstanceGUID == bgInstanceGuid && qItr->second->RemoveInviteTime == removeTime; } -bool BattlegroundQueue::GetPlayerGroupInfoData(uint64 guid, GroupQueueInfo* ginfo) +bool BattlegroundQueue::GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo) { auto qItr = m_QueuedPlayers.find(guid); if (qItr == m_QueuedPlayers.end()) @@ -1034,7 +1034,7 @@ void BattlegroundQueue::SendMessageArenaQueue(GroupQueueInfo* ginfo, bool IsJoin bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(m_PlayerGuid); + Player* player = ObjectAccessor::FindConnectedPlayer(m_PlayerGuid); // player logged off, so he is no longer in queue if (!player) @@ -1072,7 +1072,7 @@ void BGQueueInviteEvent::Abort(uint64 /*e_time*/) bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(m_PlayerGuid); + Player* player = ObjectAccessor::FindConnectedPlayer(m_PlayerGuid); // player logged off, so he is no longer in queue if (!player) @@ -1096,7 +1096,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK); - stmt->setUInt32(0, player->GetGUIDLow()); + stmt->setUInt32(0, player->GetGUID().GetCounter()); stmt->setUInt8(1, BG_DESERTION_TYPE_NO_ENTER_BUTTON); CharacterDatabase.Execute(stmt); } diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h index 4e6ec9d5fb..5b7590333c 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.h +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h @@ -17,7 +17,7 @@ struct GroupQueueInfo // stores information about the group in queue (also used when joined as solo!) { - std::set<uint64> Players; // player guid set + GuidSet Players; // player guid set TeamId teamId; // Player team (TEAM_ALLIANCE/TEAM_HORDE) TeamId RealTeamID; // Realm player team (TEAM_ALLIANCE/TEAM_HORDE) BattlegroundTypeId BgTypeId; // battleground type id @@ -63,10 +63,10 @@ public: bool CheckNormalMatch(Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers); bool CheckSkirmishForSameFaction(BattlegroundBracketId bracket_id, uint32 minPlayersPerTeam); GroupQueueInfo* AddGroup(Player* leader, Group* group, PvPDifficultyEntry const* bracketEntry, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId); - void RemovePlayer(uint64 guid, bool sentToBg, uint32 playerQueueSlot); - bool IsPlayerInvitedToRatedArena(uint64 pl_guid); - bool IsPlayerInvited(uint64 pl_guid, uint32 bgInstanceGuid, uint32 removeTime); - bool GetPlayerGroupInfoData(uint64 guid, GroupQueueInfo* ginfo); + void RemovePlayer(ObjectGuid guid, bool sentToBg, uint32 playerQueueSlot); + bool IsPlayerInvitedToRatedArena(ObjectGuid pl_guid); + bool IsPlayerInvited(ObjectGuid pl_guid, uint32 bgInstanceGuid, uint32 removeTime); + bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo); void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo); uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo) const; uint32 GetPlayersCountInGroupsQueue(BattlegroundBracketId bracketId, BattlegroundQueueGroupTypes bgqueue); @@ -77,7 +77,7 @@ public: void SetBgTypeIdAndArenaType(BattlegroundTypeId b, uint8 a) { m_bgTypeId = b; m_arenaType = ArenaType(a); } // pussywizard void AddEvent(BasicEvent* Event, uint64 e_time); - typedef std::map<uint64, GroupQueueInfo*> QueuedPlayersMap; + typedef std::map<ObjectGuid, GroupQueueInfo*> QueuedPlayersMap; QueuedPlayersMap m_QueuedPlayers; //do NOT use deque because deque.erase() invalidates ALL iterators @@ -131,7 +131,7 @@ private: class BGQueueInviteEvent : public BasicEvent { public: - BGQueueInviteEvent(uint64 pl_guid, uint32 BgInstanceGUID, BattlegroundTypeId BgTypeId, uint8 arenaType, uint32 removeTime) : + BGQueueInviteEvent(ObjectGuid pl_guid, uint32 BgInstanceGUID, BattlegroundTypeId BgTypeId, uint8 arenaType, uint32 removeTime) : m_PlayerGuid(pl_guid), m_BgInstanceGUID(BgInstanceGUID), m_BgTypeId(BgTypeId), m_ArenaType(arenaType), m_RemoveTime(removeTime) { } ~BGQueueInviteEvent() override = default; @@ -139,7 +139,7 @@ public: bool Execute(uint64 e_time, uint32 p_time) override; void Abort(uint64 e_time) override; private: - uint64 m_PlayerGuid; + ObjectGuid m_PlayerGuid; uint32 m_BgInstanceGUID; BattlegroundTypeId m_BgTypeId; uint8 m_ArenaType; @@ -154,7 +154,7 @@ private: class BGQueueRemoveEvent : public BasicEvent { public: - BGQueueRemoveEvent(uint64 pl_guid, uint32 bgInstanceGUID, BattlegroundQueueTypeId bgQueueTypeId, uint32 removeTime) + BGQueueRemoveEvent(ObjectGuid pl_guid, uint32 bgInstanceGUID, BattlegroundQueueTypeId bgQueueTypeId, uint32 removeTime) : m_PlayerGuid(pl_guid), m_BgInstanceGUID(bgInstanceGUID), m_RemoveTime(removeTime), m_BgQueueTypeId(bgQueueTypeId) {} @@ -163,7 +163,7 @@ public: bool Execute(uint64 e_time, uint32 p_time) override; void Abort(uint64 e_time) override; private: - uint64 m_PlayerGuid; + ObjectGuid m_PlayerGuid; uint32 m_BgInstanceGUID; uint32 m_RemoveTime; BattlegroundQueueTypeId m_BgQueueTypeId; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index 27ca3d7578..678256ce6d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -294,7 +294,7 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb if (_capturePointInfo[node]._state == BG_AB_NODE_STATE_NEUTRAL) { - player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0); + player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node); UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1); _capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_CONTESTED + player->GetTeamId(); _capturePointInfo[node]._ownerTeamId = TEAM_NEUTRAL; @@ -307,7 +307,7 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb { if (!_capturePointInfo[node]._captured) { - player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0); + player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node); UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1); _capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_CONTESTED + player->GetTeamId(); _capturePointInfo[node]._ownerTeamId = TEAM_NEUTRAL; @@ -327,7 +327,7 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb } else { - player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0); + player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node); UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1); NodeDeoccupied(node); // before setting team owner to neutral @@ -379,14 +379,14 @@ bool BattlegroundAB::SetupBattleground() AddSpiritGuide(BG_AB_SPIRIT_HORDE, BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][0], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][1], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][2], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][3], TEAM_HORDE); for (uint32 i = BG_AB_OBJECT_BANNER_NEUTRAL; i < BG_AB_OBJECT_MAX; ++i) - if (BgObjects[i] == 0) + if (!BgObjects[i]) { LOG_ERROR("sql.sql", "BatteGroundAB: Failed to spawn some object Battleground not created!"); return false; } for (uint32 i = BG_AB_SPIRIT_ALIANCE; i <= BG_AB_SPIRIT_HORDE; ++i) - if (BgCreatures[i] == 0) + if (!BgCreatures[i]) { LOG_ERROR("sql.sql", "BatteGroundAB: Failed to spawn spirit guides Battleground not created!"); return false; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index c042ccfe37..ffc7933a6d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -325,7 +325,7 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type) if (!isStatic && ((cinfoid >= AV_NPC_A_GRAVEDEFENSE0 && cinfoid <= AV_NPC_A_GRAVEDEFENSE3) || (cinfoid >= AV_NPC_H_GRAVEDEFENSE0 && cinfoid <= AV_NPC_H_GRAVEDEFENSE3))) { - CreatureData& data = sObjectMgr->NewOrExistCreatureData(creature->GetDBTableGUIDLow()); + CreatureData& data = sObjectMgr->NewOrExistCreatureData(creature->GetSpawnId()); data.wander_distance = 5; } //else wander_distance will be 15, so creatures move maximum=10 diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index e7f22df2fd..37097f8835 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -28,8 +28,6 @@ BattlegroundEY::BattlegroundEY() _honorTics = 0; _ownedPointsCount[TEAM_ALLIANCE] = 0; _ownedPointsCount[TEAM_HORDE] = 0; - _flagKeeperGUID = 0; - _droppedFlagGUID = 0; _flagState = BG_EY_FLAG_STATE_ON_BASE; _flagCapturedObject = 0; @@ -318,14 +316,14 @@ bool BattlegroundEY::SetupBattleground() AddSpiritGuide(BG_EY_SPIRIT_MAIN_HORDE, sg->x, sg->y, sg->z, 3.193953f, TEAM_HORDE); for (uint32 i = BG_EY_OBJECT_DOOR_A; i < BG_EY_OBJECT_MAX; ++i) - if (BgObjects[i] == 0) + if (!BgObjects[i]) { LOG_ERROR("sql.sql", "BatteGroundEY: Failed to spawn some object Battleground not created!"); return false; } for (uint32 i = BG_EY_SPIRIT_MAIN_ALLIANCE; i <= BG_EY_SPIRIT_MAIN_HORDE; ++i) - if (BgCreatures[i] == 0) + if (!BgCreatures[i]) { LOG_ERROR("sql.sql", "BatteGroundEY: Failed to spawn spirit guides Battleground not created!"); return false; @@ -343,8 +341,8 @@ void BattlegroundEY::Init() _honorTics = BattlegroundMgr::IsBGWeekend(GetBgTypeID(true)) ? BG_EY_HONOR_TICK_WEEKEND : BG_EY_HONOR_TICK_NORMAL; _ownedPointsCount[TEAM_ALLIANCE] = 0; _ownedPointsCount[TEAM_HORDE] = 0; - _flagKeeperGUID = 0; - _droppedFlagGUID = 0; + _flagKeeperGUID.Clear(); + _droppedFlagGUID.Clear(); _flagState = BG_EY_FLAG_STATE_ON_BASE; _flagCapturedObject = 0; } @@ -372,9 +370,9 @@ void BattlegroundEY::RespawnFlagAfterDrop() _flagState = BG_EY_FLAG_STATE_ON_BASE; RespawnFlag(); - if (GameObject* flag = ObjectAccessor::GetObjectInMap(GetDroppedFlagGUID(), FindBgMap(), (GameObject*)nullptr)) + if (GameObject* flag = FindBgMap()->GetGameObject(GetDroppedFlagGUID())) flag->Delete(); - SetDroppedFlagGUID(0); + SetDroppedFlagGUID(ObjectGuid::Empty); } void BattlegroundEY::HandleKillPlayer(Player* player, Player* killer) @@ -391,7 +389,7 @@ void BattlegroundEY::EventPlayerDroppedFlag(Player* player) if (GetFlagPickerGUID() != player->GetGUID()) return; - SetFlagPicker(0); + SetFlagPicker(ObjectGuid::Empty); player->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL); if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -413,7 +411,7 @@ void BattlegroundEY::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb _flagState = BG_EY_FLAG_STATE_ON_PLAYER; SpawnBGObject(BG_EY_OBJECT_FLAG_NETHERSTORM, RESPAWN_ONE_DAY); SetFlagPicker(player->GetGUID()); - SetDroppedFlagGUID(0); + SetDroppedFlagGUID(ObjectGuid::Empty); player->CastSpell(player, BG_EY_NETHERSTORM_FLAG_SPELL, true); player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); @@ -501,7 +499,7 @@ void BattlegroundEY::EventTeamCapturedPoint(TeamId teamId, uint32 point) void BattlegroundEY::EventPlayerCapturedFlag(Player* player, uint32 BgObjectType) { - SetFlagPicker(0); + SetFlagPicker(ObjectGuid::Empty); _flagState = BG_EY_FLAG_STATE_ON_BASE; player->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL); player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index 2b46fab510..ff13aab570 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -326,14 +326,14 @@ public: void StartingEventOpenDoors() override; /* BG Flags */ - uint64 GetFlagPickerGUID(TeamId /*teamId*/ = TEAM_NEUTRAL) const override { return _flagKeeperGUID; } - void SetFlagPicker(uint64 guid) { _flagKeeperGUID = guid; } + ObjectGuid GetFlagPickerGUID(TeamId /*teamId*/ = TEAM_NEUTRAL) const override { return _flagKeeperGUID; } + void SetFlagPicker(ObjectGuid guid) { _flagKeeperGUID = guid; } uint8 GetFlagState() const { return _flagState; } void RespawnFlag(); void RespawnFlagAfterDrop(); void RemovePlayer(Player* player) override; - void HandleBuffUse(uint64 buff_guid); + void HandleBuffUse(ObjectGuid buff_guid); void HandleAreaTrigger(Player* player, uint32 trigger) override; void HandleKillPlayer(Player* player, Player* killer) override; GraveyardStruct const* GetClosestGraveyard(Player* player) override; @@ -342,8 +342,8 @@ public: void EndBattleground(TeamId winnerTeamId) override; void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override; void FillInitialWorldStates(WorldPacket& data) override; - void SetDroppedFlagGUID(uint64 guid, TeamId /*teamId*/ = TEAM_NEUTRAL) override { _droppedFlagGUID = guid; } - uint64 GetDroppedFlagGUID() const { return _droppedFlagGUID; } + void SetDroppedFlagGUID(ObjectGuid guid, TeamId /*teamId*/ = TEAM_NEUTRAL) override { _droppedFlagGUID = guid; } + ObjectGuid GetDroppedFlagGUID() const { return _droppedFlagGUID; } /* Battleground Events */ void EventPlayerClickedOnFlag(Player* player, GameObject* gameObject) override; @@ -390,8 +390,8 @@ private: EventMap _bgEvents; uint32 _honorTics; uint8 _ownedPointsCount[BG_TEAMS_COUNT]; - uint64 _flagKeeperGUID; - uint64 _droppedFlagGUID; + ObjectGuid _flagKeeperGUID; + ObjectGuid _droppedFlagGUID; uint8 _flagState; uint32 _flagCapturedObject; }; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index cfe59ca122..891222426f 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -52,7 +52,7 @@ BattlegroundIC::~BattlegroundIC() { } -void BattlegroundIC::DoAction(uint32 action, uint64 guid) +void BattlegroundIC::DoAction(uint32 action, ObjectGuid guid) { if (action != ACTION_TELEPORT_PLAYER_TO_TRANSPORT) return; @@ -127,7 +127,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) if (!catapult->IsAlive()) { // Check if creature respawn time is properly saved - RespawnMap::iterator itr = respawnMap.find(catapult->GetGUIDLow()); + RespawnMap::iterator itr = respawnMap.find(catapult->GetGUID()); if (itr == respawnMap.end() || time(nullptr) < itr->second) continue; @@ -145,7 +145,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) if (!glaiveThrower->IsAlive()) { // Check if creature respawn time is properly saved - RespawnMap::iterator itr = respawnMap.find(glaiveThrower->GetGUIDLow()); + RespawnMap::iterator itr = respawnMap.find(glaiveThrower->GetGUID()); if (itr == respawnMap.end() || time(nullptr) < itr->second) continue; @@ -174,7 +174,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) if (!siege->IsAlive()) { // Check if creature respawn time is properly saved - RespawnMap::iterator itr = respawnMap.find(siege->GetGUIDLow()); + RespawnMap::iterator itr = respawnMap.find(siege->GetGUID()); if (itr == respawnMap.end() || time(nullptr) < itr->second) continue; @@ -191,7 +191,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) if (!demolisher->IsAlive()) { // Check if creature respawn time is properly saved - RespawnMap::iterator itr = respawnMap.find(demolisher->GetGUIDLow()); + RespawnMap::iterator itr = respawnMap.find(demolisher->GetGUID()); if (itr == respawnMap.end() || time(nullptr) < itr->second) continue; @@ -521,7 +521,7 @@ void BattlegroundIC::HandleKillUnit(Creature* unit, Player* killer) // Xinef: Add to respawn list if (entry == NPC_DEMOLISHER || entry == NPC_SIEGE_ENGINE_H || entry == NPC_SIEGE_ENGINE_A || entry == NPC_GLAIVE_THROWER_A || entry == NPC_GLAIVE_THROWER_H || entry == NPC_CATAPULT) - respawnMap[unit->GetGUIDLow()] = time(nullptr) + VEHICLE_RESPAWN_TIME; + respawnMap[unit->GetGUID()] = time(nullptr) + VEHICLE_RESPAWN_TIME; } } @@ -868,7 +868,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture) if (!siegeVehicle->IsVehicleInUse()) Unit::Kill(siegeEngine, siegeEngine); - respawnMap[siegeEngine->GetGUIDLow()] = time(nullptr) + VEHICLE_RESPAWN_TIME; + respawnMap[siegeEngine->GetGUID()] = time(nullptr) + VEHICLE_RESPAWN_TIME; } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index c22d30d8bb..2fdfbe9ed0 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -924,7 +924,7 @@ public: bool AllNodesConrolledByTeam(TeamId teamId) const override; // overwrited bool IsResourceGlutAllowed(TeamId teamId) const; - void DoAction(uint32 action, uint64 guid) override; + void DoAction(uint32 action, ObjectGuid guid) override; private: uint32 closeFortressDoorsTimer; bool doorsClosed; @@ -935,7 +935,7 @@ private: BG_IC_GateState GateStatus[6]; ICNodePoint nodePoint[7]; - typedef std::map<uint32, uint32> RespawnMap; + typedef std::map<ObjectGuid, uint32> RespawnMap; RespawnMap respawnMap; MotionTransport* gunshipAlliance; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index f79e545e2b..1e5dfcdeec 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -886,13 +886,13 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source) GraveyardStatus[i] = Source->GetTeamId(); // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard - std::vector<uint64> ghost_list = m_ReviveQueue[BgCreatures[BG_SA_MAXNPC + i]]; + GuidVector& ghost_list = m_ReviveQueue[BgCreatures[BG_SA_MAXNPC + i]]; if (!ghost_list.empty()) { GraveyardStruct const* ClosestGrave = nullptr; - for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) + for (ObjectGuid const guid : ghost_list) { - Player* player = ObjectAccessor::FindPlayer(*itr); + Player* player = ObjectAccessor::FindPlayer(guid); if (!player) continue; @@ -902,8 +902,9 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source) if (ClosestGrave) player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation()); } + // xinef: clear resurrect queue for this creature - m_ReviveQueue[BgCreatures[BG_SA_MAXNPC + i]].clear(); + ghost_list.clear(); } DelCreature(BG_SA_MAXNPC + i); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index 65d49d78f8..3399feb48d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -24,10 +24,6 @@ BattlegroundWS::BattlegroundWS() StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_BG_WS_START_HALF_MINUTE; StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_WS_HAS_BEGUN; - _flagKeepers[TEAM_ALLIANCE] = 0; - _flagKeepers[TEAM_HORDE] = 0; - _droppedFlagGUID[TEAM_ALLIANCE] = 0; - _droppedFlagGUID[TEAM_HORDE] = 0; _flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE; _flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE; _lastFlagCaptureTeam = TEAM_NEUTRAL; @@ -70,18 +66,18 @@ void BattlegroundWS::PostUpdateImpl(uint32 diff) RespawnFlagAfterDrop(TEAM_HORDE); break; case BG_WS_EVENT_BOTH_FLAGS_KEPT10: - if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_ALLIANCE), this->FindBgMap(), (Player*)nullptr)) + if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_ALLIANCE))) player->CastSpell(player, BG_WS_SPELL_FOCUSED_ASSAULT, true); - if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_HORDE), this->FindBgMap(), (Player*)nullptr)) + if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_HORDE))) player->CastSpell(player, BG_WS_SPELL_FOCUSED_ASSAULT, true); break; case BG_WS_EVENT_BOTH_FLAGS_KEPT15: - if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_ALLIANCE), this->FindBgMap(), (Player*)nullptr)) + if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_ALLIANCE))) { player->RemoveAurasDueToSpell(BG_WS_SPELL_FOCUSED_ASSAULT); player->CastSpell(player, BG_WS_SPELL_BRUTAL_ASSAULT, true); } - if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_HORDE), this->FindBgMap(), (Player*)nullptr)) + if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_HORDE))) { player->RemoveAurasDueToSpell(BG_WS_SPELL_FOCUSED_ASSAULT); player->CastSpell(player, BG_WS_SPELL_BRUTAL_ASSAULT, true); @@ -142,7 +138,7 @@ void BattlegroundWS::RespawnFlagAfterDrop(TeamId teamId) if (GameObject* flag = GetBgMap()->GetGameObject(GetDroppedFlagGUID(teamId))) flag->Delete(); - SetDroppedFlagGUID(0, teamId); + SetDroppedFlagGUID(ObjectGuid::Empty, teamId); _bgEvents.CancelEvent(BG_WS_EVENT_BOTH_FLAGS_KEPT10); _bgEvents.CancelEvent(BG_WS_EVENT_BOTH_FLAGS_KEPT15); RemoveAssaultAuras(); @@ -157,7 +153,7 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* player) RemoveAssaultAuras(); AddPoints(player->GetTeamId(), 1); - SetFlagPicker(0, GetOtherTeamId(player->GetTeamId())); + SetFlagPicker(ObjectGuid::Empty, GetOtherTeamId(player->GetTeamId())); UpdateFlagState(GetOtherTeamId(player->GetTeamId()), BG_WS_FLAG_STATE_ON_BASE); if (player->GetTeamId() == TEAM_ALLIANCE) { @@ -200,7 +196,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* player) if (GetFlagPickerGUID(TEAM_HORDE) != player->GetGUID() && GetFlagPickerGUID(TEAM_ALLIANCE) != player->GetGUID()) return; - SetFlagPicker(0, GetOtherTeamId(player->GetTeamId())); + SetFlagPicker(ObjectGuid::Empty, GetOtherTeamId(player->GetTeamId())); player->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); player->RemoveAurasDueToSpell(BG_WS_SPELL_FOCUSED_ASSAULT); player->RemoveAurasDueToSpell(BG_WS_SPELL_BRUTAL_ASSAULT); @@ -279,7 +275,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb // Alliance Flag on ground if (GetFlagState(TEAM_ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && player->IsWithinDistInMap(gameObject, 10.0f) && gameObject->GetEntry() == BG_OBJECT_A_FLAG_GROUND_WS_ENTRY) { - SetDroppedFlagGUID(0, TEAM_ALLIANCE); + SetDroppedFlagGUID(ObjectGuid::Empty, TEAM_ALLIANCE); if (player->GetTeamId() == TEAM_ALLIANCE) { UpdateFlagState(TEAM_ALLIANCE, BG_WS_FLAG_STATE_ON_BASE); @@ -310,7 +306,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb // Horde Flag on ground if (GetFlagState(TEAM_HORDE) == BG_WS_FLAG_STATE_ON_GROUND && player->IsWithinDistInMap(gameObject, 10.0f) && gameObject->GetEntry() == BG_OBJECT_H_FLAG_GROUND_WS_ENTRY) { - SetDroppedFlagGUID(0, TEAM_HORDE); + SetDroppedFlagGUID(ObjectGuid::Empty, TEAM_HORDE); if (player->GetTeamId() == TEAM_HORDE) { UpdateFlagState(TEAM_HORDE, BG_WS_FLAG_STATE_ON_BASE); @@ -412,14 +408,14 @@ bool BattlegroundWS::SetupBattleground() AddSpiritGuide(WS_SPIRIT_MAIN_HORDE, sg->x, sg->y, sg->z, 3.193953f, TEAM_HORDE); for (uint32 i = BG_WS_OBJECT_DOOR_A_1; i < BG_WS_OBJECT_MAX; ++i) - if (BgObjects[i] == 0) + if (!BgObjects[i]) { LOG_ERROR("sql.sql", "BatteGroundWS: Failed to spawn some object Battleground not created!"); return false; } for (uint32 i = WS_SPIRIT_MAIN_ALLIANCE; i < BG_CREATURES_MAX_WS; ++i) - if (BgCreatures[i] == 0) + if (!BgCreatures[i]) { LOG_ERROR("sql.sql", "BatteGroundWS: Failed to spawn spirit guides Battleground not created!"); return false; @@ -434,10 +430,10 @@ void BattlegroundWS::Init() Battleground::Init(); _bgEvents.Reset(); - _flagKeepers[TEAM_ALLIANCE] = 0; - _flagKeepers[TEAM_HORDE] = 0; - _droppedFlagGUID[TEAM_ALLIANCE] = 0; - _droppedFlagGUID[TEAM_HORDE] = 0; + _flagKeepers[TEAM_ALLIANCE].Clear(); + _flagKeepers[TEAM_HORDE].Clear(); + _droppedFlagGUID[TEAM_ALLIANCE].Clear(); + _droppedFlagGUID[TEAM_HORDE].Clear(); _flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE; _flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE; _lastFlagCaptureTeam = TEAM_NEUTRAL; @@ -530,8 +526,8 @@ TeamId BattlegroundWS::GetPrematureWinner() uint32 BattlegroundWS::GetAssaultSpellId() const { - if ((GetFlagPickerGUID(TEAM_ALLIANCE) == 0 && GetFlagState(TEAM_ALLIANCE) != BG_WS_FLAG_STATE_ON_GROUND) || - (GetFlagPickerGUID(TEAM_HORDE) == 0 && GetFlagState(TEAM_HORDE) != BG_WS_FLAG_STATE_ON_GROUND) || + if ((!GetFlagPickerGUID(TEAM_ALLIANCE) && GetFlagState(TEAM_ALLIANCE) != BG_WS_FLAG_STATE_ON_GROUND) || + (!GetFlagPickerGUID(TEAM_HORDE) && GetFlagState(TEAM_HORDE) != BG_WS_FLAG_STATE_ON_GROUND) || _bgEvents.GetNextEventTime(BG_WS_EVENT_BOTH_FLAGS_KEPT10) > 0) return 0; @@ -540,12 +536,12 @@ uint32 BattlegroundWS::GetAssaultSpellId() const void BattlegroundWS::RemoveAssaultAuras() { - if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_ALLIANCE), this->FindBgMap(), (Player*)nullptr)) + if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_ALLIANCE))) { player->RemoveAurasDueToSpell(BG_WS_SPELL_FOCUSED_ASSAULT); player->RemoveAurasDueToSpell(BG_WS_SPELL_BRUTAL_ASSAULT); } - if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_HORDE), this->FindBgMap(), (Player*)nullptr)) + if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_HORDE))) { player->RemoveAurasDueToSpell(BG_WS_SPELL_FOCUSED_ASSAULT); player->RemoveAurasDueToSpell(BG_WS_SPELL_BRUTAL_ASSAULT); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h index cb79055215..31c55431c8 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h @@ -159,8 +159,8 @@ public: void StartingEventOpenDoors() override; /* BG Flags */ - uint64 GetFlagPickerGUID(TeamId teamId) const override { return _flagKeepers[teamId]; } - void SetFlagPicker(uint64 guid, TeamId teamId) { _flagKeepers[teamId] = guid; } + ObjectGuid GetFlagPickerGUID(TeamId teamId) const override { return _flagKeepers[teamId]; } + void SetFlagPicker(ObjectGuid guid, TeamId teamId) { _flagKeepers[teamId] = guid; } void RespawnFlagAfterDrop(TeamId teamId); uint8 GetFlagState(TeamId teamId) const { return _flagState[teamId]; } @@ -179,8 +179,8 @@ public: void UpdateFlagState(TeamId teamId, uint32 value); void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override; - void SetDroppedFlagGUID(uint64 guid, TeamId teamId) override { _droppedFlagGUID[teamId] = guid; } - uint64 GetDroppedFlagGUID(TeamId teamId) const { return _droppedFlagGUID[teamId];} + void SetDroppedFlagGUID(ObjectGuid guid, TeamId teamId) override { _droppedFlagGUID[teamId] = guid; } + ObjectGuid GetDroppedFlagGUID(TeamId teamId) const { return _droppedFlagGUID[teamId];} void FillInitialWorldStates(WorldPacket& data) override; /* Scorekeeping */ @@ -194,8 +194,8 @@ public: private: EventMap _bgEvents; - uint64 _flagKeepers[2]; - uint64 _droppedFlagGUID[2]; + ObjectGuid _flagKeepers[2]; + ObjectGuid _droppedFlagGUID[2]; uint8 _flagState[2]; TeamId _lastFlagCaptureTeam; uint32 _reputationCapture; diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index 7c17697a72..e06336d3c2 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -55,7 +55,7 @@ void CalendarMgr::LoadFromDB() Field* fields = result->Fetch(); uint64 eventId = fields[0].GetUInt64(); - uint64 creatorGUID = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER); + ObjectGuid creatorGUID = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32()); std::string title = fields[2].GetString(); std::string description = fields[3].GetString(); CalendarEventType type = CalendarEventType(fields[4].GetUInt8()); @@ -66,7 +66,7 @@ void CalendarMgr::LoadFromDB() uint32 guildId = 0; if (flags & CALENDAR_FLAG_GUILD_EVENT || flags & CALENDAR_FLAG_WITHOUT_INVITES) - guildId = Player::GetGuildIdFromStorage(GUID_LOPART(creatorGUID)); + guildId = Player::GetGuildIdFromStorage(creatorGUID.GetCounter()); CalendarEvent* calendarEvent = new CalendarEvent(eventId, creatorGUID, guildId, type, dungeonId, time_t(eventTime), flags, time_t(timezoneTime), title, description); _events.insert(calendarEvent); @@ -87,8 +87,8 @@ void CalendarMgr::LoadFromDB() uint64 inviteId = fields[0].GetUInt64(); uint64 eventId = fields[1].GetUInt64(); - uint64 invitee = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER); - uint64 senderGUID = MAKE_NEW_GUID(fields[3].GetUInt32(), 0, HIGHGUID_PLAYER); + ObjectGuid invitee = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32()); + ObjectGuid senderGUID = ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt32()); CalendarInviteStatus status = CalendarInviteStatus(fields[4].GetUInt8()); uint32 statusTime = fields[5].GetUInt32(); CalendarModerationRank rank = CalendarModerationRank(fields[6].GetUInt8()); @@ -142,7 +142,7 @@ void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite } } -void CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover) +void CalendarMgr::RemoveEvent(uint64 eventId, ObjectGuid remover) { CalendarEvent* calendarEvent = GetEvent(eventId); @@ -155,7 +155,7 @@ void CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover) RemoveEvent(calendarEvent, remover); } -void CalendarMgr::RemoveEvent(CalendarEvent* calendarEvent, uint64 remover) +void CalendarMgr::RemoveEvent(CalendarEvent* calendarEvent, ObjectGuid remover) { if (!calendarEvent) { @@ -180,7 +180,7 @@ void CalendarMgr::RemoveEvent(CalendarEvent* calendarEvent, uint64 remover) // guild events only? check invite status here? // When an event is deleted, all invited (accepted/declined? - verify) guildies are notified via in-game mail. (wowwiki) if (remover && invite->GetInviteeGUID() != remover) - mail.SendMailTo(trans, MailReceiver(invite->GetInviteeGUID()), calendarEvent, MAIL_CHECK_MASK_COPIED); + mail.SendMailTo(trans, MailReceiver(invite->GetInviteeGUID().GetCounter()), calendarEvent, MAIL_CHECK_MASK_COPIED); delete invite; } @@ -197,7 +197,7 @@ void CalendarMgr::RemoveEvent(CalendarEvent* calendarEvent, uint64 remover) return; } -void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, uint64 /*remover*/) +void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid /*remover*/) { CalendarEvent* calendarEvent = GetEvent(eventId); @@ -236,7 +236,7 @@ void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_EVENT); stmt->setUInt64(0, calendarEvent->GetEventId()); - stmt->setUInt32(1, GUID_LOPART(calendarEvent->GetCreatorGUID())); + stmt->setUInt32(1, calendarEvent->GetCreatorGUID().GetCounter()); stmt->setString(2, calendarEvent->GetTitle()); stmt->setString(3, calendarEvent->GetDescription()); stmt->setUInt8(4, calendarEvent->GetType()); @@ -258,8 +258,8 @@ void CalendarMgr::UpdateInvite(CalendarInvite* invite, SQLTransaction& trans) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_INVITE); stmt->setUInt64(0, invite->GetInviteId()); stmt->setUInt64(1, invite->GetEventId()); - stmt->setUInt32(2, GUID_LOPART(invite->GetInviteeGUID())); - stmt->setUInt32(3, GUID_LOPART(invite->GetSenderGUID())); + stmt->setUInt32(2, invite->GetInviteeGUID().GetCounter()); + stmt->setUInt32(3, invite->GetSenderGUID().GetCounter()); stmt->setUInt8(4, invite->GetStatus()); stmt->setUInt32(5, uint32(invite->GetStatusTime())); stmt->setUInt8(6, invite->GetRank()); @@ -267,7 +267,7 @@ void CalendarMgr::UpdateInvite(CalendarInvite* invite, SQLTransaction& trans) CharacterDatabase.ExecuteOrAppend(trans, stmt); } -void CalendarMgr::RemoveAllPlayerEventsAndInvites(uint64 guid) +void CalendarMgr::RemoveAllPlayerEventsAndInvites(ObjectGuid guid) { for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end();) { @@ -275,7 +275,7 @@ void CalendarMgr::RemoveAllPlayerEventsAndInvites(uint64 guid) ++itr; if (event->GetCreatorGUID() == guid) { - RemoveEvent(event, 0); + RemoveEvent(event, ObjectGuid::Empty); continue; } } @@ -285,7 +285,7 @@ void CalendarMgr::RemoveAllPlayerEventsAndInvites(uint64 guid) RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); } -void CalendarMgr::RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId) +void CalendarMgr::RemovePlayerGuildEventsAndSignups(ObjectGuid guid, uint32 guildId) { for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) if ((*itr)->GetCreatorGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement())) @@ -365,11 +365,11 @@ void CalendarMgr::DeleteOldEvents() CalendarEvent* event = *itr; ++itr; if (event->GetEventTime() < oldEventsTime) - RemoveEvent(event, 0); + RemoveEvent(event, ObjectGuid::Empty); } } -CalendarEventStore CalendarMgr::GetEventsCreatedBy(uint64 guid, bool includeGuildEvents) +CalendarEventStore CalendarMgr::GetEventsCreatedBy(ObjectGuid guid, bool includeGuildEvents) { CalendarEventStore result; for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) @@ -394,7 +394,7 @@ CalendarEventStore CalendarMgr::GetGuildEvents(uint32 guildId) return result; } -CalendarEventStore CalendarMgr::GetPlayerEvents(uint64 guid) +CalendarEventStore CalendarMgr::GetPlayerEvents(ObjectGuid guid) { CalendarEventStore events; @@ -404,7 +404,7 @@ CalendarEventStore CalendarMgr::GetPlayerEvents(uint64 guid) if (CalendarEvent* event = GetEvent(itr->first)) // nullptr check added as attempt to fix #11512 events.insert(event); - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) if (player->GetGuildId()) for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) if ((*itr)->GetGuildId() == player->GetGuildId()) @@ -418,7 +418,7 @@ CalendarInviteStore const& CalendarMgr::GetEventInvites(uint64 eventId) return _invites[eventId]; } -CalendarInviteStore CalendarMgr::GetPlayerInvites(uint64 guid) +CalendarInviteStore CalendarMgr::GetPlayerInvites(ObjectGuid guid) { CalendarInviteStore invites; @@ -430,7 +430,7 @@ CalendarInviteStore CalendarMgr::GetPlayerInvites(uint64 guid) return invites; } -uint32 CalendarMgr::GetPlayerNumPending(uint64 guid) +uint32 CalendarMgr::GetPlayerNumPending(ObjectGuid guid) { CalendarInviteStore const& invites = GetPlayerInvites(guid); @@ -452,10 +452,10 @@ uint32 CalendarMgr::GetPlayerNumPending(uint64 guid) return pendingNum; } -std::string CalendarEvent::BuildCalendarMailSubject(uint64 remover) const +std::string CalendarEvent::BuildCalendarMailSubject(ObjectGuid remover) const { std::ostringstream strm; - strm << remover << ':' << _title; + strm << remover.ToString().c_str() << ':' << _title; return strm.str(); } @@ -478,13 +478,13 @@ void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite) time_t statusTime = invite.GetStatusTime(); bool hasStatusTime = statusTime != 946684800; // 01/01/2000 00:00:00 - uint64 invitee = invite.GetInviteeGUID(); - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(invitee); + ObjectGuid invitee = invite.GetInviteeGUID(); + Player* player = ObjectAccessor::FindConnectedPlayer(invitee); - uint8 level = player ? player->getLevel() : Player::GetLevelFromStorage(invitee); + uint8 level = player ? player->getLevel() : Player::GetLevelFromStorage(invitee.GetCounter()); WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (statusTime ? 4 : 0) + 1); - data.appendPackGUID(invitee); + data << invitee.WriteAsPacked(); data << uint64(invite.GetEventId()); data << uint64(invite.GetInviteId()); data << uint8(level); @@ -496,7 +496,7 @@ void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite) if (!calendarEvent) // Pre-invite { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(invite.GetSenderGUID())) + if (Player* player = ObjectAccessor::FindConnectedPlayer(invite.GetSenderGUID())) player->SendDirectMessage(&data); } else @@ -529,7 +529,7 @@ void CalendarMgr::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEven void CalendarMgr::SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { WorldPacket data(SMSG_CALENDAR_EVENT_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4); - data.appendPackGUID(invite.GetInviteeGUID()); + data << invite.GetInviteeGUID().WriteAsPacked(); data << uint64(calendarEvent.GetEventId()); data.AppendPackedTime(calendarEvent.GetEventTime()); data << uint32(calendarEvent.GetFlags()); @@ -553,7 +553,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.appendPackGUID(invite.GetInviteeGUID()); + data<< invite.GetInviteeGUID().WriteAsPacked(); data << uint64(invite.GetEventId()); data << uint32(flags); data << uint8(1); // FIXME @@ -564,7 +564,7 @@ void CalendarMgr::SendCalendarEventInviteRemove(CalendarEvent const& calendarEve void CalendarMgr::SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { WorldPacket data(SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT, 8 + 8 + 1 + 1); - data.appendPackGUID(invite.GetInviteeGUID()); + data << invite.GetInviteeGUID().WriteAsPacked(); data << uint64(invite.GetEventId()); data << uint8(invite.GetRank()); data << uint8(1); // Unk boolean - Display to client? @@ -584,21 +584,21 @@ void CalendarMgr::SendCalendarEventInviteAlert(CalendarEvent const& calendarEven data << uint64(invite.GetInviteId()); data << uint8(invite.GetStatus()); data << uint8(invite.GetRank()); - data.appendPackGUID(calendarEvent.GetCreatorGUID()); - data.appendPackGUID(invite.GetSenderGUID()); + data << calendarEvent.GetCreatorGUID().WriteAsPacked(); + data << invite.GetSenderGUID().WriteAsPacked(); if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) { if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId())) guild->BroadcastPacket(&data); } - else if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(invite.GetInviteeGUID())) + else if (Player* player = ObjectAccessor::FindConnectedPlayer(invite.GetInviteeGUID())) player->SendDirectMessage(&data); } -void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType) +void CalendarMgr::SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType) { - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* player = ObjectAccessor::FindConnectedPlayer(guid); if (!player) return; @@ -606,7 +606,7 @@ void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEv WorldPacket data(SMSG_CALENDAR_SEND_EVENT, 60 + eventInviteeList.size() * 32); data << uint8(sendType); - data.appendPackGUID(calendarEvent.GetCreatorGUID()); + data << calendarEvent.GetCreatorGUID().WriteAsPacked(); data << uint64(calendarEvent.GetEventId()); data << calendarEvent.GetTitle(); data << calendarEvent.GetDescription(); @@ -623,13 +623,13 @@ void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEv for (CalendarInviteStore::const_iterator itr = eventInviteeList.begin(); itr != eventInviteeList.end(); ++itr) { CalendarInvite const* calendarInvite = (*itr); - uint64 inviteeGuid = calendarInvite->GetInviteeGUID(); - Player* invitee = ObjectAccessor::FindPlayerInOrOutOfWorld(inviteeGuid); + ObjectGuid inviteeGuid = calendarInvite->GetInviteeGUID(); + Player* invitee = ObjectAccessor::FindConnectedPlayer(inviteeGuid); - uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromStorage(inviteeGuid); - uint32 inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromStorage(GUID_LOPART(inviteeGuid)); + uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromStorage(inviteeGuid.GetCounter()); + uint32 inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromStorage(inviteeGuid.GetCounter()); - data.appendPackGUID(inviteeGuid); + data << inviteeGuid.WriteAsPacked(); data << uint8(inviteeLevel); data << uint8(calendarInvite->GetStatus()); data << uint8(calendarInvite->GetRank()); @@ -642,9 +642,9 @@ void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEv player->SendDirectMessage(&data); } -void CalendarMgr::SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status) +void CalendarMgr::SendCalendarEventInviteRemoveAlert(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) { WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT, 8 + 4 + 4 + 1); data << uint64(calendarEvent.GetEventId()); @@ -656,18 +656,18 @@ void CalendarMgr::SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent } } -void CalendarMgr::SendCalendarClearPendingAction(uint64 guid) +void CalendarMgr::SendCalendarClearPendingAction(ObjectGuid guid) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) { WorldPacket data(SMSG_CALENDAR_CLEAR_PENDING_ACTION, 0); player->SendDirectMessage(&data); } } -void CalendarMgr::SendCalendarCommandResult(uint64 guid, CalendarError err, char const* param /*= nullptr*/) +void CalendarMgr::SendCalendarCommandResult(ObjectGuid guid, CalendarError err, char const* param /*= nullptr*/) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) { WorldPacket data(SMSG_CALENDAR_COMMAND_RESULT, 0); data << uint32(0); @@ -700,7 +700,7 @@ void CalendarMgr::SendPacketToAllEventRelatives(WorldPacket packet, CalendarEven // Send packet to all invitees if event is non-guild, in other case only to non-guild invitees (packet was broadcasted for them) CalendarInviteStore invites = _invites[calendarEvent.GetEventId()]; for (CalendarInviteStore::iterator itr = invites.begin(); itr != invites.end(); ++itr) - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld((*itr)->GetInviteeGUID())) + if (Player* player = ObjectAccessor::FindConnectedPlayer((*itr)->GetInviteeGUID())) if (!calendarEvent.IsGuildEvent() || player->GetGuildId() != calendarEvent.GetGuildId()) player->SendDirectMessage(&packet); } diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h index c753e40245..59d8ddcbc9 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -10,6 +10,7 @@ #include "Common.h" #include "DatabaseEnv.h" #include "WorldPacket.h" +#include "ObjectGuid.h" enum CalendarMailAnswers { @@ -134,10 +135,10 @@ public: _text = calendarInvite.GetText(); } - CalendarInvite() : _inviteId(1), _eventId(0), _invitee(0), _senderGUID(0), _statusTime(time(nullptr)), + CalendarInvite() : _inviteId(1), _eventId(0), _statusTime(time(nullptr)), _status(CALENDAR_STATUS_INVITED), _rank(CALENDAR_RANK_PLAYER), _text("") { } - CalendarInvite(uint64 inviteId, uint64 eventId, uint64 invitee, uint64 senderGUID, time_t statusTime, + CalendarInvite(uint64 inviteId, uint64 eventId, ObjectGuid invitee, ObjectGuid senderGUID, time_t statusTime, CalendarInviteStatus status, CalendarModerationRank rank, std::string text) : _inviteId(inviteId), _eventId(eventId), _invitee(invitee), _senderGUID(senderGUID), _statusTime(statusTime), _status(status), _rank(rank), _text(text) { } @@ -150,11 +151,11 @@ public: void SetEventId(uint64 eventId) { _eventId = eventId; } uint64 GetEventId() const { return _eventId; } - void SetSenderGUID(uint64 guid) { _senderGUID = guid; } - uint64 GetSenderGUID() const { return _senderGUID; } + void SetSenderGUID(ObjectGuid guid) { _senderGUID = guid; } + ObjectGuid GetSenderGUID() const { return _senderGUID; } - void SetInvitee(uint64 guid) { _invitee = guid; } - uint64 GetInviteeGUID() const { return _invitee; } + void SetInvitee(ObjectGuid guid) { _invitee = guid; } + ObjectGuid GetInviteeGUID() const { return _invitee; } void SetStatusTime(time_t statusTime) { _statusTime = statusTime; } time_t GetStatusTime() const { return _statusTime; } @@ -171,8 +172,8 @@ public: private: uint64 _inviteId; uint64 _eventId; - uint64 _invitee; - uint64 _senderGUID; + ObjectGuid _invitee; + ObjectGuid _senderGUID; time_t _statusTime; CalendarInviteStatus _status; CalendarModerationRank _rank; @@ -196,13 +197,13 @@ public: _description = calendarEvent.GetDescription(); } - CalendarEvent(uint64 eventId, uint64 creatorGUID, uint32 guildId, CalendarEventType type, int32 dungeonId, + CalendarEvent(uint64 eventId, ObjectGuid creatorGUID, uint32 guildId, CalendarEventType type, int32 dungeonId, time_t eventTime, uint32 flags, time_t timezoneTime, std::string title, std::string description) : _eventId(eventId), _creatorGUID(creatorGUID), _guildId(guildId), _type(type), _dungeonId(dungeonId), _eventTime(eventTime), _flags(flags), _timezoneTime(timezoneTime), _title(title), _description(description) { } - CalendarEvent() : _eventId(1), _creatorGUID(0), _guildId(0), _type(CALENDAR_TYPE_OTHER), _dungeonId(-1), _eventTime(0), + CalendarEvent() : _eventId(1), _guildId(0), _type(CALENDAR_TYPE_OTHER), _dungeonId(-1), _eventTime(0), _flags(0), _timezoneTime(0), _title(""), _description("") { } ~CalendarEvent(); @@ -210,8 +211,8 @@ public: void SetEventId(uint64 eventId) { _eventId = eventId; } uint64 GetEventId() const { return _eventId; } - void SetCreatorGUID(uint64 guid) { _creatorGUID = guid; } - uint64 GetCreatorGUID() const { return _creatorGUID; } + void SetCreatorGUID(ObjectGuid guid) { _creatorGUID = guid; } + ObjectGuid GetCreatorGUID() const { return _creatorGUID; } void SetGuildId(uint32 guildId) { _guildId = guildId; } uint32 GetGuildId() const { return _guildId; } @@ -243,12 +244,12 @@ public: static bool IsGuildEvent(uint32 flags) { return (flags & CALENDAR_FLAG_GUILD_EVENT) != 0; } static bool IsGuildAnnouncement(uint32 flags) { return (flags & CALENDAR_FLAG_WITHOUT_INVITES) != 0; } - std::string BuildCalendarMailSubject(uint64 remover) const; + std::string BuildCalendarMailSubject(ObjectGuid remover) const; std::string BuildCalendarMailBody() const; private: uint64 _eventId; - uint64 _creatorGUID; + ObjectGuid _creatorGUID; uint32 _guildId; CalendarEventType _type; int32 _dungeonId; @@ -283,14 +284,14 @@ public: CalendarEvent* GetEvent(uint64 eventId); CalendarEventStore const& GetEvents() const { return _events; } - CalendarEventStore GetEventsCreatedBy(uint64 guid, bool includeGuildEvents = false); - CalendarEventStore GetPlayerEvents(uint64 guid); + CalendarEventStore GetEventsCreatedBy(ObjectGuid guid, bool includeGuildEvents = false); + CalendarEventStore GetPlayerEvents(ObjectGuid guid); CalendarEventStore GetGuildEvents(uint32 guildId); CalendarInvite* GetInvite(uint64 inviteId) const; CalendarEventInviteStore const& GetInvites() const { return _invites; } CalendarInviteStore const& GetEventInvites(uint64 eventId); - CalendarInviteStore GetPlayerInvites(uint64 guid); + CalendarInviteStore GetPlayerInvites(ObjectGuid guid); void FreeEventId(uint64 id); uint64 GetFreeEventId(); @@ -299,33 +300,33 @@ public: void DeleteOldEvents(); - uint32 GetPlayerNumPending(uint64 guid); + uint32 GetPlayerNumPending(ObjectGuid guid); void AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType sendType); - void RemoveEvent(uint64 eventId, uint64 remover); - void RemoveEvent(CalendarEvent* calendarEvent, uint64 remover); + void RemoveEvent(uint64 eventId, ObjectGuid remover); + void RemoveEvent(CalendarEvent* calendarEvent, ObjectGuid remover); void UpdateEvent(CalendarEvent* calendarEvent); void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite); void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite, SQLTransaction& trans); - void RemoveInvite(uint64 inviteId, uint64 eventId, uint64 remover); + void RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid remover); void UpdateInvite(CalendarInvite* invite); void UpdateInvite(CalendarInvite* invite, SQLTransaction& trans); - void RemoveAllPlayerEventsAndInvites(uint64 guid); - void RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId); + void RemoveAllPlayerEventsAndInvites(ObjectGuid guid); + void RemovePlayerGuildEventsAndSignups(ObjectGuid guid, uint32 guildId); - void SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType); + void SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType); void SendCalendarEventInvite(CalendarInvite const& invite); void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite); void SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags); - void SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status); + void SendCalendarEventInviteRemoveAlert(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status); void SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t oldEventTime); void SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite); void SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent); void SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite); - void SendCalendarClearPendingAction(uint64 guid); - void SendCalendarCommandResult(uint64 guid, CalendarError err, char const* param = nullptr); + void SendCalendarClearPendingAction(ObjectGuid guid); + void SendCalendarCommandResult(ObjectGuid guid, CalendarError err, char const* param = nullptr); void SendPacketToAllEventRelatives(WorldPacket packet, CalendarEvent const& calendarEvent); }; diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index c2c004d182..88399667bb 100644 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -22,7 +22,6 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId, _channelId(channelId), _channelDBId(channelDBId), _teamId(teamId), - _ownerGUID(0), _name(name), _password("") { @@ -81,9 +80,9 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId, } } -bool Channel::IsBanned(uint64 guid) const +bool Channel::IsBanned(ObjectGuid guid) const { - BannedContainer::const_iterator itr = bannedStore.find(GUID_LOPART(guid)); + BannedContainer::const_iterator itr = bannedStore.find(guid); return itr != bannedStore.end() && itr->second > time(nullptr); } @@ -110,20 +109,20 @@ void Channel::UpdateChannelUseageInDB() const CharacterDatabase.Execute(stmt); } -void Channel::AddChannelBanToDB(uint32 guid, uint32 time) const +void Channel::AddChannelBanToDB(ObjectGuid guid, uint32 time) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL_BAN); stmt->setUInt32(0, _channelDBId); - stmt->setUInt32(1, guid); + stmt->setUInt32(1, guid.GetCounter()); stmt->setUInt32(2, time); CharacterDatabase.Execute(stmt); } -void Channel::RemoveChannelBanFromDB(uint32 guid) const +void Channel::RemoveChannelBanFromDB(ObjectGuid guid) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHANNEL_BAN); stmt->setUInt32(0, _channelDBId); - stmt->setUInt32(1, guid); + stmt->setUInt32(1, guid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -146,7 +145,7 @@ void Channel::CleanOldChannelsInDB() void Channel::JoinChannel(Player* player, std::string const& pass) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); if (IsOn(guid)) { // Do not send error message for built-in channels @@ -243,7 +242,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass) void Channel::LeaveChannel(Player* player, bool send) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); if (!IsOn(guid)) { if (send) @@ -288,7 +287,7 @@ void Channel::LeaveChannel(Player* player, bool send) { if (!playersStore.empty()) { - uint64 newowner = 0; + ObjectGuid newowner; for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr) { newowner = itr->second.player; @@ -303,7 +302,7 @@ void Channel::LeaveChannel(Player* player, bool send) // if the new owner is invisible gm, set flag to automatically choose a new owner } else - SetOwner(0); + SetOwner(ObjectGuid::Empty); } } } @@ -311,7 +310,7 @@ void Channel::LeaveChannel(Player* player, bool send) void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban) { AccountTypes sec = player->GetSession()->GetSecurity(); - uint64 good = player->GetGUID(); + ObjectGuid good = player->GetGUID(); if (!IsOn(good)) { @@ -332,7 +331,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b bool banOffline = false; // pussywizard bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end(); - uint64 victim = 0; + ObjectGuid victim; uint32 badAccId = 0; uint32 badSecurity = 0; Player* bad = ObjectAccessor::FindPlayerByName(badname, false); @@ -348,13 +347,13 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b { if (ban && (AccountMgr::IsGMAccount(sec) || isGoodConstantModerator)) { - if (uint32 lowGuid = sWorld->GetGlobalPlayerGUID(badname)) - if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(lowGuid)) + if (ObjectGuid guid = sWorld->GetGlobalPlayerGUID(badname)) + if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(guid.GetCounter())) { if (Player::TeamIdForRace(gpd->race) == Player::TeamIdForRace(player->getRace())) { banOffline = true; - victim = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER); + victim = guid; badAccId = gpd->accountId; } else @@ -417,8 +416,8 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b { if (!IsBanned(victim)) { - bannedStore[GUID_LOPART(victim)] = time(nullptr) + CHANNEL_BAN_DURATION; - AddChannelBanToDB(GUID_LOPART(victim), time(nullptr) + CHANNEL_BAN_DURATION); + bannedStore[victim] = time(nullptr) + CHANNEL_BAN_DURATION; + AddChannelBanToDB(victim, time(nullptr) + CHANNEL_BAN_DURATION); if (notify) { @@ -449,7 +448,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b SetOwner(good); else if (!playersStore.empty()) { - uint64 newowner = 0; + ObjectGuid newowner; for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr) { newowner = itr->second.player; @@ -459,14 +458,14 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b SetOwner(newowner); } else - SetOwner(0); + SetOwner(ObjectGuid::Empty); } } void Channel::UnBan(Player const* player, std::string const& badname) { uint32 sec = player->GetSession()->GetSecurity(); - uint64 good = player->GetGUID(); + ObjectGuid good = player->GetGUID(); if (!IsOn(good)) { @@ -484,9 +483,9 @@ void Channel::UnBan(Player const* player, std::string const& badname) return; } - uint64 victim = 0; - if (uint32 guidLow = sWorld->GetGlobalPlayerGUID(badname)) - victim = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER); + ObjectGuid victim; + if (ObjectGuid guid = sWorld->GetGlobalPlayerGUID(badname)) + victim = guid; if (!victim || !IsBanned(victim)) { @@ -509,27 +508,29 @@ void Channel::UnBan(Player const* player, std::string const& badname) } if (_channelRights.flags & CHANNEL_RIGHT_CANT_BAN) - LOG_GM(player->GetSession()->GetAccountId(), "Command: /unban %s %s (Moderator %s [guid: %u, account: %u] unbanned %s [guid: %u])", GetName().c_str(), badname.c_str(), player->GetName().c_str(), player->GetGUIDLow(), player->GetSession()->GetAccountId(), badname.c_str(), GUID_LOPART(victim)); + LOG_GM(player->GetSession()->GetAccountId(), "Command: /unban %s %s (Moderator %s [%s, account: %u] unbanned %s [%s])", + GetName().c_str(), badname.c_str(), player->GetName().c_str(), player->GetGUID().ToString().c_str(), player->GetSession()->GetAccountId(), + badname.c_str(), victim.ToString().c_str()); - bannedStore.erase(GUID_LOPART(victim)); - RemoveChannelBanFromDB(GUID_LOPART(victim)); + bannedStore.erase(victim); + RemoveChannelBanFromDB(victim); WorldPacket data; MakePlayerUnbanned(&data, victim, good); SendToAll(&data); } -void Channel::UnBan(uint64 guid) +void Channel::UnBan(ObjectGuid guid) { if (!IsBanned(guid)) return; - bannedStore.erase(GUID_LOPART(guid)); - RemoveChannelBanFromDB(GUID_LOPART(guid)); + bannedStore.erase(guid); + RemoveChannelBanFromDB(guid); } void Channel::Password(Player const* player, std::string const& pass) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); ChatHandler chat(player->GetSession()); if (!IsOn(guid)) @@ -567,7 +568,7 @@ void Channel::Password(Player const* player, std::string const& pass) void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bool set) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(guid)) @@ -590,7 +591,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo return; Player* newp = ObjectAccessor::FindPlayerByName(p2n, false); - uint64 victim = newp ? newp->GetGUID() : 0; + ObjectGuid victim = newp ? newp->GetGUID() : ObjectGuid::Empty; if (!victim || !IsOn(victim) || // allow make moderator from another team only if both is GMs @@ -638,7 +639,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo void Channel::SetOwner(Player const* player, std::string const& newname) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(guid)) @@ -659,7 +660,7 @@ void Channel::SetOwner(Player const* player, std::string const& newname) } Player* newp = ObjectAccessor::FindPlayerByName(newname, false); - uint64 victim = newp ? newp->GetGUID() : 0; + ObjectGuid victim = newp ? newp->GetGUID() : ObjectGuid::Empty; if (!victim || !IsOn(victim) || (newp->GetTeamId() != player->GetTeamId() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))) @@ -673,7 +674,7 @@ void Channel::SetOwner(Player const* player, std::string const& newname) SetOwner(victim); } -void Channel::SendWhoOwner(uint64 guid) +void Channel::SendWhoOwner(ObjectGuid guid) { WorldPacket data; if (IsOn(guid)) @@ -685,7 +686,7 @@ void Channel::SendWhoOwner(uint64 guid) void Channel::List(Player const* player) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); if (!IsOn(guid)) { @@ -711,7 +712,7 @@ void Channel::List(Player const* player) for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i) if (AccountMgr::IsPlayerAccount(i->second.plrPtr->GetSession()->GetSecurity())) { - data << uint64(i->first); + data << i->first; data << uint8(i->second.flags); // flags seems to be changed... ++count; } @@ -723,7 +724,7 @@ void Channel::List(Player const* player) void Channel::Announce(Player const* player) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(guid)) @@ -762,7 +763,7 @@ void Channel::Announce(Player const* player) UpdateChannelInDB(); } -void Channel::Say(uint64 guid, std::string const& what, uint32 lang) +void Channel::Say(ObjectGuid guid, std::string const& what, uint32 lang) { if (what.empty()) return; @@ -814,7 +815,7 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang) else ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, _name); - SendToAll(&data, pinfo.IsModerator() ? 0 : guid); + SendToAll(&data, pinfo.IsModerator() ? ObjectGuid::Empty : guid); } void Channel::EveryoneSayToSelf(const char* what) @@ -845,7 +846,7 @@ void Channel::EveryoneSayToSelf(const char* what) void Channel::Invite(Player const* player, std::string const& newname) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); if (!IsOn(guid)) { @@ -888,7 +889,7 @@ void Channel::Invite(Player const* player, std::string const& newname) return; } - if (!newp->GetSocial()->HasIgnore(GUID_LOPART(guid))) + if (!newp->GetSocial()->HasIgnore(guid)) { WorldPacket data; MakeInvite(&data, guid); @@ -901,7 +902,7 @@ void Channel::Invite(Player const* player, std::string const& newname) SendToOne(&data, guid); } -void Channel::SetOwner(uint64 guid, bool exclaim) +void Channel::SetOwner(ObjectGuid guid, bool exclaim) { if (_ownerGUID) { @@ -950,23 +951,23 @@ void Channel::SetOwner(uint64 guid, bool exclaim) } } -void Channel::SendToAll(WorldPacket* data, uint64 guid) +void Channel::SendToAll(WorldPacket* data, ObjectGuid guid) { for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i) - if (!guid || !i->second.plrPtr->GetSocial()->HasIgnore(GUID_LOPART(guid))) + if (!guid || !i->second.plrPtr->GetSocial()->HasIgnore(guid)) i->second.plrPtr->GetSession()->SendPacket(data); } -void Channel::SendToAllButOne(WorldPacket* data, uint64 who) +void Channel::SendToAllButOne(WorldPacket* data, ObjectGuid who) { for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i) if (i->first != who) i->second.plrPtr->GetSession()->SendPacket(data); } -void Channel::SendToOne(WorldPacket* data, uint64 who) +void Channel::SendToOne(WorldPacket* data, ObjectGuid who) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(who)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(who)) player->GetSession()->SendPacket(data); } @@ -976,11 +977,11 @@ void Channel::SendToAllWatching(WorldPacket* data) (*i)->GetSession()->SendPacket(data); } -void Channel::Voice(uint64 /*guid1*/, uint64 /*guid2*/) +void Channel::Voice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/) { } -void Channel::DeVoice(uint64 /*guid1*/, uint64 /*guid2*/) +void Channel::DeVoice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/) { } @@ -991,16 +992,16 @@ void Channel::MakeNotifyPacket(WorldPacket* data, uint8 notify_type) *data << _name; } -void Channel::MakeJoined(WorldPacket* data, uint64 guid) +void Channel::MakeJoined(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_JOINED_NOTICE); - *data << uint64(guid); + *data << guid; } -void Channel::MakeLeft(WorldPacket* data, uint64 guid) +void Channel::MakeLeft(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_LEFT_NOTICE); - *data << uint64(guid); + *data << guid; } void Channel::MakeYouJoined(WorldPacket* data) @@ -1033,16 +1034,16 @@ void Channel::MakeNotModerator(WorldPacket* data) MakeNotifyPacket(data, CHAT_NOT_MODERATOR_NOTICE); } -void Channel::MakePasswordChanged(WorldPacket* data, uint64 guid) +void Channel::MakePasswordChanged(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE); - *data << uint64(guid); + *data << guid; } -void Channel::MakeOwnerChanged(WorldPacket* data, uint64 guid) +void Channel::MakeOwnerChanged(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE); - *data << uint64(guid); + *data << guid; } void Channel::MakePlayerNotFound(WorldPacket* data, std::string const& name) @@ -1060,31 +1061,31 @@ void Channel::MakeChannelOwner(WorldPacket* data) { std::string name = ""; - if (!sObjectMgr->GetPlayerNameByGUID(_ownerGUID, name) || name.empty()) + if (!sObjectMgr->GetPlayerNameByGUID(_ownerGUID.GetCounter(), name) || name.empty()) name = "PLAYER_NOT_FOUND"; MakeNotifyPacket(data, CHAT_CHANNEL_OWNER_NOTICE); *data << ((IsConstant() || !_ownerGUID) ? "Nobody" : name); } -void Channel::MakeModeChange(WorldPacket* data, uint64 guid, uint8 oldflags) +void Channel::MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags) { MakeNotifyPacket(data, CHAT_MODE_CHANGE_NOTICE); - *data << uint64(guid); + *data << guid; *data << uint8(oldflags); *data << uint8(GetPlayerFlags(guid)); } -void Channel::MakeAnnouncementsOn(WorldPacket* data, uint64 guid) +void Channel::MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE); - *data << uint64(guid); + *data << guid; } -void Channel::MakeAnnouncementsOff(WorldPacket* data, uint64 guid) +void Channel::MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE); - *data << uint64(guid); + *data << guid; } void Channel::MakeMuted(WorldPacket* data) @@ -1092,11 +1093,11 @@ void Channel::MakeMuted(WorldPacket* data) MakeNotifyPacket(data, CHAT_MUTED_NOTICE); } -void Channel::MakePlayerKicked(WorldPacket* data, uint64 bad, uint64 good) +void Channel::MakePlayerKicked(WorldPacket* data, ObjectGuid bad, ObjectGuid good) { MakeNotifyPacket(data, CHAT_PLAYER_KICKED_NOTICE); - *data << uint64(bad); - *data << uint64(good); + *data << bad; + *data << good; } void Channel::MakeBanned(WorldPacket* data) @@ -1104,18 +1105,18 @@ void Channel::MakeBanned(WorldPacket* data) MakeNotifyPacket(data, CHAT_BANNED_NOTICE); } -void Channel::MakePlayerBanned(WorldPacket* data, uint64 bad, uint64 good) +void Channel::MakePlayerBanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good) { MakeNotifyPacket(data, CHAT_PLAYER_BANNED_NOTICE); - *data << uint64(bad); - *data << uint64(good); + *data << bad; + *data << good; } -void Channel::MakePlayerUnbanned(WorldPacket* data, uint64 bad, uint64 good) +void Channel::MakePlayerUnbanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good) { MakeNotifyPacket(data, CHAT_PLAYER_UNBANNED_NOTICE); - *data << uint64(bad); - *data << uint64(good); + *data << bad; + *data << good; } void Channel::MakePlayerNotBanned(WorldPacket* data, const std::string& name) @@ -1124,16 +1125,16 @@ void Channel::MakePlayerNotBanned(WorldPacket* data, const std::string& name) *data << name; } -void Channel::MakePlayerAlreadyMember(WorldPacket* data, uint64 guid) +void Channel::MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE); - *data << uint64(guid); + *data << guid; } -void Channel::MakeInvite(WorldPacket* data, uint64 guid) +void Channel::MakeInvite(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_INVITE_NOTICE); - *data << uint64(guid); + *data << guid; } void Channel::MakeInviteWrongFaction(WorldPacket* data) @@ -1183,16 +1184,16 @@ void Channel::MakeNotInLfg(WorldPacket* data) MakeNotifyPacket(data, CHAT_NOT_IN_LFG_NOTICE); } -void Channel::MakeVoiceOn(WorldPacket* data, uint64 guid) +void Channel::MakeVoiceOn(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE); - *data << uint64(guid); + *data << guid; } -void Channel::MakeVoiceOff(WorldPacket* data, uint64 guid) +void Channel::MakeVoiceOff(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE); - *data << uint64(guid); + *data << guid; } void Channel::JoinNotify(Player* p) @@ -1203,7 +1204,7 @@ void Channel::JoinNotify(Player* p) return; WorldPacket data(SMSG_USERLIST_ADD, 8 + 1 + 1 + 4 + GetName().size()); - data << uint64(p->GetGUID()); + data << p->GetGUID(); data << uint8(GetPlayerFlags(p->GetGUID())); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); @@ -1220,7 +1221,7 @@ void Channel::LeaveNotify(Player* p) return; WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size()); - data << uint64(p->GetGUID()); + data << p->GetGUID(); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); data << GetName(); @@ -1236,7 +1237,7 @@ void Channel::FlagsNotify(Player* p) return; WorldPacket data(SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size()); - data << uint64(p->GetGUID()); + data << p->GetGUID(); data << uint8(GetPlayerFlags(p->GetGUID())); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); @@ -1261,7 +1262,7 @@ void Channel::RemoveWatching(Player* p) void Channel::ToggleModeration(Player* player) { - uint64 guid = player->GetGUIDLow(); + ObjectGuid guid = player->GetGUID(); if (!IsOn(guid)) { @@ -1298,14 +1299,14 @@ void Channel::ToggleModeration(Player* player) SendToAll(&data); } -void Channel::MakeModerationOn(WorldPacket* data, uint64 guid) +void Channel::MakeModerationOn(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_MODERATION_ON_NOTICE); - *data << uint64(guid); + *data << guid; } -void Channel::MakeModerationOff(WorldPacket* data, uint64 guid) +void Channel::MakeModerationOff(WorldPacket* data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_MODERATION_OFF_NOTICE); - *data << uint64(guid); + *data << guid; } diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h index f451be8519..845b1f81c1 100644 --- a/src/server/game/Chat/Channels/Channel.h +++ b/src/server/game/Chat/Channels/Channel.h @@ -135,7 +135,7 @@ class Channel { struct PlayerInfo { - uint64 player; + ObjectGuid player; uint8 flags; uint64 lastSpeakTime; // pussywizard Player* plrPtr; // pussywizard @@ -194,25 +194,25 @@ public: void KickOrBan(Player const* player, std::string const& badname, bool ban); void Kick(Player const* player, std::string const& badname) { KickOrBan(player, badname, false); } void Ban(Player const* player, std::string const& badname) { KickOrBan(player, badname, true); } - void AddBan(uint32 guid, uint32 time) { bannedStore[guid] = time; } + void AddBan(ObjectGuid guid, uint32 time) { bannedStore[guid] = time; } void UnBan(Player const* player, std::string const& badname); - void UnBan(uint64 guid); + void UnBan(ObjectGuid guid); void Password(Player const* player, std::string const& pass); void SetMode(Player const* player, std::string const& p2n, bool mod, bool set); - void SetOwner(uint64 guid, bool exclaim = true); + void SetOwner(ObjectGuid guid, bool exclaim = true); void SetOwner(Player const* player, std::string const& name); - void SendWhoOwner(uint64 guid); + void SendWhoOwner(ObjectGuid guid); void SetModerator(Player const* player, std::string const& newname) { SetMode(player, newname, true, true); } void UnsetModerator(Player const* player, std::string const& newname) { SetMode(player, newname, true, false); } void SetMute(Player const* player, std::string const& newname) { SetMode(player, newname, false, true); } void UnsetMute(Player const* player, std::string const& newname) { SetMode(player, newname, false, false); } void List(Player const* player); void Announce(Player const* player); - void Say(uint64 guid, std::string const& what, uint32 lang); + void Say(ObjectGuid guid, std::string const& what, uint32 lang); void EveryoneSayToSelf(const char* what); void Invite(Player const* player, std::string const& newp); - void Voice(uint64 guid1, uint64 guid2); - void DeVoice(uint64 guid1, uint64 guid2); + void Voice(ObjectGuid guid1, ObjectGuid guid2); + void DeVoice(ObjectGuid guid1, ObjectGuid guid2); void JoinNotify(Player* p); void LeaveNotify(Player* p); void FlagsNotify(Player* p); @@ -227,63 +227,63 @@ private: // initial packet data (notify type and channel name) void MakeNotifyPacket(WorldPacket* data, uint8 notify_type); // type specific packet data - void MakeJoined(WorldPacket* data, uint64 guid); //+ 0x00 - void MakeLeft(WorldPacket* data, uint64 guid); //+ 0x01 - void MakeYouJoined(WorldPacket* data); //+ 0x02 - void MakeYouLeft(WorldPacket* data); //+ 0x03 - void MakeWrongPassword(WorldPacket* data); //? 0x04 - void MakeNotMember(WorldPacket* data); //? 0x05 - void MakeNotModerator(WorldPacket* data); //? 0x06 - void MakePasswordChanged(WorldPacket* data, uint64 guid); //+ 0x07 - void MakeOwnerChanged(WorldPacket* data, uint64 guid); //? 0x08 - void MakePlayerNotFound(WorldPacket* data, std::string const& name); //+ 0x09 - void MakeNotOwner(WorldPacket* data); //? 0x0A - void MakeChannelOwner(WorldPacket* data); //? 0x0B - void MakeModeChange(WorldPacket* data, uint64 guid, uint8 oldflags); //+ 0x0C - void MakeAnnouncementsOn(WorldPacket* data, uint64 guid); //+ 0x0D - void MakeAnnouncementsOff(WorldPacket* data, uint64 guid); //+ 0x0E - void MakeMuted(WorldPacket* data); //? 0x11 - void MakePlayerKicked(WorldPacket* data, uint64 bad, uint64 good); //? 0x12 - void MakeBanned(WorldPacket* data); //? 0x13 - void MakePlayerBanned(WorldPacket* data, uint64 bad, uint64 good); //? 0x14 - void MakePlayerUnbanned(WorldPacket* data, uint64 bad, uint64 good); //? 0x15 - void MakePlayerNotBanned(WorldPacket* data, std::string const& name); //? 0x16 - void MakePlayerAlreadyMember(WorldPacket* data, uint64 guid); //+ 0x17 - void MakeInvite(WorldPacket* data, uint64 guid); //? 0x18 - void MakeInviteWrongFaction(WorldPacket* data); //? 0x19 - void MakeWrongFaction(WorldPacket* data); //? 0x1A - void MakeInvalidName(WorldPacket* data); //? 0x1B - void MakeNotModerated(WorldPacket* data); //? 0x1C - void MakePlayerInvited(WorldPacket* data, std::string const& name); //+ 0x1D - void MakePlayerInviteBanned(WorldPacket* data, std::string const& name);//? 0x1E - void MakeThrottled(WorldPacket* data); //? 0x1F - void MakeNotInArea(WorldPacket* data); //? 0x20 - void MakeNotInLfg(WorldPacket* data); //? 0x21 - void MakeVoiceOn(WorldPacket* data, uint64 guid); //+ 0x22 - void MakeVoiceOff(WorldPacket* data, uint64 guid); //+ 0x23 - void MakeModerationOn(WorldPacket* data, uint64 guid); - void MakeModerationOff(WorldPacket* data, uint64 guid); + void MakeJoined(WorldPacket* data, ObjectGuid guid); //+ 0x00 + void MakeLeft(WorldPacket* data, ObjectGuid guid); //+ 0x01 + void MakeYouJoined(WorldPacket* data); //+ 0x02 + void MakeYouLeft(WorldPacket* data); //+ 0x03 + void MakeWrongPassword(WorldPacket* data); //? 0x04 + void MakeNotMember(WorldPacket* data); //? 0x05 + void MakeNotModerator(WorldPacket* data); //? 0x06 + void MakePasswordChanged(WorldPacket* data, ObjectGuid guid); //+ 0x07 + void MakeOwnerChanged(WorldPacket* data, ObjectGuid guid); //? 0x08 + void MakePlayerNotFound(WorldPacket* data, std::string const& name); //+ 0x09 + void MakeNotOwner(WorldPacket* data); //? 0x0A + void MakeChannelOwner(WorldPacket* data); //? 0x0B + void MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags); //+ 0x0C + void MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid); //+ 0x0D + void MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid); //+ 0x0E + void MakeMuted(WorldPacket* data); //? 0x11 + void MakePlayerKicked(WorldPacket* data, ObjectGuid bad, ObjectGuid good); //? 0x12 + void MakeBanned(WorldPacket* data); //? 0x13 + void MakePlayerBanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good); //? 0x14 + void MakePlayerUnbanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good);//? 0x15 + void MakePlayerNotBanned(WorldPacket* data, std::string const& name); //? 0x16 + void MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid); //+ 0x17 + void MakeInvite(WorldPacket* data, ObjectGuid guid); //? 0x18 + void MakeInviteWrongFaction(WorldPacket* data); //? 0x19 + void MakeWrongFaction(WorldPacket* data); //? 0x1A + void MakeInvalidName(WorldPacket* data); //? 0x1B + void MakeNotModerated(WorldPacket* data); //? 0x1C + void MakePlayerInvited(WorldPacket* data, std::string const& name); //+ 0x1D + void MakePlayerInviteBanned(WorldPacket* data, std::string const& name); //? 0x1E + void MakeThrottled(WorldPacket* data); //? 0x1F + void MakeNotInArea(WorldPacket* data); //? 0x20 + void MakeNotInLfg(WorldPacket* data); //? 0x21 + void MakeVoiceOn(WorldPacket* data, ObjectGuid guid); //+ 0x22 + void MakeVoiceOff(WorldPacket* data, ObjectGuid guid); //+ 0x23 + void MakeModerationOn(WorldPacket* data, ObjectGuid guid); + void MakeModerationOff(WorldPacket* data, ObjectGuid guid); - void SendToAll(WorldPacket* data, uint64 guid = 0); - void SendToAllButOne(WorldPacket* data, uint64 who); - void SendToOne(WorldPacket* data, uint64 who); + void SendToAll(WorldPacket* data, ObjectGuid guid = ObjectGuid::Empty); + void SendToAllButOne(WorldPacket* data, ObjectGuid who); + void SendToOne(WorldPacket* data, ObjectGuid who); void SendToAllWatching(WorldPacket* data); - bool IsOn(uint64 who) const { return playersStore.find(who) != playersStore.end(); } - bool IsBanned(uint64 guid) const; + bool IsOn(ObjectGuid who) const { return playersStore.find(who) != playersStore.end(); } + bool IsBanned(ObjectGuid guid) const; void UpdateChannelInDB() const; void UpdateChannelUseageInDB() const; - void AddChannelBanToDB(uint32 guid, uint32 time) const; - void RemoveChannelBanFromDB(uint32 guid) const; + void AddChannelBanToDB(ObjectGuid guid, uint32 time) const; + void RemoveChannelBanFromDB(ObjectGuid guid) const; - uint8 GetPlayerFlags(uint64 guid) const + uint8 GetPlayerFlags(ObjectGuid guid) const { PlayerContainer::const_iterator itr = playersStore.find(guid); return itr != playersStore.end() ? itr->second.flags : 0; } - void SetModerator(uint64 guid, bool set) + void SetModerator(ObjectGuid guid, bool set) { PlayerInfo& pinfo = playersStore[guid]; if (pinfo.IsModerator() != set) @@ -299,7 +299,7 @@ private: } } - void SetMute(uint64 guid, bool set) + void SetMute(ObjectGuid guid, bool set) { PlayerInfo& pinfo = playersStore[guid]; if (pinfo.IsMuted() != set) @@ -313,8 +313,8 @@ private: } } - typedef std::unordered_map<uint64, PlayerInfo> PlayerContainer; - typedef std::unordered_map<uint32, uint32> BannedContainer; + typedef std::unordered_map<ObjectGuid, PlayerInfo> PlayerContainer; + typedef std::unordered_map<ObjectGuid, uint32> BannedContainer; typedef std::unordered_set<Player*> PlayersWatchingContainer; bool _announce; @@ -326,7 +326,7 @@ private: uint32 _channelId; uint32 _channelDBId; TeamId _teamId; - uint64 _ownerGUID; + ObjectGuid _ownerGUID; std::string _name; std::string _password; ChannelRights _channelRights; diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index d0d67b62c4..0e3ba0518b 100644 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -69,7 +69,7 @@ void ChannelMgr::LoadChannels() Field* banFields = banResult->Fetch(); if (!banFields) break; - newChannel->AddBan(banFields[0].GetUInt32(), banFields[1].GetUInt32()); + newChannel->AddBan(ObjectGuid::Create<HighGuid::Player>(banFields[0].GetUInt32()), banFields[1].GetUInt32()); } while (banResult->NextRow()); } diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 75a45b4c7b..9137f4423c 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -79,7 +79,7 @@ bool ChatHandler::isAvailable(ChatCommand const& cmd) const return m_session->GetSecurity() >= AccountTypes(cmd.SecurityLevel); } -bool ChatHandler::HasLowerSecurity(Player* target, uint64 guid, bool strong) +bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong) { WorldSession* target_session = nullptr; uint32 target_account = 0; @@ -87,7 +87,7 @@ bool ChatHandler::HasLowerSecurity(Player* target, uint64 guid, bool strong) if (target) target_session = target->GetSession(); else if (guid) - target_account = sObjectMgr->GetPlayerAccountIdByGUID(guid); + target_account = sObjectMgr->GetPlayerAccountIdByGUID(guid.GetCounter()); if (!target_session && !target_account) { @@ -304,7 +304,7 @@ bool ChatHandler::ExecuteCommandInTable(std::vector<ChatCommand> const& table, c Player* player = m_session->GetPlayer(); if (!AccountMgr::IsPlayerAccount(m_session->GetSecurity())) { - uint64 guid = player->GetTarget(); + ObjectGuid guid = player->GetTarget(); uint32 areaId = player->GetAreaId(); std::string areaName = "Unknown"; std::string zoneName = "Unknown"; @@ -316,20 +316,14 @@ bool ChatHandler::ExecuteCommandInTable(std::vector<ChatCommand> const& table, c zoneName = zone->area_name[locale]; } - LOG_GM(m_session->GetAccountId(), "Command: %s [Player: %s (%u) (Account: %u) X: %f Y: %f Z: %f Map: %u (%s) Area: %u (%s) Zone: %s Selected: %s (%ul)]", - fullcmd.c_str(), - player->GetName().c_str(), - GUID_LOPART(player->GetGUID()), - m_session->GetAccountId(), - player->GetPositionX(), - player->GetPositionY(), - player->GetPositionZ(), - player->GetMapId(), - player->GetMap()->GetMapName(), - areaId, areaName.c_str(), - zoneName.c_str(), - (player->GetSelectedUnit()) ? player->GetSelectedUnit()->GetName().c_str() : "", - GUID_LOPART(guid)); + LOG_GM(m_session->GetAccountId(), "Command: %s [Player: %s (%s) (Account: %u) X: %f Y: %f Z: %f Map: %u (%s) Area: %u (%s) Zone: %s Selected: %s (%s)]", + fullcmd.c_str(), player->GetName().c_str(), player->GetGUID().ToString().c_str(), + m_session->GetAccountId(), player->GetPositionX(), player->GetPositionY(), + player->GetPositionZ(), player->GetMapId(), + player->GetMap()->GetMapName(), + areaId, areaName.c_str(), zoneName.c_str(), + (player->GetSelectedUnit()) ? player->GetSelectedUnit()->GetName().c_str() : "", + guid.ToString().c_str()); } } // some commands have custom error messages. Don't send the default one in these cases. @@ -601,7 +595,7 @@ bool ChatHandler::ShowHelpForCommand(std::vector<ChatCommand> const& table, cons return ShowHelpForSubCommands(table, "", cmd); } -size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, uint64 senderGUID, uint64 receiverGUID, std::string const& message, uint8 chatTag, +size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string const& message, uint8 chatTag, std::string const& senderName /*= ""*/, std::string const& receiverName /*= ""*/, uint32 achievementId /*= 0*/, bool gmMessage /*= false*/, std::string const& channelName /*= ""*/) { @@ -609,7 +603,7 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag data.Initialize(!gmMessage ? SMSG_MESSAGECHAT : SMSG_GM_MESSAGECHAT); data << uint8(chatType); data << int32(language); - data << uint64(senderGUID); + data << senderGUID; data << uint32(0); // some flags switch (chatType) { @@ -624,8 +618,8 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag data << uint32(senderName.length() + 1); data << senderName; receiverGUIDPos = data.wpos(); - data << uint64(receiverGUID); - if (receiverGUID && !IS_PLAYER_GUID(receiverGUID) && !IS_PET_GUID(receiverGUID)) + data << receiverGUID; + if (receiverGUID && !receiverGUID.IsPlayer() && !receiverGUID.IsPet()) { data << uint32(receiverName.length() + 1); data << receiverName; @@ -635,14 +629,14 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag data << uint32(senderName.length() + 1); data << senderName; receiverGUIDPos = data.wpos(); - data << uint64(receiverGUID); + data << receiverGUID; break; case CHAT_MSG_BG_SYSTEM_NEUTRAL: case CHAT_MSG_BG_SYSTEM_ALLIANCE: case CHAT_MSG_BG_SYSTEM_HORDE: receiverGUIDPos = data.wpos(); - data << uint64(receiverGUID); - if (receiverGUID && !IS_PLAYER_GUID(receiverGUID)) + data << receiverGUID; + if (receiverGUID && !receiverGUID.IsPlayer()) { data << uint32(receiverName.length() + 1); data << receiverName; @@ -651,7 +645,7 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag case CHAT_MSG_ACHIEVEMENT: case CHAT_MSG_GUILD_ACHIEVEMENT: receiverGUIDPos = data.wpos(); - data << uint64(receiverGUID); + data << receiverGUID; break; default: if (gmMessage) @@ -667,7 +661,7 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag } receiverGUIDPos = data.wpos(); - data << uint64(receiverGUID); + data << receiverGUID; break; } @@ -684,11 +678,11 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, WorldObject const* sender, WorldObject const* receiver, std::string const& message, uint32 achievementId /*= 0*/, std::string const& channelName /*= ""*/, LocaleConstant locale /*= DEFAULT_LOCALE*/) { - uint64 senderGUID = 0; + ObjectGuid senderGUID; std::string senderName = ""; uint8 chatTag = 0; bool gmMessage = false; - uint64 receiverGUID = 0; + ObjectGuid receiverGUID; std::string receiverName = ""; if (sender) { @@ -715,11 +709,11 @@ Player* ChatHandler::getSelectedPlayer() if (!m_session) return nullptr; - uint64 selected = m_session->GetPlayer()->GetTarget(); + ObjectGuid selected = m_session->GetPlayer()->GetTarget(); if (!selected) return m_session->GetPlayer(); - return ObjectAccessor::FindPlayerInOrOutOfWorld(selected); + return ObjectAccessor::FindConnectedPlayer(selected); } Unit* ChatHandler::getSelectedUnit() @@ -738,9 +732,9 @@ WorldObject* ChatHandler::getSelectedObject() if (!m_session) return nullptr; - uint64 guid = m_session->GetPlayer()->GetTarget(); + ObjectGuid guid = m_session->GetPlayer()->GetTarget(); - if (guid == 0) + if (!guid) return GetNearbyGameObject(); return ObjectAccessor::GetUnit(*m_session->GetPlayer(), guid); @@ -759,12 +753,12 @@ Player* ChatHandler::getSelectedPlayerOrSelf() if (!m_session) return nullptr; - uint64 selected = m_session->GetPlayer()->GetTarget(); + ObjectGuid selected = m_session->GetPlayer()->GetTarget(); if (!selected) return m_session->GetPlayer(); // first try with selected target - Player* targetPlayer = ObjectAccessor::FindPlayerInOrOutOfWorld(selected); + Player* targetPlayer = ObjectAccessor::FindConnectedPlayer(selected); // if the target is not a player, then return self if (!targetPlayer) targetPlayer = m_session->GetPlayer(); @@ -897,29 +891,35 @@ GameObject* ChatHandler::GetNearbyGameObject() return obj; } -GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry) +Creature* ChatHandler::GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid) { if (!m_session) return nullptr; - Player* pl = m_session->GetPlayer(); - - GameObject* obj = pl->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT)); + // Select the first alive creature or a dead one if not found + Creature* creature = nullptr; - if (!obj && sObjectMgr->GetGOData(lowguid)) // guid is DB guid of object + auto bounds = m_session->GetPlayer()->GetMap()->GetCreatureBySpawnIdStore().equal_range(lowguid); + for (auto it = bounds.first; it != bounds.second; ++it) { - // search near player then - CellCoord p(acore::ComputeCellCoord(pl->GetPositionX(), pl->GetPositionY())); - Cell cell(p); + creature = it->second; + if (it->second->IsAlive()) + break; + } - acore::GameObjectWithDbGUIDCheck go_check(lowguid); - acore::GameObjectSearcher<acore::GameObjectWithDbGUIDCheck> checker(pl, obj, go_check); + return creature; +} - TypeContainerVisitor<acore::GameObjectSearcher<acore::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker); - cell.Visit(p, object_checker, *pl->GetMap(), *pl, pl->GetGridActivationRange()); - } +GameObject* ChatHandler::GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid) +{ + if (!m_session) + return nullptr; - return obj; + auto bounds = m_session->GetPlayer()->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid); + if (bounds.first != bounds.second) + return bounds.first->second; + + return nullptr; } enum SpellLinkType @@ -1025,7 +1025,7 @@ static char const* const guidKeys[] = 0 }; -uint64 ChatHandler::extractGuidFromLink(char* text) +ObjectGuid::LowType ChatHandler::extractLowGuidFromLink(char* text, HighGuid& guidHigh) { int type = 0; @@ -1040,33 +1040,39 @@ uint64 ChatHandler::extractGuidFromLink(char* text) { case SPELL_LINK_PLAYER: { + guidHigh = HighGuid::Player; + std::string name = idS; if (!normalizePlayerName(name)) return 0; if (Player* player = ObjectAccessor::FindPlayerByName(name, false)) - return player->GetGUID(); + return player->GetGUID().GetCounter(); - if (uint64 guid = sObjectMgr->GetPlayerGUIDByName(name)) - return guid; + if (ObjectGuid guid = sObjectMgr->GetPlayerGUIDByName(name)) + return guid.GetCounter(); return 0; } case SPELL_LINK_CREATURE: { - uint32 lowguid = (uint32)atol(idS); + guidHigh = HighGuid::Unit; + + ObjectGuid::LowType lowguid = (uint32)atol(idS); - if (CreatureData const* data = sObjectMgr->GetCreatureData(lowguid)) - return MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT); + if (sObjectMgr->GetCreatureData(lowguid)) + return lowguid; else return 0; } case SPELL_LINK_GAMEOBJECT: { - uint32 lowguid = (uint32)atol(idS); + guidHigh = HighGuid::GameObject; + + ObjectGuid::LowType lowguid = (uint32)atol(idS); - if (GameObjectData const* data = sObjectMgr->GetGOData(lowguid)) - return MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_GAMEOBJECT); + if (sObjectMgr->GetGOData(lowguid)) + return lowguid; else return 0; } @@ -1090,7 +1096,7 @@ std::string ChatHandler::extractPlayerNameFromLink(char* text) return name; } -bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* player_guid /*=nullptr*/, std::string* player_name /*= nullptr*/) +bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*=nullptr*/, std::string* player_name /*= nullptr*/) { if (args && *args) { @@ -1109,7 +1115,7 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe *player = pl; // if need guid value from DB (in name case for check player existence) - uint64 guid = !pl && (player_guid || player_name) ? sObjectMgr->GetPlayerGUIDByName(name) : 0; + ObjectGuid guid = !pl && (player_guid || player_name) ? sObjectMgr->GetPlayerGUIDByName(name) : ObjectGuid::Empty; // if allowed player guid (if no then only online players allowed) if (player_guid) @@ -1126,7 +1132,7 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe *player = pl; // if allowed player guid (if no then only online players allowed) if (player_guid) - *player_guid = pl ? pl->GetGUID() : 0; + *player_guid = pl ? pl->GetGUID() : ObjectGuid::Empty; if (player_name) *player_name = pl ? pl->GetName() : ""; @@ -1249,10 +1255,10 @@ bool CliHandler::needReportToTarget(Player* /*chr*/) const return true; } -bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, uint64& guid, bool offline) +bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline) { - player = nullptr; - guid = 0; + player = nullptr; + guid = ObjectGuid::Empty; if (cname) { diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index 967e8b9e84..05405f4db5 100644 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -45,7 +45,7 @@ public: virtual ~ChatHandler() { } // Builds chat packet and returns receiver guid position in the packet to substitute in whisper builders - static size_t BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, uint64 senderGUID, uint64 receiverGUID, std::string const& message, uint8 chatTag, + static size_t BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string const& message, uint8 chatTag, std::string const& senderName = "", std::string const& receiverName = "", uint32 achievementId = 0, bool gmMessage = false, std::string const& channelName = ""); @@ -79,7 +79,7 @@ public: virtual LocaleConstant GetSessionDbcLocale() const; virtual int GetSessionDbLocaleIndex() const; - bool HasLowerSecurity(Player* target, uint64 guid, bool strong = false); + bool HasLowerSecurity(Player* target, ObjectGuid guid = ObjectGuid::Empty, bool strong = false); bool HasLowerSecurityAccount(WorldSession* target, uint32 account, bool strong = false); void SendGlobalGMSysMessage(const char* str); @@ -98,18 +98,19 @@ public: char* extractQuotedArg(char* args); uint32 extractSpellIdFromLink(char* text); - uint64 extractGuidFromLink(char* text); + ObjectGuid::LowType extractLowGuidFromLink(char* text, HighGuid& guidHigh); GameTele const* extractGameTeleFromLink(char* text); - bool GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, uint64& guid, bool offline = false); + bool GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline = false); std::string extractPlayerNameFromLink(char* text); // select by arg (name/link) or in-game selection online/offline player - bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = nullptr, std::string* player_name = nullptr); + bool extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid = nullptr, std::string* player_name = nullptr); std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:" + name + "|h[" + name + "]|h|r" : name; } std::string GetNameLink(Player* chr) const; GameObject* GetNearbyGameObject(); - GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry); + GameObject* GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid); + Creature* GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid); bool HasSentErrorMessage() const { return sentErrorMessage; } void SetSentErrorMessage(bool val) { sentErrorMessage = val; } static bool LoadCommandTable() { return load_command_table; } diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index 8e570b9cb2..f6ff3cc58b 100644 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -244,7 +244,7 @@ HostileReference* ThreatContainer::getReferenceByTarget(Unit* victim) const if (!victim) return nullptr; - uint64 const guid = victim->GetGUID(); + ObjectGuid const guid = victim->GetGUID(); for (ThreatContainer::StorageType::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { HostileReference* ref = (*i); diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h index 5b7848c1fc..70a2ab832c 100644 --- a/src/server/game/Combat/ThreatManager.h +++ b/src/server/game/Combat/ThreatManager.h @@ -84,7 +84,7 @@ public: //================================================= - [[nodiscard]] uint64 getUnitGuid() const { return iUnitGuid; } + [[nodiscard]] ObjectGuid getUnitGuid() const { return iUnitGuid; } //================================================= // reference is not needed anymore. realy delete it ! @@ -113,7 +113,7 @@ private: private: float iThreat; float iTempThreatModifier; // used for taunt - uint64 iUnitGuid; + ObjectGuid iUnitGuid; bool iOnline; }; diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 48220eee01..ce3e015a3b 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -170,12 +170,15 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) case INSTANCE_INFO_DATA: condMeets = instance->GetData(ConditionValue1) == ConditionValue2; break; - case INSTANCE_INFO_DATA64: - condMeets = instance->GetData64(ConditionValue1) == ConditionValue2; + 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; + case INSTANCE_INFO_DATA64: + condMeets = instance->GetData64(ConditionValue1) == ConditionValue2; + break; } } } @@ -230,10 +233,10 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) switch (object->GetTypeId()) { case TYPEID_UNIT: - condMeets &= object->ToCreature()->GetDBTableGUIDLow() == ConditionValue3; + condMeets &= object->ToCreature()->GetSpawnId() == ConditionValue3; break; case TYPEID_GAMEOBJECT: - condMeets &= object->ToGameObject()->GetDBTableGUIDLow() == ConditionValue3; + condMeets &= object->ToGameObject()->GetSpawnId() == ConditionValue3; break; default: break; diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 1a536c995d..e36ecd0f9f 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -153,8 +153,9 @@ enum RelationType enum InstanceInfo { INSTANCE_INFO_DATA = 0, - INSTANCE_INFO_DATA64, - INSTANCE_INFO_BOSS_STATE + INSTANCE_INFO_GUID_DATA, + INSTANCE_INFO_BOSS_STATE, + INSTANCE_INFO_DATA64 }; enum diff --git a/src/server/game/DungeonFinding/LFG.h b/src/server/game/DungeonFinding/LFG.h index 2062924e57..25d3aa988b 100644 --- a/src/server/game/DungeonFinding/LFG.h +++ b/src/server/game/DungeonFinding/LFG.h @@ -9,9 +9,12 @@ #include "Common.h" #include "ObjectDefines.h" +#include "ObjectGuid.h" #include "SharedDefines.h" #include "WorldPacket.h" +#include <array> + namespace lfg { @@ -93,68 +96,68 @@ namespace lfg typedef std::list<Lfg5Guids> Lfg5GuidsList; typedef std::set<uint32> LfgDungeonSet; typedef std::map<uint32, uint32> LfgLockMap; - typedef std::map<uint64, LfgLockMap> LfgLockPartyMap; - typedef std::set<uint64> LfgGuidSet; - typedef std::list<uint64> LfgGuidList; - typedef std::map<uint64, uint8> LfgRolesMap; - typedef std::map<uint64, uint64> LfgGroupsMap; + typedef std::map<ObjectGuid, LfgLockMap> LfgLockPartyMap; + typedef GuidSet LfgGuidSet; + typedef GuidList LfgGuidList; + typedef std::map<ObjectGuid, uint8> LfgRolesMap; + typedef std::map<ObjectGuid, ObjectGuid> LfgGroupsMap; class Lfg5Guids { public: - uint64 guid[5]; + std::array<ObjectGuid, 5> guids = { }; LfgRolesMap* roles; Lfg5Guids() { - memset(&guid, 0, 5 * 8); + guids.fill(ObjectGuid::Empty); roles = nullptr; } - Lfg5Guids(uint64 g) + Lfg5Guids(ObjectGuid g) { - memset(&guid, 0, 5 * 8); - guid[0] = g; + guids.fill(ObjectGuid::Empty); + guids[0] = g; roles = nullptr; } Lfg5Guids(Lfg5Guids const& x) { - memcpy(guid, x.guid, 5 * 8); + guids = x.guids; roles = x.roles ? (new LfgRolesMap(*(x.roles))) : nullptr; } Lfg5Guids(Lfg5Guids const& x, bool /*copyRoles*/) { - memcpy(guid, x.guid, 5 * 8); + guids = x.guids; roles = nullptr; } ~Lfg5Guids() { delete roles; } void addRoles(LfgRolesMap const& r) { roles = new LfgRolesMap(r); } - void clear() { memset(&guid, 0, 5 * 8); } - bool empty() const { return guid[0] == 0; } - uint64 front() const { return guid[0]; } + void clear() { guids.fill(ObjectGuid::Empty); } + bool empty() const { return guids[0] == ObjectGuid::Empty; } + ObjectGuid front() const { return guids[0]; } uint8 size() const { - if (guid[2]) + if (guids[2]) { - if (guid[4]) + if (guids[4]) { return 5; } - else if (guid[3]) + else if (guids[3]) { return 4; } return 3; } - else if (guid[1]) + else if (guids[1]) { return 2; } - else if (guid[0]) + else if (guids[0]) { return 1; } @@ -162,289 +165,289 @@ namespace lfg return 0; } - void insert(const uint64& g) + void insert(const ObjectGuid& g) { // avoid loops for performance - if (guid[0] == 0) + if (!guids[0]) { - guid[0] = g; + guids[0] = g; return; } - if (g <= guid[0]) + if (g <= guids[0]) { - if (guid[3]) + if (guids[3]) { - guid[4] = guid[3]; + guids[4] = guids[3]; } - if (guid[2]) + if (guids[2]) { - guid[3] = guid[2]; + guids[3] = guids[2]; } - if (guid[1]) + if (guids[1]) { - guid[2] = guid[1]; + guids[2] = guids[1]; } - guid[1] = guid[0]; - guid[0] = g; + guids[1] = guids[0]; + guids[0] = g; return; } - if (guid[1] == 0) + if (!guids[1]) { - guid[1] = g; + guids[1] = g; return; } - if (g <= guid[1]) + if (g <= guids[1]) { - if (guid[3]) + if (guids[3]) { - guid[4] = guid[3]; + guids[4] = guids[3]; } - if (guid[2]) + if (guids[2]) { - guid[3] = guid[2]; + guids[3] = guids[2]; } - guid[2] = guid[1]; - guid[1] = g; + guids[2] = guids[1]; + guids[1] = g; return; } - if (guid[2] == 0) + if (!guids[2]) { - guid[2] = g; + guids[2] = g; return; } - if (g <= guid[2]) + if (g <= guids[2]) { - if (guid[3]) + if (guids[3]) { - guid[4] = guid[3]; + guids[4] = guids[3]; } - guid[3] = guid[2]; - guid[2] = g; + guids[3] = guids[2]; + guids[2] = g; return; } - if (guid[3] == 0) + if (!guids[3]) { - guid[3] = g; + guids[3] = g; return; } - if (g <= guid[3]) + if (g <= guids[3]) { - guid[4] = guid[3]; - guid[3] = g; + guids[4] = guids[3]; + guids[3] = g; return; } - guid[4] = g; + guids[4] = g; } - void force_insert_front(const uint64& g) + void force_insert_front(const ObjectGuid& g) { - if (guid[3]) + if (guids[3]) { - guid[4] = guid[3]; + guids[4] = guids[3]; } - if (guid[2]) + if (guids[2]) { - guid[3] = guid[2]; + guids[3] = guids[2]; } - if (guid[1]) + if (guids[1]) { - guid[2] = guid[1]; + guids[2] = guids[1]; } - guid[1] = guid[0]; - guid[0] = g; + guids[1] = guids[0]; + guids[0] = g; } - void remove(const uint64& g) + void remove(const ObjectGuid& g) { // avoid loops for performance - if (guid[0] == g) + if (guids[0] == g) { - if (guid[1]) + if (guids[1]) { - guid[0] = guid[1]; + guids[0] = guids[1]; } else { - guid[0] = 0; + guids[0].Clear(); return; } - if (guid[2]) + if (guids[2]) { - guid[1] = guid[2]; + guids[1] = guids[2]; } else { - guid[1] = 0; + guids[1].Clear(); return; } - if (guid[3]) + if (guids[3]) { - guid[2] = guid[3]; + guids[2] = guids[3]; } else { - guid[2] = 0; + guids[2].Clear(); return; } - if (guid[4]) + if (guids[4]) { - guid[3] = guid[4]; + guids[3] = guids[4]; } else { - guid[3] = 0; + guids[3].Clear(); return; } - guid[4] = 0; + guids[4].Clear(); return; } - if (guid[1] == g) + if (guids[1] == g) { - if (guid[2]) + if (guids[2]) { - guid[1] = guid[2]; + guids[1] = guids[2]; } else { - guid[1] = 0; + guids[1].Clear(); return; } - if (guid[3]) + if (guids[3]) { - guid[2] = guid[3]; + guids[2] = guids[3]; } else { - guid[2] = 0; + guids[2].Clear(); return; } - if (guid[4]) + if (guids[4]) { - guid[3] = guid[4]; + guids[3] = guids[4]; } else { - guid[3] = 0; + guids[3].Clear(); return; } - guid[4] = 0; + guids[4].Clear(); return; } - if (guid[2] == g) + if (guids[2] == g) { - if (guid[3]) + if (guids[3]) { - guid[2] = guid[3]; + guids[2] = guids[3]; } else { - guid[2] = 0; + guids[2].Clear(); return; } - if (guid[4]) + if (guids[4]) { - guid[3] = guid[4]; + guids[3] = guids[4]; } else { - guid[3] = 0; + guids[3].Clear(); return; } - guid[4] = 0; + guids[4].Clear(); return; } - if (guid[3] == g) + if (guids[3] == g) { - if (guid[4]) + if (guids[4]) { - guid[3] = guid[4]; + guids[3] = guids[4]; } else { - guid[3] = 0; + guids[3].Clear(); return; } - guid[4] = 0; + guids[4].Clear(); return; } - if (guid[4] == g) + if (guids[4] == g) { - guid[4] = 0; + guids[4].Clear(); } } - bool hasGuid(const uint64& g) const + bool hasGuid(const ObjectGuid& g) const { - return g && (guid[0] == g || guid[1] == g || guid[2] == g || guid[3] == g || guid[4] == g); + return g && (guids[0] == g || guids[1] == g || guids[2] == g || guids[3] == g || guids[4] == g); } bool operator<(const Lfg5Guids& x) const { - if (guid[0] <= x.guid[0]) + if (guids[0] <= x.guids[0]) { - if (guid[0] != x.guid[0]) + if (guids[0] != x.guids[0]) { return true; } - if (guid[1] <= x.guid[1]) + if (guids[1] <= x.guids[1]) { - if (guid[1] != x.guid[1]) + if (guids[1] != x.guids[1]) { return true; } - if (guid[2] <= x.guid[2]) + if (guids[2] <= x.guids[2]) { - if (guid[2] != x.guid[2]) + if (guids[2] != x.guids[2]) { return true; } - if (guid[3] <= x.guid[3]) + if (guids[3] <= x.guids[3]) { - if (guid[3] != x.guid[3]) + if (guids[3] != x.guids[3]) { return true; } - if (guid[4] <= x.guid[4]) + if (guids[4] <= x.guids[4]) { - return !(guid[4] == x.guid[4]); + return !(guids[4] == x.guids[4]); } } } @@ -456,12 +459,12 @@ namespace lfg bool operator==(const Lfg5Guids& x) const { - return guid[0] == x.guid[0] && guid[1] == x.guid[1] && guid[2] == x.guid[2] && guid[3] == x.guid[3] && guid[4] == x.guid[4]; + return guids[0] == x.guids[0] && guids[1] == x.guids[1] && guids[2] == x.guids[2] && guids[3] == x.guids[3] && guids[4] == x.guids[4]; } void operator=(const Lfg5Guids& x) { - memcpy(guid, x.guid, 5 * 8); + guids = x.guids; delete roles; roles = x.roles ? (new LfgRolesMap(*(x.roles))) : nullptr; } @@ -469,7 +472,7 @@ namespace lfg std::string toString() const // for debugging { std::ostringstream o; - o << GUID_LOPART(guid[0]) << "," << GUID_LOPART(guid[1]) << "," << GUID_LOPART(guid[2]) << "," << GUID_LOPART(guid[3]) << "," << GUID_LOPART(guid[4]) << ":" << (roles ? 1 : 0); + o << guids[0].ToString().c_str() << "," << guids[1].ToString().c_str() << "," << guids[2].ToString().c_str() << "," << guids[3].ToString().c_str() << "," << guids[4].ToString().c_str() << ":" << (roles ? 1 : 0); return o.str(); } }; diff --git a/src/server/game/DungeonFinding/LFGGroupData.cpp b/src/server/game/DungeonFinding/LFGGroupData.cpp index 11cde5be34..256f9f7034 100644 --- a/src/server/game/DungeonFinding/LFGGroupData.cpp +++ b/src/server/game/DungeonFinding/LFGGroupData.cpp @@ -11,7 +11,7 @@ namespace lfg { LfgGroupData::LfgGroupData(): m_State(LFG_STATE_NONE), m_OldState(LFG_STATE_NONE), - m_Leader(0), m_Dungeon(0), m_KicksLeft(LFG_GROUP_MAX_KICKS) + m_Dungeon(0), m_KicksLeft(LFG_GROUP_MAX_KICKS) { } LfgGroupData::~LfgGroupData() @@ -44,12 +44,12 @@ namespace lfg m_State = m_OldState; } - void LfgGroupData::AddPlayer(uint64 guid) + void LfgGroupData::AddPlayer(ObjectGuid guid) { m_Players.insert(guid); } - uint8 LfgGroupData::RemovePlayer(uint64 guid) + uint8 LfgGroupData::RemovePlayer(ObjectGuid guid) { LfgGuidSet::iterator it = m_Players.find(guid); if (it != m_Players.end()) @@ -62,7 +62,7 @@ namespace lfg m_Players.clear(); } - void LfgGroupData::SetLeader(uint64 guid) + void LfgGroupData::SetLeader(ObjectGuid guid) { m_Leader = guid; } @@ -98,7 +98,7 @@ namespace lfg return m_Players.size(); } - uint64 LfgGroupData::GetLeader() const + ObjectGuid LfgGroupData::GetLeader() const { return m_Leader; } diff --git a/src/server/game/DungeonFinding/LFGGroupData.h b/src/server/game/DungeonFinding/LFGGroupData.h index e7ea762a07..57a17149d3 100644 --- a/src/server/game/DungeonFinding/LFGGroupData.h +++ b/src/server/game/DungeonFinding/LFGGroupData.h @@ -31,10 +31,10 @@ namespace lfg // General void SetState(LfgState state); void RestoreState(); - void AddPlayer(uint64 guid); - uint8 RemovePlayer(uint64 guid); + void AddPlayer(ObjectGuid guid); + uint8 RemovePlayer(ObjectGuid guid); void RemoveAllPlayers(); - void SetLeader(uint64 guid); + void SetLeader(ObjectGuid guid); // Dungeon void SetDungeon(uint32 dungeon); @@ -47,7 +47,7 @@ namespace lfg LfgState GetOldState() const; LfgGuidSet const& GetPlayers() const; uint8 GetPlayerCount() const; - uint64 GetLeader() const; + ObjectGuid GetLeader() const; // Dungeon uint32 GetDungeon(bool asId = true) const; @@ -59,7 +59,7 @@ namespace lfg // General LfgState m_State; ///< State if group in LFG LfgState m_OldState; ///< Old State - uint64 m_Leader; ///< Leader GUID + ObjectGuid m_Leader; ///< Leader GUID LfgGuidSet m_Players; ///< Players in group // Dungeon uint32 m_Dungeon; ///< Dungeon entry diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 9098a35a75..e92cf35b16 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -51,15 +51,15 @@ namespace lfg return &instance; } - void LFGMgr::_LoadFromDB(Field* fields, uint64 guid) + void LFGMgr::_LoadFromDB(Field* fields, ObjectGuid guid) { if (!fields) return; - if (!IS_GROUP_GUID(guid)) + if (!guid.IsGroup()) return; - SetLeader(guid, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER)); + SetLeader(guid, ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32())); uint32 dungeon = fields[17].GetUInt32(); uint8 state = fields[18].GetUInt8(); @@ -80,13 +80,13 @@ namespace lfg } } - void LFGMgr::_SaveToDB(uint64 guid) + void LFGMgr::_SaveToDB(ObjectGuid guid) { - if (!IS_GROUP_GUID(guid)) + if (!guid.IsGroup()) return; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_LFG_DATA); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt32(1, GetDungeon(guid)); stmt->setUInt32(2, GetState(guid)); CharacterDatabase.Execute(stmt); @@ -254,7 +254,7 @@ namespace lfg CachedDungeonMapStore.clear(); // Recalculate locked dungeons for (LfgPlayerDataContainer::const_iterator it = PlayersStore.begin(); it != PlayersStore.end(); ++it) - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(it->first)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(it->first)) InitializeLockedDungeons(player); } } @@ -279,7 +279,7 @@ namespace lfg for (LfgRolesMap::const_iterator itRoles = roleCheck.roles.begin(); itRoles != roleCheck.roles.end(); ++itRoles) { - uint64 guid = itRoles->first; + ObjectGuid guid = itRoles->first; RestoreState(guid, "Remove Obsolete RoleCheck"); SendLfgRoleCheckUpdate(guid, roleCheck); if (guid == roleCheck.leader) @@ -308,7 +308,7 @@ namespace lfg boot.inProgress = false; for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) { - uint64 pguid = itVotes->first; + ObjectGuid pguid = itVotes->first; if (pguid != boot.victim) SendLfgBootProposalUpdate(pguid, boot); SetState(pguid, LFG_STATE_DUNGEON); @@ -345,12 +345,12 @@ namespace lfg uint32 proposalId = itProposal->first; LfgProposal& proposal = ProposalsStore[proposalId]; - uint64 guid = 0; + ObjectGuid guid; for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers) { guid = itPlayers->first; SetState(guid, LFG_STATE_PROPOSAL); - if (uint64 gguid = GetGroup(guid)) + if (ObjectGuid gguid = GetGroup(guid)) { SetState(gguid, LFG_STATE_PROPOSAL); SendLfgUpdateParty(guid, LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid))); @@ -376,7 +376,7 @@ namespace lfg */ void LFGMgr::InitializeLockedDungeons(Player* player, uint8 level /* = 0 */) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); if (!level) level = player->getLevel(); uint8 expansion = player->GetSession()->Expansion(); @@ -400,7 +400,7 @@ namespace lfg lockData = LFG_LOCKSTATUS_RAID_LOCKED; else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_LFG_MAP, dungeon->map, player)) lockData = LFG_LOCKSTATUS_RAID_LOCKED; - else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && (!mapEntry || !mapEntry->IsRaid()) && sInstanceSaveMgr->PlayerIsPermBoundToInstance(player->GetGUIDLow(), dungeon->map, Difficulty(dungeon->difficulty))) + else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && (!mapEntry || !mapEntry->IsRaid()) && sInstanceSaveMgr->PlayerIsPermBoundToInstance(player->GetGUID(), dungeon->map, Difficulty(dungeon->difficulty))) lockData = LFG_LOCKSTATUS_RAID_LOCKED; else if ((dungeon->minlevel > level && !sWorld->getBoolConfig(CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE)) || (sWorld->getBoolConfig(CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE) && ar && ar->levelMin > 0 && ar->levelMin > level)) lockData = LFG_LOCKSTATUS_TOO_LOW_LEVEL; @@ -490,8 +490,8 @@ namespace lfg return; Group* grp = player->GetGroup(); - uint64 guid = player->GetGUID(); - uint64 gguid = grp ? grp->GetGUID() : guid; + ObjectGuid guid = player->GetGUID(); + ObjectGuid gguid = grp ? grp->GetGUID() : guid; LfgJoinResultData joinData; LfgGuidSet players; uint32 rDungeonId = 0; @@ -522,7 +522,7 @@ namespace lfg switch (state) { case LFG_STATE_ROLECHECK: // if joining again during rolecheck (eg. many players clicked continue inside instance) - if (IS_GROUP_GUID(gguid)) + if (gguid.IsGroup()) UpdateRoleCheck(gguid); // abort role check and remove from RoleChecksStore break; case LFG_STATE_QUEUED: // joining again while in a queue @@ -666,7 +666,7 @@ namespace lfg if (joinData.result != LFG_JOIN_OK) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: %u", guid, grp ? grp->GetMembersCount() : 1, joinData.result); + LOG_DEBUG("lfg", "LFGMgr::Join: [%s] joining with %u members. result: %u", guid.ToString().c_str(), grp ? grp->GetMembersCount() : 1, joinData.result); #endif if (!dungeons.empty()) // Only should show lockmap when have no dungeons available joinData.lockmap.clear(); @@ -715,7 +715,7 @@ namespace lfg { if (Player* plrg = itr->GetSource()) { - uint64 pguid = plrg->GetGUID(); + ObjectGuid pguid = plrg->GetGUID(); plrg->GetSession()->SendLfgUpdateParty(updateData); SetState(pguid, LFG_STATE_ROLECHECK); if (!isContinue) @@ -770,10 +770,10 @@ namespace lfg @param[in] guid Player or group guid */ - void LFGMgr::LeaveLfg(uint64 guid) + void LFGMgr::LeaveLfg(ObjectGuid guid) { - LOG_DEBUG("lfg", "LFGMgr::Leave: [" UI64FMTD "]", guid); - uint64 gguid = IS_GROUP_GUID(guid) ? guid : GetGroup(guid); + LOG_DEBUG("lfg", "LFGMgr::Leave: [%s]", guid.ToString().c_str()); + ObjectGuid gguid = guid.IsGroup() ? guid : GetGroup(guid); LfgState state = GetState(guid); switch (state) { @@ -806,7 +806,7 @@ namespace lfg { // Remove from Proposals LfgProposalContainer::iterator it = ProposalsStore.begin(); - uint64 pguid = gguid == guid ? GetLeader(gguid) : guid; + ObjectGuid pguid = gguid == guid ? GetLeader(gguid) : guid; while (it != ProposalsStore.end()) { LfgProposalPlayerContainer::iterator itPlayer = it->second.players.find(pguid); @@ -853,17 +853,16 @@ namespace lfg for (LfgDungeonSet::const_iterator itr = dungeons.begin(); itr != dungeons.end(); ++itr) if (GetLFGDungeon(*itr)) // ensure dungeon data exists for such dungeon id { - RaidBrowserStore[player->GetTeamId()][*itr][player->GetGUIDLow()] = entry; + RaidBrowserStore[player->GetTeamId()][*itr][player->GetGUID()] = entry; RBUsedDungeonsStore[player->GetTeamId()].insert(*itr); } } - void LFGMgr::LeaveRaidBrowser(uint64 guid) + void LFGMgr::LeaveRaidBrowser(ObjectGuid guid) { - uint32 guidLow = GUID_LOPART(guid); for (uint8 team = 0; team < 2; ++team) for (RBStoreMap::iterator itr = RaidBrowserStore[team].begin(); itr != RaidBrowserStore[team].end(); ++itr) - itr->second.erase(guidLow); + itr->second.erase(guid); } void LFGMgr::SendRaidBrowserJoinedPacket(Player* p, LfgDungeonSet& dungeons, std::string comment) @@ -874,7 +873,7 @@ namespace lfg uint8 team = p->GetTeamId(); bool setComment = true; for (RBStoreMap::iterator itr = RaidBrowserStore[team].begin(); itr != RaidBrowserStore[team].end(); ++itr) - if ((iter = itr->second.find(p->GetGUIDLow())) != itr->second.end()) + if ((iter = itr->second.find(p->GetGUID())) != itr->second.end()) { dungeons.insert(itr->first); if (setComment) @@ -895,12 +894,12 @@ namespace lfg void LFGMgr::LfrSearchAdd(Player* p, uint32 dungeonId) { - RBSearchersStore[p->GetTeamId()][p->GetGUIDLow()] = dungeonId; + RBSearchersStore[p->GetTeamId()][p->GetGUID()] = dungeonId; } void LFGMgr::LfrSearchRemove(Player* p) { - RBSearchersStore[p->GetTeamId()].erase(p->GetGUIDLow()); + RBSearchersStore[p->GetTeamId()].erase(p->GetGUID()); } void LFGMgr::SendRaidBrowserCachedList(Player* player, uint32 dungeonId) @@ -936,7 +935,7 @@ namespace lfg if (getMSTimeDiff(World::GetGameTimeMS(), getMSTime()) > (70 * 7) / 5) // prevent lagging return; - uint64 guid, groupGuid, instanceGuid; + ObjectGuid guid, groupGuid, instanceGuid; uint8 level, Class, race, talents[3]; float iLevel, mp5, mp5combat, baseAP, rangedAP; int32 spellDamage, spellHeal; @@ -944,7 +943,7 @@ namespace lfg uint32 deletedCounter, groupCounter, playerCounter; ByteBuffer buffer_deleted, buffer_groups, buffer_players; std::string emptyComment; - std::set<uint64> deletedGroups, deletedGroupsToErase; + GuidSet deletedGroups, deletedGroupsToErase; RBInternalInfoMap copy; for (uint8 team = 0; team < 2; ++team) @@ -973,9 +972,9 @@ namespace lfg RBInternalInfoMap& currInternalInfoMap = RBInternalInfoStoreCurr[team][dungeonId]; for (RBEntryInfoMap::const_iterator sitr = entryInfoMap.begin(); sitr != entryInfoMap.end(); ++sitr) { - guid = MAKE_NEW_GUID(sitr->first, 0, HIGHGUID_PLAYER); - groupGuid = 0; - Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + guid = sitr->first; + groupGuid.Clear(); + Player* p = ObjectAccessor::FindConnectedPlayer(guid); ASSERT(p); if (sitr->second.roles == PLAYER_ROLE_LEADER) { @@ -983,11 +982,11 @@ namespace lfg groupGuid = p->GetGroup()->GetGUID(); } encounterMask = 0; - instanceGuid = 0; - if (InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(sitr->first, dungeonData->map, dungeonData->difficulty)) + instanceGuid.Clear(); + if (InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(guid, dungeonData->map, dungeonData->difficulty)) if (bind->perm) { - instanceGuid = MAKE_NEW_GUID(bind->save->GetInstanceId(), 0, HIGHGUID_INSTANCE); + instanceGuid = ObjectGuid::Create<HighGuid::Instance>(bind->save->GetInstanceId()); encounterMask = bind->save->GetCompletedEncounterMask(); } @@ -1007,7 +1006,7 @@ namespace lfg else maxPower = (p->getPowerType() == POWER_RAGE || p->getPowerType() == POWER_RUNIC_POWER) ? p->GetMaxPower(p->getPowerType()) / 10 : p->GetMaxPower(p->getPowerType()); - currInternalInfoMap[sitr->first] = RBInternalInfo(guid, sitr->second.comment, groupGuid != 0, groupGuid, sitr->second.roles, encounterMask, instanceGuid, + currInternalInfoMap[sitr->first] = RBInternalInfo(guid, sitr->second.comment, !groupGuid.IsEmpty(), groupGuid, sitr->second.roles, encounterMask, instanceGuid, 1, p->getLevel(), p->getClass(), p->getRace(), p->GetAverageItemLevel(), talents, p->m_last_area_id, p->GetArmor(), (uint32)std::max<int32>(0, spellDamage), (uint32)std::max<int32>(0, spellHeal), p->GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_CRIT_MELEE), p->GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_CRIT_RANGED), p->GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_CRIT_SPELL), std::max<float>(0.0f, mp5), std::max<float>(0.0f, mp5combat), @@ -1020,7 +1019,8 @@ namespace lfg { if (mitr->guid == sitr->first) // leader already added continue; - guid = MAKE_NEW_GUID(mitr->guid, 0, HIGHGUID_PLAYER); + + guid = mitr->guid; level = 1; Class = 0; race = 0; @@ -1028,19 +1028,19 @@ namespace lfg talents[0] = 0; talents[1] = 0; talents[2] = 0; - if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(mitr->guid)) + if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(mitr->guid.GetCounter())) { level = gpd->level; Class = gpd->playerClass; race = gpd->race; } - Player* mplr = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* mplr = ObjectAccessor::FindConnectedPlayer(guid); if (mplr) { iLevel = mplr->GetAverageItemLevel(); mplr->GetTalentTreePoints(talents); } - currInternalInfoMap[mitr->guid] = RBInternalInfo(guid, emptyComment, false, groupGuid, 0, 0, 0, + currInternalInfoMap[mitr->guid] = RBInternalInfo(guid, emptyComment, false, groupGuid, 0, 0, ObjectGuid::Empty, (mplr ? 1 : 0), level, Class, race, iLevel, talents, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1072,7 +1072,7 @@ namespace lfg if (sitr->second.isGroupLeader) deletedGroups.insert(sitr->second.groupGuid); ++deletedCounter; - buffer_deleted << (uint64)sitr->second.guid; + buffer_deleted << sitr->second.guid; } else // was -> is { @@ -1132,14 +1132,14 @@ namespace lfg } if (!deletedGroupsToErase.empty()) - for (std::set<uint64>::const_iterator sitr = deletedGroupsToErase.begin(); sitr != deletedGroupsToErase.end(); ++sitr) - deletedGroups.erase(*sitr); + for (ObjectGuid const guid : deletedGroupsToErase) + deletedGroups.erase(guid); if (!deletedGroups.empty()) - for (std::set<uint64>::const_iterator sitr = deletedGroups.begin(); sitr != deletedGroups.end(); ++sitr) + for (ObjectGuid const guid : deletedGroups) { ++deletedCounter; - buffer_deleted << (*sitr); + buffer_deleted << guid; } WorldPacket differencePacket(SMSG_UPDATE_LFG_LIST, 1000); @@ -1157,7 +1157,7 @@ namespace lfg // send difference packet to browsing players for (RBSearchersMap::const_iterator sitr = RBSearchersStore[team].begin(); sitr != RBSearchersStore[team].end(); ++sitr) if (sitr->second == dungeonId) - if (Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(sitr->first, 0, HIGHGUID_PLAYER))) + if (Player* p = ObjectAccessor::FindConnectedPlayer(sitr->first)) p->GetSession()->SendPacket(&differencePacket); break; // one dungeon updated in one LFGMgr::UpdateRaidBrowser @@ -1171,7 +1171,7 @@ namespace lfg void LFGMgr::RBPacketAppendGroup(const RBInternalInfo& info, ByteBuffer& buffer) { - buffer << (uint64)info.groupGuid; + buffer << info.groupGuid; uint32 flags = LFG_UPDATE_FLAG_COMMENT | LFG_UPDATE_FLAG_ROLES | LFG_UPDATE_FLAG_BINDED; buffer << (uint32)flags; if (flags & LFG_UPDATE_FLAG_COMMENT) @@ -1181,13 +1181,13 @@ namespace lfg buffer << (uint8)0; if (!(flags & LFG_UPDATE_FLAG_BINDED)) return; - buffer << (uint64)info.instanceGuid; + buffer << info.instanceGuid; buffer << (uint32)info.encounterMask; } void LFGMgr::RBPacketAppendPlayer(const RBInternalInfo& info, ByteBuffer& buffer) { - buffer << (uint64)info.guid; + buffer << info.guid; uint32 flags = LFG_UPDATE_FLAG_CHARACTERINFO | LFG_UPDATE_FLAG_ROLES | LFG_UPDATE_FLAG_COMMENT | (info.groupGuid ? LFG_UPDATE_FLAG_GROUPGUID : LFG_UPDATE_FLAG_BINDED) | (info.isGroupLeader ? LFG_UPDATE_FLAG_GROUPLEADER : 0) | (!info.groupGuid || info.isGroupLeader ? LFG_UPDATE_FLAG_AREA : 0); buffer << (uint32)flags; @@ -1226,7 +1226,7 @@ namespace lfg if (flags & LFG_UPDATE_FLAG_GROUPLEADER) buffer << (uint8)1; // isLFM if (flags & LFG_UPDATE_FLAG_GROUPGUID) - buffer << (uint64)info.groupGuid; + buffer << info.groupGuid; if (flags & LFG_UPDATE_FLAG_ROLES) buffer << (uint8)(info.groupGuid ? (info.isGroupLeader ? PLAYER_ROLE_LEADER : 0) : info.roles); if (flags & LFG_UPDATE_FLAG_AREA) @@ -1235,7 +1235,7 @@ namespace lfg buffer << (uint8)0; if (!(flags & LFG_UPDATE_FLAG_BINDED)) return; - buffer << (uint64)info.instanceGuid; + buffer << info.instanceGuid; buffer << (uint32)info.encounterMask; } @@ -1280,12 +1280,12 @@ namespace lfg } // pussywizard: - void LFGMgr::LeaveAllLfgQueues(uint64 guid, bool allowgroup, uint64 groupguid) + void LFGMgr::LeaveAllLfgQueues(ObjectGuid guid, bool allowgroup, ObjectGuid groupguid) { - uint64 pguid = 0, gguid = 0; - if (IS_GROUP_GUID(guid)) + ObjectGuid pguid, gguid; + if (guid.IsGroup()) gguid = guid; - else if (groupguid && IS_GROUP_GUID(groupguid)) + else if (groupguid && groupguid.IsGroup()) { pguid = guid; gguid = groupguid; @@ -1296,7 +1296,7 @@ namespace lfg gguid = GetGroup(guid); } if (!allowgroup) - gguid = 0; + gguid.Clear(); if (pguid) for (lfg::LfgQueueContainer::iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr) @@ -1335,7 +1335,7 @@ namespace lfg @param[in] guid Player guid (0 = rolecheck failed) @param[in] roles Player selected roles */ - void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /* = PLAYER_ROLE_NONE */) + void LFGMgr::UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid /* = 0 */, uint8 roles /* = PLAYER_ROLE_NONE */) { if (!gguid) return; @@ -1378,7 +1378,7 @@ namespace lfg LfgJoinResultData joinData = LfgJoinResultData(LFG_JOIN_FAILED, roleCheck.state); for (LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it) { - uint64 pguid = it->first; + ObjectGuid pguid = it->first; if (sendRoleChosen) SendLfgRoleChosen(pguid, guid, roles); @@ -1428,7 +1428,7 @@ namespace lfg lockMap.clear(); for (LfgGuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons.empty(); ++it) { - uint64 guid = (*it); + ObjectGuid guid = (*it); LfgLockMap const& cachedLockMap = GetLockedDungeons(guid); for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && !dungeons.empty(); ++it2) { @@ -1524,7 +1524,7 @@ namespace lfg for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { - uint64 guid = it->first; + ObjectGuid guid = it->first; if (guid == proposal.leader) players.push_front(guid); else @@ -1538,12 +1538,12 @@ namespace lfg LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId); ASSERT(dungeon); - Group* grp = proposal.group ? sGroupMgr->GetGroupByGUID(GUID_LOPART(proposal.group)) : nullptr; - uint64 oldGroupGUID = 0; + Group* grp = proposal.group ? sGroupMgr->GetGroupByGUID(proposal.group.GetCounter()) : nullptr; + ObjectGuid oldGroupGUID; for (LfgGuidList::const_iterator it = players.begin(); it != players.end(); ++it) { - uint64 pguid = (*it); - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(pguid); + ObjectGuid pguid = (*it); + Player* player = ObjectAccessor::FindConnectedPlayer(pguid); if (!player) continue; @@ -1574,7 +1574,7 @@ namespace lfg grp = new Group(); grp->ConvertToLFG(); grp->Create(player); - uint64 gguid = grp->GetGUID(); + ObjectGuid gguid = grp->GetGUID(); SetState(gguid, LFG_STATE_PROPOSAL); sGroupMgr->AddGroup(grp); } @@ -1595,7 +1595,7 @@ namespace lfg return; grp->SetDungeonDifficulty(Difficulty(dungeon->difficulty)); - uint64 gguid = grp->GetGUID(); + ObjectGuid gguid = grp->GetGUID(); SetDungeon(gguid, dungeon->Entry()); SetState(gguid, LFG_STATE_DUNGEON); @@ -1641,7 +1641,7 @@ namespace lfg @param[in] guid Player guid to update answer @param[in] accept Player answer */ - void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) + void LFGMgr::UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept) { // Check if the proposal exists LfgProposalContainer::iterator itProposal = ProposalsStore.find(proposalId); @@ -1659,7 +1659,7 @@ namespace lfg player.accept = LfgAnswer(accept); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::UpdateProposal: Player [" UI64FMTD "] of proposal %u selected: %u", guid, proposalId, accept); + LOG_DEBUG("lfg", "LFGMgr::UpdateProposal: Player [%s] of proposal %u selected: %u", guid.ToString().c_str(), proposalId, accept); #endif if (!accept) { @@ -1689,8 +1689,8 @@ namespace lfg LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND); for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { - uint64 pguid = it->first; - uint64 gguid = it->second.group; + ObjectGuid pguid = it->first; + ObjectGuid gguid = it->second.group; uint32 dungeonId = (*GetSelectedDungeons(pguid).begin()); int32 waitTime = -1; if (sendUpdate) @@ -1733,8 +1733,8 @@ namespace lfg } // Remove players/groups from Queue - for (uint8 i = 0; i < 5 && proposal.queues.guid[i]; ++i) - queue.RemoveQueueData(proposal.queues.guid[i]); + for (uint8 i = 0; i < 5 && proposal.queues.guids[i]; ++i) + queue.RemoveQueueData(proposal.queues.guids[i]); MakeNewGroup(proposal); ProposalsStore.erase(itProposal); @@ -1763,7 +1763,7 @@ namespace lfg // pussywizard: add cooldown for not accepting (after 40 secs) or declining for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) if (it->second.accept == LFG_ANSWER_DENY) - if (Player* plr = sObjectAccessor->FindPlayer(it->first)) + if (Player* plr = ObjectAccessor::FindPlayer(it->first)) if (Aura* aura = plr->AddAura(LFG_SPELL_DUNGEON_COOLDOWN, plr)) aura->SetDuration(150 * IN_MILLISECONDS); @@ -1774,7 +1774,7 @@ namespace lfg if (it->second.accept == LFG_ANSWER_AGREE) continue; - uint64 guid = it->second.group ? it->second.group : it->first; + ObjectGuid guid = it->second.group ? it->second.group : it->first; // Player didn't accept or still pending when no secs left if (it->second.accept == LFG_ANSWER_DENY || type == LFG_UPDATETYPE_PROPOSAL_FAILED) { @@ -1786,8 +1786,8 @@ namespace lfg // Notify players for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { - uint64 guid = it->first; - uint64 gguid = it->second.group ? it->second.group : guid; + ObjectGuid guid = it->first; + ObjectGuid gguid = it->second.group ? it->second.group : guid; SendLfgUpdateProposal(guid, proposal); @@ -1798,14 +1798,14 @@ namespace lfg { updateData.updateType = type; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: [" UI64FMTD "] didn't accept. Removing from queue and compatible cache", guid); + LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: [%s] didn't accept. Removing from queue and compatible cache", guid.ToString().c_str()); #endif } else { updateData.updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: [" UI64FMTD "] in same group that someone that didn't accept. Removing from queue and compatible cache", guid); + LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: [%s] in same group that someone that didn't accept. Removing from queue and compatible cache", guid.ToString().c_str()); #endif } @@ -1821,7 +1821,7 @@ namespace lfg else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: Readding [" UI64FMTD "] to queue.", guid); + LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: Readding [%s] to queue.", guid.ToString().c_str()); #endif SetState(guid, LFG_STATE_QUEUED); if (gguid != guid) @@ -1838,18 +1838,18 @@ namespace lfg // Remove players/groups from queue for (LfgGuidSet::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it) { - uint64 guid = *it; + ObjectGuid guid = *it; queue.RemoveFromQueue(guid); proposal.queues.remove(guid); } // Readd to queue - for (uint8 i = 0; i < 5 && proposal.queues.guid[i]; ++i) + for (uint8 i = 0; i < 5 && proposal.queues.guids[i]; ++i) { // xinef: this will work as data is not deleted, only references to this data are cleared // xinef: when new proposal is created // xinef: successful proposal is also taken into account is similar manner - queue.AddToQueue(proposal.queues.guid[i], true); + queue.AddToQueue(proposal.queues.guids[i], true); } ProposalsStore.erase(itProposal); @@ -1863,7 +1863,7 @@ namespace lfg @param[in] victim Victim guid @param[in] reason Kick reason */ - void LFGMgr::InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string const& reason) + void LFGMgr::InitBoot(ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, std::string const& reason) { SetState(gguid, LFG_STATE_BOOT); @@ -1878,7 +1878,7 @@ namespace lfg // Set votes for (LfgGuidSet::const_iterator itr = players.begin(); itr != players.end(); ++itr) { - uint64 guid = (*itr); + ObjectGuid guid = (*itr); SetState(guid, LFG_STATE_BOOT); boot.votes[guid] = LFG_ANSWER_PENDING; } @@ -1897,9 +1897,9 @@ namespace lfg @param[in] guid Player who has answered @param[in] player answer */ - void LFGMgr::UpdateBoot(uint64 guid, bool accept) + void LFGMgr::UpdateBoot(ObjectGuid guid, bool accept) { - uint64 gguid = GetGroup(guid); + ObjectGuid gguid = GetGroup(guid); if (!gguid) return; @@ -1934,7 +1934,7 @@ namespace lfg boot.inProgress = false; for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) { - uint64 pguid = itVotes->first; + ObjectGuid pguid = itVotes->first; if (pguid != boot.victim) { SetState(pguid, LFG_STATE_DUNGEON); @@ -1945,8 +1945,9 @@ namespace lfg SetState(gguid, LFG_STATE_DUNGEON); if (agreeNum == LFG_GROUP_KICK_VOTES_NEEDED) // Vote passed - Kick player { - if (Group* group = sGroupMgr->GetGroupByGUID(GUID_LOPART(gguid))) + if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter())) Player::RemoveFromGroup(group, boot.victim, GROUP_REMOVEMETHOD_KICK_LFG); + DecreaseKicksLeft(gguid); } BootsStore.erase(itBoot); @@ -2042,18 +2043,18 @@ namespace lfg @param[in] guid Group guid @param[in] dungeonId Dungeonid */ - void LFGMgr::FinishDungeon(uint64 gguid, const uint32 dungeonId, const Map* currMap) + void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, const Map* currMap) { uint32 gDungeonId = GetDungeon(gguid); if (gDungeonId != dungeonId) { - LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [" UI64FMTD "] Finished dungeon %u but group queued for %u. Ignoring", gguid, dungeonId, gDungeonId); + LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [%s] Finished dungeon %u but group queued for %u. Ignoring", gguid.ToString().c_str(), dungeonId, gDungeonId); return; } if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times { - LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [" UI64FMTD "] Already rewarded group. Ignoring", gguid); + LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [%s] Already rewarded group. Ignoring", gguid.ToString().c_str()); return; } @@ -2063,10 +2064,10 @@ namespace lfg const LfgGuidSet& players = GetPlayers(gguid); for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it) { - uint64 guid = (*it); + ObjectGuid guid = (*it); if (GetState(guid) == LFG_STATE_FINISHED_DUNGEON) { - LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [" UI64FMTD "] Already rewarded player. Ignoring", guid); + LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [%s] Already rewarded player. Ignoring", guid.ToString().c_str()); continue; } @@ -2082,14 +2083,14 @@ namespace lfg if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !dungeon->seasonal)) { - LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [" UI64FMTD "] dungeon %u is not random or seasonal", guid, rDungeonId); + LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [%s] dungeon %u is not random or seasonal", guid.ToString().c_str(), rDungeonId); continue; } Player* player = ObjectAccessor::FindPlayer(guid); if (!player || player->FindMap() != currMap) // pussywizard: currMap - multithreading crash if on other map (map id check is not enough, binding system is not reliable) { - LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [" UI64FMTD "] not found in world", guid); + LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [%s] not found in world", guid.ToString().c_str()); continue; } @@ -2098,7 +2099,7 @@ namespace lfg if (player->GetMapId() != mapId) { - LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [" UI64FMTD "] is in map %u and should be in %u to get reward", guid, player->GetMapId(), mapId); + LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [%s] is in map %u and should be in %u to get reward", guid.ToString().c_str(), player->GetMapId(), mapId); continue; } @@ -2136,7 +2137,7 @@ namespace lfg } // Give rewards - LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [" UI64FMTD "] done dungeon %u, %s previously done.", player->GetGUID(), GetDungeon(gguid), done ? " " : " not"); + LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [%s] done dungeon %u, %s previously done.", player->GetGUID().ToString().c_str(), GetDungeon(gguid), done ? " " : " not"); LfgPlayerRewardData data = LfgPlayerRewardData(dungeon->Entry(), GetDungeon(gguid, false), done, quest); player->GetSession()->SendLfgPlayerReward(data); } @@ -2196,44 +2197,44 @@ namespace lfg return LfgType(dungeon->type); } - LfgState LFGMgr::GetState(uint64 guid) + LfgState LFGMgr::GetState(ObjectGuid guid) { LfgState state; - if (IS_GROUP_GUID(guid)) + if (guid.IsGroup()) state = GroupsStore[guid].GetState(); else state = PlayersStore[guid].GetState(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::GetState: [" UI64FMTD "] = %u", guid, state); + LOG_DEBUG("lfg", "LFGMgr::GetState: [%s] = %u", guid.ToString().c_str(), state); #endif return state; } - LfgState LFGMgr::GetOldState(uint64 guid) + LfgState LFGMgr::GetOldState(ObjectGuid guid) { LfgState state; - if (IS_GROUP_GUID(guid)) + if (guid.IsGroup()) state = GroupsStore[guid].GetOldState(); else state = PlayersStore[guid].GetOldState(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::GetOldState: [" UI64FMTD "] = %u", guid, state); + LOG_DEBUG("lfg", "LFGMgr::GetOldState: [%s] = %u", guid.ToString().c_str(), state); #endif return state; } - uint32 LFGMgr::GetDungeon(uint64 guid, bool asId /*= true */) + uint32 LFGMgr::GetDungeon(ObjectGuid guid, bool asId /*= true */) { uint32 dungeon = GroupsStore[guid].GetDungeon(asId); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::GetDungeon: [" UI64FMTD "] asId: %u = %u", guid, asId, dungeon); + LOG_DEBUG("lfg", "LFGMgr::GetDungeon: [%s] asId: %u = %u", guid.ToString().c_str(), asId, dungeon); #endif return dungeon; } - uint32 LFGMgr::GetDungeonMapId(uint64 guid) + uint32 LFGMgr::GetDungeonMapId(ObjectGuid guid) { uint32 dungeonId = GroupsStore[guid].GetDungeon(true); uint32 mapId = 0; @@ -2242,64 +2243,64 @@ namespace lfg mapId = dungeon->map; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::GetDungeonMapId: [" UI64FMTD "] = %u (DungeonId = %u)", guid, mapId, dungeonId); + LOG_DEBUG("lfg", "LFGMgr::GetDungeonMapId: [%s] = %u (DungeonId = %u)", guid.ToString().c_str(), mapId, dungeonId); #endif return mapId; } - uint8 LFGMgr::GetRoles(uint64 guid) + uint8 LFGMgr::GetRoles(ObjectGuid guid) { uint8 roles = PlayersStore[guid].GetRoles(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::GetRoles: [" UI64FMTD "] = %u", guid, roles); + LOG_DEBUG("lfg", "LFGMgr::GetRoles: [%s] = %u", guid.ToString().c_str(), roles); #endif return roles; } - const std::string& LFGMgr::GetComment(uint64 guid) + const std::string& LFGMgr::GetComment(ObjectGuid guid) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::GetComment: [" UI64FMTD "] = %s", guid, PlayersStore[guid].GetComment().c_str()); + LOG_DEBUG("lfg", "LFGMgr::GetComment: [%s] = %s", guid.ToString().c_str(), PlayersStore[guid].GetComment().c_str()); #endif return PlayersStore[guid].GetComment(); } - LfgDungeonSet const& LFGMgr::GetSelectedDungeons(uint64 guid) + LfgDungeonSet const& LFGMgr::GetSelectedDungeons(ObjectGuid guid) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::GetSelectedDungeons: [" UI64FMTD "]", guid); + LOG_DEBUG("lfg", "LFGMgr::GetSelectedDungeons: [%s]", guid.ToString().c_str()); #endif return PlayersStore[guid].GetSelectedDungeons(); } - LfgLockMap const& LFGMgr::GetLockedDungeons(uint64 guid) + LfgLockMap const& LFGMgr::GetLockedDungeons(ObjectGuid guid) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::GetLockedDungeons: [" UI64FMTD "]", guid); + LOG_DEBUG("lfg", "LFGMgr::GetLockedDungeons: [%s]", guid.ToString().c_str()); #endif return PlayersStore[guid].GetLockedDungeons(); } - uint8 LFGMgr::GetKicksLeft(uint64 guid) + uint8 LFGMgr::GetKicksLeft(ObjectGuid guid) { uint8 kicks = GroupsStore[guid].GetKicksLeft(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::GetKicksLeft: [" UI64FMTD "] = %u", guid, kicks); + LOG_DEBUG("lfg", "LFGMgr::GetKicksLeft: [%s] = %u", guid.ToString().c_str(), kicks); #endif return kicks; } - void LFGMgr::RestoreState(uint64 guid, char const* /*debugMsg*/) + void LFGMgr::RestoreState(ObjectGuid guid, char const* /*debugMsg*/) { - if (IS_GROUP_GUID(guid)) + if (guid.IsGroup()) { LfgGroupData& data = GroupsStore[guid]; /*if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) { std::string const& ps = GetStateString(data.GetState()); std::string const& os = GetStateString(data.GetOldState()); - LOG_TRACE("lfg", "LFGMgr::RestoreState: Group: [" UI64FMTD "] (%s) State: %s, oldState: %s", - guid, debugMsg, ps.c_str(), os.c_str()); + LOG_TRACE("lfg", "LFGMgr::RestoreState: Group: [%s] (%s) State: %s, oldState: %s", + guid.ToString().c_str(), debugMsg, ps.c_str(), os.c_str()); }*/ data.RestoreState(); @@ -2311,22 +2312,22 @@ namespace lfg { std::string const& ps = GetStateString(data.GetState()); std::string const& os = GetStateString(data.GetOldState()); - LOG_TRACE("lfg", "LFGMgr::RestoreState: Player: [" UI64FMTD "] (%s) State: %s, oldState: %s", - guid, debugMsg, ps.c_str(), os.c_str()); + LOG_TRACE("lfg", "LFGMgr::RestoreState: Player: [%s] (%s) State: %s, oldState: %s", + guid.ToString().c_str(), debugMsg, ps.c_str(), os.c_str()); }*/ data.RestoreState(); } } - void LFGMgr::SetState(uint64 guid, LfgState state) + void LFGMgr::SetState(ObjectGuid guid, LfgState state) { - if (IS_GROUP_GUID(guid)) + if (guid.IsGroup()) { LfgGroupData& data = GroupsStore[guid]; std::string ns = GetStateString(state); std::string ps = GetStateString(data.GetState()); std::string os = GetStateString(data.GetOldState()); - LOG_DEBUG("lfg", "LFGMgr::SetState: Group: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", guid, ns.c_str(), ps.c_str(), os.c_str()); + LOG_DEBUG("lfg", "LFGMgr::SetState: Group: [%s] newState: %s, previous: %s, oldState: %s", guid.ToString().c_str(), ns.c_str(), ps.c_str(), os.c_str()); data.SetState(state); } else @@ -2335,36 +2336,36 @@ namespace lfg std::string ns = GetStateString(state); std::string ps = GetStateString(data.GetState()); std::string os = GetStateString(data.GetOldState()); - LOG_DEBUG("lfg", "LFGMgr::SetState: Player: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", guid, ns.c_str(), ps.c_str(), os.c_str()); + LOG_DEBUG("lfg", "LFGMgr::SetState: Player: [%s] newState: %s, previous: %s, oldState: %s", guid.ToString().c_str(), ns.c_str(), ps.c_str(), os.c_str()); data.SetState(state); } } - void LFGMgr::SetCanOverrideRBState(uint64 guid, bool val) + void LFGMgr::SetCanOverrideRBState(ObjectGuid guid, bool val) { PlayersStore[guid].SetCanOverrideRBState(val); } - void LFGMgr::SetDungeon(uint64 guid, uint32 dungeon) + void LFGMgr::SetDungeon(ObjectGuid guid, uint32 dungeon) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::SetDungeon: [" UI64FMTD "] dungeon %u", guid, dungeon); + LOG_DEBUG("lfg", "LFGMgr::SetDungeon: [%s] dungeon %u", guid.ToString().c_str(), dungeon); #endif GroupsStore[guid].SetDungeon(dungeon); } - void LFGMgr::SetRoles(uint64 guid, uint8 roles) + void LFGMgr::SetRoles(ObjectGuid guid, uint8 roles) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::SetRoles: [" UI64FMTD "] roles: %u", guid, roles); + LOG_DEBUG("lfg", "LFGMgr::SetRoles: [%s] roles: %u", guid.ToString().c_str(), roles); #endif PlayersStore[guid].SetRoles(roles); } - void LFGMgr::SetComment(uint64 guid, std::string const& comment) + void LFGMgr::SetComment(ObjectGuid guid, std::string const& comment) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::SetComment: [" UI64FMTD "] comment: %s", guid, comment.c_str()); + LOG_DEBUG("lfg", "LFGMgr::SetComment: [%s] comment: %s", guid.ToString().c_str(), comment.c_str()); #endif PlayersStore[guid].SetComment(comment); } @@ -2378,38 +2379,38 @@ namespace lfg uint8 teamId = p->GetTeamId(); RBEntryInfoMap::iterator iter; for (RBStoreMap::iterator itr = RaidBrowserStore[teamId].begin(); itr != RaidBrowserStore[teamId].end(); ++itr) - if ((iter = itr->second.find(p->GetGUIDLow())) != itr->second.end()) + if ((iter = itr->second.find(p->GetGUID())) != itr->second.end()) iter->second.comment = comment; } - void LFGMgr::SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons) + void LFGMgr::SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const& dungeons) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::SetLockedDungeons: [" UI64FMTD "]", guid); + LOG_DEBUG("lfg", "LFGMgr::SetLockedDungeons: [%s]", guid.ToString().c_str()); #endif PlayersStore[guid].SetSelectedDungeons(dungeons); } - void LFGMgr::SetLockedDungeons(uint64 guid, LfgLockMap const& lock) + void LFGMgr::SetLockedDungeons(ObjectGuid guid, LfgLockMap const& lock) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::SetLockedDungeons: [" UI64FMTD "]", guid); + LOG_DEBUG("lfg", "LFGMgr::SetLockedDungeons: [%s]", guid.ToString().c_str()); #endif PlayersStore[guid].SetLockedDungeons(lock); } - void LFGMgr::DecreaseKicksLeft(uint64 guid) + void LFGMgr::DecreaseKicksLeft(ObjectGuid guid) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::DecreaseKicksLeft: [" UI64FMTD "]", guid); + LOG_DEBUG("lfg", "LFGMgr::DecreaseKicksLeft: [%s]", guid.ToString().c_str()); #endif GroupsStore[guid].DecreaseKicksLeft(); } - void LFGMgr::RemoveGroupData(uint64 guid) + void LFGMgr::RemoveGroupData(ObjectGuid guid) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGMgr::RemoveGroupData: [" UI64FMTD "]", guid); + LOG_DEBUG("lfg", "LFGMgr::RemoveGroupData: [%s]", guid.ToString().c_str()); #endif LfgGroupDataContainer::iterator it = GroupsStore.find(guid); if (it == GroupsStore.end()) @@ -2420,8 +2421,8 @@ namespace lfg LfgGuidSet const& players = it->second.GetPlayers(); for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it) { - uint64 guid = (*it); - SetGroup(*it, 0); + ObjectGuid guid = (*it); + SetGroup(*it, ObjectGuid::Empty); if (state != LFG_STATE_PROPOSAL) { SetState(*it, LFG_STATE_NONE); @@ -2431,27 +2432,27 @@ namespace lfg GroupsStore.erase(it); } - TeamId LFGMgr::GetTeam(uint64 guid) + TeamId LFGMgr::GetTeam(ObjectGuid guid) { return PlayersStore[guid].GetTeam(); } - uint8 LFGMgr::RemovePlayerFromGroup(uint64 gguid, uint64 guid) + uint8 LFGMgr::RemovePlayerFromGroup(ObjectGuid gguid, ObjectGuid guid) { return GroupsStore[gguid].RemovePlayer(guid); } - void LFGMgr::AddPlayerToGroup(uint64 gguid, uint64 guid) + void LFGMgr::AddPlayerToGroup(ObjectGuid gguid, ObjectGuid guid) { GroupsStore[gguid].AddPlayer(guid); } - void LFGMgr::SetLeader(uint64 gguid, uint64 leader) + void LFGMgr::SetLeader(ObjectGuid gguid, ObjectGuid leader) { GroupsStore[gguid].SetLeader(leader); } - void LFGMgr::SetTeam(uint64 guid, TeamId teamId) + void LFGMgr::SetTeam(ObjectGuid guid, TeamId teamId) { if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP)) teamId = TEAM_ALLIANCE; // @Not Sure About That TeamId is supposed to be uint8 Team = 0(@TrinityCore) @@ -2459,110 +2460,108 @@ namespace lfg PlayersStore[guid].SetTeam(teamId); } - uint64 LFGMgr::GetGroup(uint64 guid) + ObjectGuid LFGMgr::GetGroup(ObjectGuid guid) { return PlayersStore[guid].GetGroup(); } - void LFGMgr::SetGroup(uint64 guid, uint64 group) + void LFGMgr::SetGroup(ObjectGuid guid, ObjectGuid group) { PlayersStore[guid].SetGroup(group); } - LfgGuidSet const& LFGMgr::GetPlayers(uint64 guid) + LfgGuidSet const& LFGMgr::GetPlayers(ObjectGuid guid) { return GroupsStore[guid].GetPlayers(); } - uint8 LFGMgr::GetPlayerCount(uint64 guid) + uint8 LFGMgr::GetPlayerCount(ObjectGuid guid) { return GroupsStore[guid].GetPlayerCount(); } - uint64 LFGMgr::GetLeader(uint64 guid) + ObjectGuid LFGMgr::GetLeader(ObjectGuid guid) { return GroupsStore[guid].GetLeader(); } - void LFGMgr::SetRandomPlayersCount(uint64 guid, uint8 count) + void LFGMgr::SetRandomPlayersCount(ObjectGuid guid, uint8 count) { PlayersStore[guid].SetRandomPlayersCount(count); } - uint8 LFGMgr::GetRandomPlayersCount(uint64 guid) + uint8 LFGMgr::GetRandomPlayersCount(ObjectGuid guid) { return PlayersStore[guid].GetRandomPlayersCount(); } - bool LFGMgr::HasIgnore(uint64 guid1, uint64 guid2) + bool LFGMgr::HasIgnore(ObjectGuid guid1, ObjectGuid guid2) { - Player* plr1 = ObjectAccessor::FindPlayerInOrOutOfWorld(guid1); - Player* plr2 = ObjectAccessor::FindPlayerInOrOutOfWorld(guid2); - uint32 low1 = GUID_LOPART(guid1); - uint32 low2 = GUID_LOPART(guid2); - return plr1 && plr2 && (plr1->GetSocial()->HasIgnore(low2) || plr2->GetSocial()->HasIgnore(low1)); + Player* plr1 = ObjectAccessor::FindConnectedPlayer(guid1); + Player* plr2 = ObjectAccessor::FindConnectedPlayer(guid2); + return plr1 && plr2 && (plr1->GetSocial()->HasIgnore(guid2) || plr2->GetSocial()->HasIgnore(guid1)); } - void LFGMgr::SendLfgRoleChosen(uint64 guid, uint64 pguid, uint8 roles) + void LFGMgr::SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, uint8 roles) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) player->GetSession()->SendLfgRoleChosen(pguid, roles); } - void LFGMgr::SendLfgRoleCheckUpdate(uint64 guid, LfgRoleCheck const& roleCheck) + void LFGMgr::SendLfgRoleCheckUpdate(ObjectGuid guid, LfgRoleCheck const& roleCheck) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) player->GetSession()->SendLfgRoleCheckUpdate(roleCheck); } - void LFGMgr::SendLfgUpdatePlayer(uint64 guid, LfgUpdateData const& data) + void LFGMgr::SendLfgUpdatePlayer(ObjectGuid guid, LfgUpdateData const& data) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) player->GetSession()->SendLfgUpdatePlayer(data); } - void LFGMgr::SendLfgUpdateParty(uint64 guid, LfgUpdateData const& data) + void LFGMgr::SendLfgUpdateParty(ObjectGuid guid, LfgUpdateData const& data) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) player->GetSession()->SendLfgUpdateParty(data); } - void LFGMgr::SendLfgJoinResult(uint64 guid, LfgJoinResultData const& data) + void LFGMgr::SendLfgJoinResult(ObjectGuid guid, LfgJoinResultData const& data) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) player->GetSession()->SendLfgJoinResult(data); } - void LFGMgr::SendLfgBootProposalUpdate(uint64 guid, LfgPlayerBoot const& boot) + void LFGMgr::SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const& boot) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) player->GetSession()->SendLfgBootProposalUpdate(boot); } - void LFGMgr::SendLfgUpdateProposal(uint64 guid, LfgProposal const& proposal) + void LFGMgr::SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const& proposal) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) player->GetSession()->SendLfgUpdateProposal(proposal); } - void LFGMgr::SendLfgQueueStatus(uint64 guid, LfgQueueStatusData const& data) + void LFGMgr::SendLfgQueueStatus(ObjectGuid guid, LfgQueueStatusData const& data) { - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) player->GetSession()->SendLfgQueueStatus(data); } - bool LFGMgr::IsLfgGroup(uint64 guid) + bool LFGMgr::IsLfgGroup(ObjectGuid guid) { - return guid && IS_GROUP_GUID(guid) && GroupsStore[guid].IsLfgGroup(); + return guid && guid.IsGroup() && GroupsStore[guid].IsLfgGroup(); } - LFGQueue& LFGMgr::GetQueue(uint64 guid) + LFGQueue& LFGMgr::GetQueue(ObjectGuid guid) { uint8 queueId = 0; - if (IS_GROUP_GUID(guid)) + if (guid.IsGroup()) { LfgGuidSet const& players = GetPlayers(guid); - uint64 pguid = players.empty() ? 0 : (*players.begin()); + ObjectGuid pguid = players.empty() ? ObjectGuid::Empty : (*players.begin()); if (pguid) queueId = GetTeam(pguid); else @@ -2580,9 +2579,9 @@ namespace lfg if (check.empty()) return false; - for (uint8 i = 0; i < 5 && check.guid[i]; ++i) + for (uint8 i = 0; i < 5 && check.guids[i]; ++i) { - uint64 guid = check.guid[i]; + ObjectGuid guid = check.guids[i]; if (GetState(guid) != LFG_STATE_QUEUED) { LFGQueue& queue = GetQueue(guid); @@ -2615,7 +2614,7 @@ namespace lfg m_options = options; } - LfgUpdateData LFGMgr::GetLfgStatus(uint64 guid) + LfgUpdateData LFGMgr::GetLfgStatus(ObjectGuid guid) { LfgPlayerData& playerData = PlayersStore[guid]; return LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS, playerData.GetState(), playerData.GetSelectedDungeons()); @@ -2637,7 +2636,7 @@ namespace lfg return false; } - void LFGMgr::SetupGroupMember(uint64 guid, uint64 gguid) + void LFGMgr::SetupGroupMember(ObjectGuid guid, ObjectGuid gguid) { LfgDungeonSet dungeons; dungeons.insert(GetDungeon(gguid)); @@ -2647,7 +2646,7 @@ namespace lfg AddPlayerToGroup(gguid, guid); } - bool LFGMgr::selectedRandomLfgDungeon(uint64 guid) + bool LFGMgr::selectedRandomLfgDungeon(ObjectGuid guid) { if (GetState(guid) != LFG_STATE_NONE) { @@ -2663,9 +2662,9 @@ namespace lfg return false; } - bool LFGMgr::inLfgDungeonMap(uint64 guid, uint32 map, Difficulty difficulty) + bool LFGMgr::inLfgDungeonMap(ObjectGuid guid, uint32 map, Difficulty difficulty) { - if (!IS_GROUP_GUID(guid)) + if (!guid.IsGroup()) guid = GetGroup(guid); if (uint32 dungeonId = GetDungeon(guid, true)) diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index c065838a69..0340cc57ac 100644 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -137,13 +137,13 @@ namespace lfg struct RBInternalInfo { - uint64 guid; + ObjectGuid guid; std::string comment; bool isGroupLeader; - uint64 groupGuid; + ObjectGuid groupGuid; uint8 roles; uint32 encounterMask; - uint64 instanceGuid; + ObjectGuid instanceGuid; // additional character info parameters: uint8 _online; @@ -179,7 +179,7 @@ namespace lfg uint32 _expertiseRating; RBInternalInfo() {} - RBInternalInfo(uint64 guid, std::string const& comment, bool isGroupLeader, uint64 groupGuid, uint8 roles, uint32 encounterMask, uint64 instanceGuid, + RBInternalInfo(ObjectGuid guid, std::string const& comment, bool isGroupLeader, ObjectGuid groupGuid, uint8 roles, uint32 encounterMask, ObjectGuid instanceGuid, uint8 _online, uint8 _level, uint8 _class, uint8 _race, float _avgItemLevel, uint8 (&_talents)[3], uint32 _area, uint32 _armor, uint32 _spellDamage, uint32 _spellHeal, uint32 _critRatingMelee, uint32 _critRatingRanged, uint32 _critRatingSpell, float _mp5, float _mp5combat, @@ -242,13 +242,13 @@ namespace lfg typedef std::multimap<uint32, LfgReward const*> LfgRewardContainer; typedef std::pair<LfgRewardContainer::const_iterator, LfgRewardContainer::const_iterator> LfgRewardContainerBounds; typedef std::map<uint8, LfgDungeonSet> LfgCachedDungeonContainer; - typedef std::map<uint64, LfgAnswer> LfgAnswerContainer; - typedef std::map<uint64, LfgRoleCheck> LfgRoleCheckContainer; + typedef std::map<ObjectGuid, LfgAnswer> LfgAnswerContainer; + typedef std::map<ObjectGuid, LfgRoleCheck> LfgRoleCheckContainer; typedef std::map<uint32, LfgProposal> LfgProposalContainer; - typedef std::map<uint64, LfgProposalPlayer> LfgProposalPlayerContainer; - typedef std::map<uint64, LfgPlayerBoot> LfgPlayerBootContainer; - typedef std::map<uint64, LfgGroupData> LfgGroupDataContainer; - typedef std::map<uint64, LfgPlayerData> LfgPlayerDataContainer; + typedef std::map<ObjectGuid, LfgProposalPlayer> LfgProposalPlayerContainer; + typedef std::map<ObjectGuid, LfgPlayerBoot> LfgPlayerBootContainer; + typedef std::map<ObjectGuid, LfgGroupData> LfgGroupDataContainer; + typedef std::map<ObjectGuid, LfgPlayerData> LfgPlayerDataContainer; typedef std::unordered_map<uint32, LFGDungeonData> LFGDungeonContainer; // Data needed by SMSG_LFG_JOIN_RESULT @@ -320,24 +320,23 @@ namespace lfg /// Stores player data related to proposal to join struct LfgProposalPlayer { - LfgProposalPlayer(): role(0), accept(LFG_ANSWER_PENDING), group(0) { } + LfgProposalPlayer(): role(0), accept(LFG_ANSWER_PENDING) { } uint8 role; ///< Proposed role LfgAnswer accept; ///< Accept status (-1 not answer | 0 Not agree | 1 agree) - uint64 group; ///< Original group guid. 0 if no original group + ObjectGuid group; ///< Original group guid. 0 if no original group }; /// Stores group data related to proposal to join struct LfgProposal { - LfgProposal(uint32 dungeon = 0): id(0), dungeonId(dungeon), state(LFG_PROPOSAL_INITIATING), - group(0), leader(0), cancelTime(0), encounters(0), isNew(true) + LfgProposal(uint32 dungeon = 0): id(0), dungeonId(dungeon), state(LFG_PROPOSAL_INITIATING), cancelTime(0), encounters(0), isNew(true) { } uint32 id; ///< Proposal Id uint32 dungeonId; ///< Dungeon to join LfgProposalState state; ///< State of the proposal - uint64 group; ///< Proposal group (0 if new) - uint64 leader; ///< Leader guid. + ObjectGuid group; ///< Proposal group (0 if new) + ObjectGuid leader; ///< Leader guid. time_t cancelTime; ///< Time when we will cancel this proposal uint32 encounters; ///< Dungeon Encounters bool isNew; ///< Determines if it's new group or not @@ -354,7 +353,7 @@ namespace lfg LfgRoleCheckState state; ///< State of the rolecheck LfgDungeonSet dungeons; ///< Dungeons group is applying for (expanded random dungeons) uint32 rDungeonId; ///< Random Dungeon Id. - uint64 leader; ///< Leader of the group + ObjectGuid leader; ///< Leader of the group }; /// Stores information of a current vote to kick someone from a group @@ -363,7 +362,7 @@ namespace lfg time_t cancelTime; ///< Time left to vote bool inProgress; ///< Vote in progress LfgAnswerContainer votes; ///< Player votes (-1 not answer | 0 Not agree | 1 agree) - uint64 victim; ///< Player guid to be kicked (can't vote) + ObjectGuid victim; ///< Player guid to be kicked (can't vote) std::string reason; ///< kick reason }; @@ -401,14 +400,14 @@ namespace lfg ~LFGMgr(); // pussywizard: RAIDBROWSER - typedef std::unordered_map<uint32 /*playerGuidLow*/, RBEntryInfo> RBEntryInfoMap; + typedef std::unordered_map<ObjectGuid /*playerGuid*/, RBEntryInfo> RBEntryInfoMap; typedef std::unordered_map<uint32 /*dungeonId*/, RBEntryInfoMap> RBStoreMap; RBStoreMap RaidBrowserStore[2]; // for 2 factions - typedef std::unordered_map<uint32 /*playerGuidLow*/, uint32 /*dungeonId*/> RBSearchersMap; + typedef std::unordered_map<ObjectGuid /*playerGuid*/, uint32 /*dungeonId*/> RBSearchersMap; RBSearchersMap RBSearchersStore[2]; // for 2 factions typedef std::unordered_map<uint32 /*dungeonId*/, WorldPacket> RBCacheMap; RBCacheMap RBCacheStore[2]; // for 2 factions - typedef std::unordered_map<uint32 /*guidLow*/, RBInternalInfo> RBInternalInfoMap; + typedef std::unordered_map<ObjectGuid /*guid*/, RBInternalInfo> RBInternalInfoMap; typedef std::unordered_map<uint32 /*dungeonId*/, RBInternalInfoMap> RBInternalInfoMapMap; RBInternalInfoMapMap RBInternalInfoStorePrev[2]; // for 2 factions RBInternalInfoMapMap RBInternalInfoStoreCurr[2]; // for 2 factions @@ -423,7 +422,7 @@ namespace lfg // World.cpp /// Finish the dungeon for the given group. All check are performed using internal lfg data - void FinishDungeon(uint64 gguid, uint32 dungeonId, const Map* currMap); + void FinishDungeon(ObjectGuid gguid, uint32 dungeonId, const Map* currMap); /// Loads rewards for random dungeons void LoadRewards(); /// Loads dungeons from dbc and adds teleport coords @@ -431,31 +430,31 @@ namespace lfg // Multiple files /// Check if given guid applied for random dungeon - bool selectedRandomLfgDungeon(uint64 guid); + bool selectedRandomLfgDungeon(ObjectGuid guid); /// Check if given guid applied for given map and difficulty. Used to know - bool inLfgDungeonMap(uint64 guid, uint32 map, Difficulty difficulty); + bool inLfgDungeonMap(ObjectGuid guid, uint32 map, Difficulty difficulty); /// Get selected dungeons - LfgDungeonSet const& GetSelectedDungeons(uint64 guid); + LfgDungeonSet const& GetSelectedDungeons(ObjectGuid guid); /// Get current lfg state - LfgState GetState(uint64 guid); + LfgState GetState(ObjectGuid guid); /// Get current dungeon - uint32 GetDungeon(uint64 guid, bool asId = true); + uint32 GetDungeon(ObjectGuid guid, bool asId = true); /// Get the map id of the current dungeon - uint32 GetDungeonMapId(uint64 guid); + uint32 GetDungeonMapId(ObjectGuid guid); /// Get kicks left in current group - uint8 GetKicksLeft(uint64 gguid); + uint8 GetKicksLeft(ObjectGuid gguid); /// Load Lfg group info from DB - void _LoadFromDB(Field* fields, uint64 guid); + void _LoadFromDB(Field* fields, ObjectGuid guid); /// Initializes player data after loading group data from DB - void SetupGroupMember(uint64 guid, uint64 gguid); + void SetupGroupMember(ObjectGuid guid, ObjectGuid gguid); /// Return Lfg dungeon entry for given dungeon id uint32 GetLFGDungeonEntry(uint32 id); // cs_lfg /// Get current player roles - uint8 GetRoles(uint64 guid); + uint8 GetRoles(ObjectGuid guid); /// Get current player comment (used for LFR) - std::string const& GetComment(uint64 gguid); + std::string const& GetComment(ObjectGuid gguid); /// Gets current lfg options uint32 GetOptions(); /// Sets new lfg options @@ -467,33 +466,33 @@ namespace lfg // LFGScripts /// Get leader of the group (using internal data) - uint64 GetLeader(uint64 guid); + ObjectGuid GetLeader(ObjectGuid guid); /// Initializes locked dungeons for given player (called at login or level change) void InitializeLockedDungeons(Player* player, uint8 level = 0); /// Sets player team - void SetTeam(uint64 guid, TeamId teamId); + void SetTeam(ObjectGuid guid, TeamId teamId); /// Sets player group - void SetGroup(uint64 guid, uint64 group); + void SetGroup(ObjectGuid guid, ObjectGuid group); /// Gets player group - uint64 GetGroup(uint64 guid); + ObjectGuid GetGroup(ObjectGuid guid); /// Sets the leader of the group - void SetLeader(uint64 gguid, uint64 leader); + void SetLeader(ObjectGuid gguid, ObjectGuid leader); /// Removes saved group data - void RemoveGroupData(uint64 guid); + void RemoveGroupData(ObjectGuid guid); /// Removes a player from a group - uint8 RemovePlayerFromGroup(uint64 gguid, uint64 guid); + uint8 RemovePlayerFromGroup(ObjectGuid gguid, ObjectGuid guid); /// Adds player to group - void AddPlayerToGroup(uint64 gguid, uint64 guid); + void AddPlayerToGroup(ObjectGuid gguid, ObjectGuid guid); /// Xinef: Set Random Players Count - void SetRandomPlayersCount(uint64 guid, uint8 count); + void SetRandomPlayersCount(ObjectGuid guid, uint8 count); /// Xinef: Get Random Players Count - uint8 GetRandomPlayersCount(uint64 guid); + uint8 GetRandomPlayersCount(ObjectGuid guid); // LFGHandler /// Get locked dungeons - LfgLockMap const& GetLockedDungeons(uint64 guid); + LfgLockMap const& GetLockedDungeons(ObjectGuid guid); /// Returns current lfg status - LfgUpdateData GetLfgStatus(uint64 guid); + LfgUpdateData GetLfgStatus(ObjectGuid guid); /// Checks if Seasonal dungeon is active bool IsSeasonActive(uint32 dungeonId); /// Gets the random dungeon reward corresponding to given dungeon and player level @@ -503,26 +502,26 @@ namespace lfg /// Teleport a player to/from selected dungeon void TeleportPlayer(Player* player, bool out, bool fromOpcode = false); /// Inits new proposal to boot a player - void InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string const& reason); + void InitBoot(ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, std::string const& reason); /// Updates player boot proposal with new player answer - void UpdateBoot(uint64 guid, bool accept); + void UpdateBoot(ObjectGuid guid, bool accept); /// Updates proposal to join dungeon with player answer - void UpdateProposal(uint32 proposalId, uint64 guid, bool accept); + void UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept); /// Updates the role check with player answer - void UpdateRoleCheck(uint64 gguid, uint64 guid = 0, uint8 roles = PLAYER_ROLE_NONE); + void UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid = ObjectGuid::Empty, uint8 roles = PLAYER_ROLE_NONE); /// Sets player lfg roles - void SetRoles(uint64 guid, uint8 roles); + void SetRoles(ObjectGuid guid, uint8 roles); /// Sets player lfr comment - void SetComment(uint64 guid, std::string const& comment); + void SetComment(ObjectGuid guid, std::string const& comment); /// Join Lfg with selected roles, dungeons and comment void JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, std::string const& comment); /// Leaves lfg - void LeaveLfg(uint64 guid); + void LeaveLfg(ObjectGuid guid); /// pussywizard: cleans all queues' data - void LeaveAllLfgQueues(uint64 guid, bool allowgroup, uint64 groupguid = 0); + void LeaveAllLfgQueues(ObjectGuid guid, bool allowgroup, ObjectGuid groupguid = ObjectGuid::Empty); /// pussywizard: Raid Browser void JoinRaidBrowser(Player* player, uint8 roles, LfgDungeonSet& dungeons, std::string comment); - void LeaveRaidBrowser(uint64 guid); + void LeaveRaidBrowser(ObjectGuid guid); void LfrSearchAdd(Player* p, uint32 dungeonId); void LfrSearchRemove(Player* p); void SendRaidBrowserCachedList(Player* player, uint32 dungeonId); @@ -536,11 +535,11 @@ namespace lfg // LfgQueue /// Get last lfg state (NONE, DUNGEON or FINISHED_DUNGEON) - LfgState GetOldState(uint64 guid); + LfgState GetOldState(ObjectGuid guid); /// Check if given group guid is lfg - bool IsLfgGroup(uint64 guid); + bool IsLfgGroup(ObjectGuid guid); /// Gets the player count of given group - uint8 GetPlayerCount(uint64 guid); + uint8 GetPlayerCount(ObjectGuid guid); /// Add a new Proposal uint32 AddProposal(LfgProposal& proposal); /// Checks if all players are queued @@ -548,22 +547,22 @@ namespace lfg /// Checks if given roles match, modifies given roles map with new roles static uint8 CheckGroupRoles(LfgRolesMap& groles, bool removeLeaderFlag = true); /// Checks if given players are ignoring each other - static bool HasIgnore(uint64 guid1, uint64 guid2); + static bool HasIgnore(ObjectGuid guid1, ObjectGuid guid2); /// Sends queue status to player - static void SendLfgQueueStatus(uint64 guid, LfgQueueStatusData const& data); + static void SendLfgQueueStatus(ObjectGuid guid, LfgQueueStatusData const& data); private: - TeamId GetTeam(uint64 guid); - void RestoreState(uint64 guid, char const* debugMsg); - void ClearState(uint64 guid, char const* debugMsg); - void SetDungeon(uint64 guid, uint32 dungeon); - void SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons); - void SetLockedDungeons(uint64 guid, LfgLockMap const& lock); - void DecreaseKicksLeft(uint64 guid); - void SetState(uint64 guid, LfgState state); - void SetCanOverrideRBState(uint64 guid, bool val); + TeamId GetTeam(ObjectGuid guid); + void RestoreState(ObjectGuid guid, char const* debugMsg); + void ClearState(ObjectGuid guid, char const* debugMsg); + void SetDungeon(ObjectGuid guid, uint32 dungeon); + void SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const& dungeons); + void SetLockedDungeons(ObjectGuid guid, LfgLockMap const& lock); + void DecreaseKicksLeft(ObjectGuid guid); + void SetState(ObjectGuid guid, LfgState state); + void SetCanOverrideRBState(ObjectGuid guid, bool val); void GetCompatibleDungeons(LfgDungeonSet& dungeons, LfgGuidSet const& players, LfgLockPartyMap& lockMap); - void _SaveToDB(uint64 guid); + void _SaveToDB(ObjectGuid guid); LFGDungeonData const* GetLFGDungeon(uint32 id); // Proposals @@ -571,19 +570,19 @@ namespace lfg void MakeNewGroup(LfgProposal const& proposal); // Generic - LFGQueue& GetQueue(uint64 guid); + LFGQueue& GetQueue(ObjectGuid guid); LfgDungeonSet const& GetDungeonsByRandom(uint32 randomdungeon); LfgType GetDungeonType(uint32 dungeon); - void SendLfgBootProposalUpdate(uint64 guid, LfgPlayerBoot const& boot); - void SendLfgJoinResult(uint64 guid, LfgJoinResultData const& data); - void SendLfgRoleChosen(uint64 guid, uint64 pguid, uint8 roles); - void SendLfgRoleCheckUpdate(uint64 guid, LfgRoleCheck const& roleCheck); - void SendLfgUpdateParty(uint64 guid, LfgUpdateData const& data); - void SendLfgUpdatePlayer(uint64 guid, LfgUpdateData const& data); - void SendLfgUpdateProposal(uint64 guid, LfgProposal const& proposal); + void SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const& boot); + void SendLfgJoinResult(ObjectGuid guid, LfgJoinResultData const& data); + void SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, uint8 roles); + void SendLfgRoleCheckUpdate(ObjectGuid guid, LfgRoleCheck const& roleCheck); + void SendLfgUpdateParty(ObjectGuid guid, LfgUpdateData const& data); + void SendLfgUpdatePlayer(ObjectGuid guid, LfgUpdateData const& data); + void SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const& proposal); - LfgGuidSet const& GetPlayers(uint64 guid); + LfgGuidSet const& GetPlayers(ObjectGuid guid); // General variables uint32 m_lfgProposalId; ///< used as internal counter for proposals diff --git a/src/server/game/DungeonFinding/LFGPlayerData.cpp b/src/server/game/DungeonFinding/LFGPlayerData.cpp index 125e9f03e4..f689c7c30c 100644 --- a/src/server/game/DungeonFinding/LFGPlayerData.cpp +++ b/src/server/game/DungeonFinding/LFGPlayerData.cpp @@ -11,7 +11,7 @@ namespace lfg { LfgPlayerData::LfgPlayerData(): m_State(LFG_STATE_NONE), m_OldState(LFG_STATE_NONE), m_canOverrideRBState(false), - m_TeamId(TEAM_ALLIANCE), m_Group(0), m_Roles(0), m_Comment("") + m_TeamId(TEAM_ALLIANCE), m_Roles(0), m_Comment("") {} LfgPlayerData::~LfgPlayerData() @@ -62,7 +62,7 @@ namespace lfg m_TeamId = teamId; } - void LfgPlayerData::SetGroup(uint64 group) + void LfgPlayerData::SetGroup(ObjectGuid group) { m_Group = group; } @@ -112,7 +112,7 @@ namespace lfg return m_TeamId; } - uint64 LfgPlayerData::GetGroup() const + ObjectGuid LfgPlayerData::GetGroup() const { return m_Group; } diff --git a/src/server/game/DungeonFinding/LFGPlayerData.h b/src/server/game/DungeonFinding/LFGPlayerData.h index 4426181b68..4236d09374 100644 --- a/src/server/game/DungeonFinding/LFGPlayerData.h +++ b/src/server/game/DungeonFinding/LFGPlayerData.h @@ -27,7 +27,7 @@ namespace lfg void RestoreState(); void SetLockedDungeons(LfgLockMap const& lock); void SetTeam(TeamId teamId); - void SetGroup(uint64 group); + void SetGroup(ObjectGuid group); void SetRandomPlayersCount(uint8 count); // Queue @@ -40,7 +40,7 @@ namespace lfg LfgState GetOldState() const; LfgLockMap const& GetLockedDungeons() const; TeamId GetTeam() const; - uint64 GetGroup() const; + ObjectGuid GetGroup() const; uint8 GetRandomPlayersCount() const; void SetCanOverrideRBState(bool val) { m_canOverrideRBState = val; } bool CanOverrideRBState() const { return m_canOverrideRBState; } @@ -58,7 +58,7 @@ namespace lfg // Player LfgLockMap m_LockedDungeons; ///< Dungeons player can't do and reason TeamId m_TeamId; ///< Player team - determines the queue to join - uint64 m_Group; ///< Original group of player when joined LFG + ObjectGuid m_Group; ///< Original group of player when joined LFG uint8 m_randomPlayers; ///< Xinef: Amount of random players you raid with // Queue diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index 252fa71778..86ead49f67 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -29,22 +29,22 @@ namespace lfg { - void LFGQueue::AddToQueue(uint64 guid, bool failedProposal) + void LFGQueue::AddToQueue(ObjectGuid guid, bool failedProposal) { - //LOG_INFO("server", "ADD AddToQueue: %u, failed proposal: %u", GUID_LOPART(guid), failedProposal ? 1 : 0); + //LOG_INFO("server", "ADD AddToQueue: %s, failed proposal: %u", guid.ToString().c_str(), failedProposal ? 1 : 0); LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid); if (itQueue == QueueDataStore.end()) { - LOG_ERROR("server", "LFGQueue::AddToQueue: Queue data not found for [" UI64FMTD "]", guid); + LOG_ERROR("server", "LFGQueue::AddToQueue: Queue data not found for [%s]", guid.ToString().c_str()); return; } - //LOG_INFO("server", "AddToQueue success: %u", GUID_LOPART(guid)); + //LOG_INFO("server", "AddToQueue success: %s", guid.ToString().c_str()); AddToNewQueue(guid, failedProposal); } - void LFGQueue::RemoveFromQueue(uint64 guid, bool partial) + void LFGQueue::RemoveFromQueue(ObjectGuid guid, bool partial) { - //LOG_INFO("server", "REMOVE RemoveFromQueue: %u, partial: %u", GUID_LOPART(guid), partial ? 1 : 0); + //LOG_INFO("server", "REMOVE RemoveFromQueue: %s, partial: %u", guid.ToString().c_str(), partial ? 1 : 0); RemoveFromNewQueue(guid); RemoveFromCompatibles(guid); @@ -55,13 +55,13 @@ namespace lfg { if (itr->second.bestCompatible.hasGuid(guid)) { - //LOG_INFO("server", "CLEAR bestCompatible: %s, because of guid: %u", itr->second.bestCompatible.toString().c_str(), GUID_LOPART(guid)); + //LOG_INFO("server", "CLEAR bestCompatible: %s, because of: %s", itr->second.bestCompatible.toString().c_str(), guid.ToString().c_str()); itr->second.bestCompatible.clear(); } } else { - //LOG_INFO("server", "CLEAR bestCompatible SELF: %s, because of guid: %u", itr->second.bestCompatible.toString().c_str(), GUID_LOPART(guid)); + //LOG_INFO("server", "CLEAR bestCompatible SELF: %s, because of: %s", itr->second.bestCompatible.toString().c_str(), guid.ToString().c_str()); //itr->second.bestCompatible.clear(); // don't clear here, because UpdateQueueTimers will try to find with every diff update itDelete = itr; } @@ -70,45 +70,45 @@ namespace lfg // xinef: partial if (!partial && itDelete != QueueDataStore.end()) { - //LOG_INFO("server", "ERASE QueueDataStore for: %u", GUID_LOPART(guid)); - //LOG_INFO("server", "ERASE QueueDataStore for: %u, itDelete: %u,%u,%u", GUID_LOPART(guid), itDelete->second.dps, itDelete->second.healers, itDelete->second.tanks); + //LOG_INFO("server", "ERASE QueueDataStore for: %s", guid.ToString().c_str()); + //LOG_INFO("server", "ERASE QueueDataStore for: %s, itDelete: %u,%u,%u", guid.ToString().c_str(), itDelete->second.dps, itDelete->second.healers, itDelete->second.tanks); QueueDataStore.erase(itDelete); - //LOG_INFO("server", "ERASE QueueDataStore for: %u SUCCESS", GUID_LOPART(guid)); + //LOG_INFO("server", "ERASE QueueDataStore for: %s SUCCESS", guid.ToString().c_str()); } } - void LFGQueue::AddToNewQueue(uint64 guid, bool front) + void LFGQueue::AddToNewQueue(ObjectGuid guid, bool front) { if (front) { - //LOG_INFO("server", "ADD AddToNewQueue at FRONT: %u", GUID_LOPART(guid)); + //LOG_INFO("server", "ADD AddToNewQueue at FRONT: %s", guid.ToString().c_str()); restoredAfterProposal.push_back(guid); newToQueueStore.push_front(guid); } else { - //LOG_INFO("server", "ADD AddToNewQueue at the END: %u", GUID_LOPART(guid)); + //LOG_INFO("server", "ADD AddToNewQueue at the END: %s", guid.ToString().c_str()); newToQueueStore.push_back(guid); } } - void LFGQueue::RemoveFromNewQueue(uint64 guid) + void LFGQueue::RemoveFromNewQueue(ObjectGuid guid) { - //LOG_INFO("server", "REMOVE RemoveFromNewQueue: %u", GUID_LOPART(guid)); + //LOG_INFO("server", "REMOVE RemoveFromNewQueue: %s", guid.ToString().c_str()); newToQueueStore.remove(guid); restoredAfterProposal.remove(guid); } - void LFGQueue::AddQueueData(uint64 guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap) + void LFGQueue::AddQueueData(ObjectGuid guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap) { - //LOG_INFO("server", "JOINED AddQueueData: %u", GUID_LOPART(guid)); + //LOG_INFO("server", "JOINED AddQueueData: %s", guid.ToString().c_str()); QueueDataStore[guid] = LfgQueueData(joinTime, dungeons, rolesMap); AddToQueue(guid); } - void LFGQueue::RemoveQueueData(uint64 guid) + void LFGQueue::RemoveQueueData(ObjectGuid guid) { - //LOG_INFO("server", "LEFT RemoveQueueData: %u", GUID_LOPART(guid)); + //LOG_INFO("server", "LEFT RemoveQueueData: %s", guid.ToString().c_str()); LfgQueueDataContainer::iterator it = QueueDataStore.find(guid); if (it != QueueDataStore.end()) QueueDataStore.erase(it); @@ -142,13 +142,13 @@ namespace lfg wt.time = int32((wt.time * old_number + waitTime) / wt.number); } - void LFGQueue::RemoveFromCompatibles(uint64 guid) + void LFGQueue::RemoveFromCompatibles(ObjectGuid guid) { - //LOG_INFO("server", "COMPATIBLES REMOVE for: %u", GUID_LOPART(guid)); + //LOG_INFO("server", "COMPATIBLES REMOVE for: %s", guid.ToString().c_str()); for (LfgCompatibleContainer::iterator it = CompatibleList.begin(); it != CompatibleList.end(); ++it) if (it->hasGuid(guid)) { - //LOG_INFO("server", "Removed Compatible: %s, because of guid: %u", it->toString().c_str(), GUID_LOPART(guid)); + //LOG_INFO("server", "Removed Compatible: %s, because of: %s", it->toString().c_str(), guid.ToString().c_str()); it->clear(); // set to 0, this will be removed while iterating in FindNewGroups } for (LfgCompatibleContainer::iterator itr = CompatibleTempList.begin(); itr != CompatibleTempList.end(); ) @@ -156,7 +156,7 @@ namespace lfg LfgCompatibleContainer::iterator it = itr++; if (it->hasGuid(guid)) { - //LOG_INFO("server", "Erased Temp Compatible: %s, because of guid: %u", it->toString().c_str(), GUID_LOPART(guid)); + //LOG_INFO("server", "Erased Temp Compatible: %s, because of: %s", it->toString().c_str(), guid.ToString().c_str()); CompatibleTempList.erase(it); } } @@ -175,9 +175,9 @@ namespace lfg if (!newToQueueStore.empty()) { ++newGroupsProcessed; - uint64 newGuid = newToQueueStore.front(); + ObjectGuid newGuid = newToQueueStore.front(); bool pushCompatiblesToFront = (std::find(restoredAfterProposal.begin(), restoredAfterProposal.end(), newGuid) != restoredAfterProposal.end()); - //LOG_INFO("server", "newToQueueStore guid: %u, front: %u", GUID_LOPART(newGuid), pushCompatiblesToFront ? 1 : 0); + //LOG_INFO("server", "newToQueueStore: %s, front: %u", newGuid.ToString().c_str(), pushCompatiblesToFront ? 1 : 0); RemoveFromNewQueue(newGuid); FindNewGroups(newGuid); @@ -190,14 +190,14 @@ namespace lfg return newGroupsProcessed; } - LfgCompatibility LFGQueue::FindNewGroups(const uint64& newGuid) + LfgCompatibility LFGQueue::FindNewGroups(const ObjectGuid& newGuid) { // each combination of dps+heal+tank (tank*8 + heal+4 + dps) has a value assigned 0..15 // first 16 bits of the mask are for marking if such combination was found once, second 16 bits for marking second occurence of that combination, etc uint64 foundMask = 0; uint32 foundCount = 0; - //LOG_INFO("server", "FIND NEW GROUPS for: %u", GUID_LOPART(newGuid)); + //LOG_INFO("server", "FIND NEW GROUPS for: %s", newGuid.ToString().c_str()); // we have to take into account that FindNewGroups is called every X minutes if number of compatibles is low! // build set of already present compatibles for this guid @@ -239,9 +239,9 @@ namespace lfg return selfCompatibility; } - LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const uint64& newGuid, uint64& foundMask, uint32& foundCount, const std::set<Lfg5Guids>& currentCompatibles) + LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const ObjectGuid& newGuid, uint64& foundMask, uint32& foundCount, const std::set<Lfg5Guids>& currentCompatibles) { - //LOG_INFO("server", "CHECK CheckCompatibility: %s, new guid: %u", checkWith.toString().c_str(), GUID_LOPART(newGuid)); + //LOG_INFO("server", "CHECK CheckCompatibility: %s, new guid: %s", checkWith.toString().c_str(), newGuid.ToString().c_str()); Lfg5Guids check(checkWith, false); // here newGuid is at front Lfg5Guids strGuids(checkWith, false); // here guids are sorted check.force_insert_front(newGuid); @@ -258,22 +258,23 @@ namespace lfg // Check if more than one LFG group and number of players joining uint8 numPlayers = 0; uint8 numLfgGroups = 0; - uint64 guid; + ObjectGuid guid; uint64 addToFoundMask = 0; - for (uint8 i = 0; i < 5 && (guid = check.guid[i]) != 0 && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++i) + for (uint8 i = 0; i < 5 && !(guid = check.guids[i]).IsEmpty() && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++i) { LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid); if (itQueue == QueueDataStore.end()) { - LOG_ERROR("server", "LFGQueue::CheckCompatibility: [" UI64FMTD "] is not queued but listed as queued!", guid); + LOG_ERROR("server", "LFGQueue::CheckCompatibility: [%s] is not queued but listed as queued!", guid.ToString().c_str()); RemoveFromQueue(guid); return LFG_COMPATIBILITY_PENDING; } // Store group so we don't need to call Mgr to get it later (if it's player group will be 0 otherwise would have joined as group) for (LfgRolesMap::const_iterator it2 = itQueue->second.roles.begin(); it2 != itQueue->second.roles.end(); ++it2) - proposalGroups[it2->first] = IS_GROUP_GUID(itQueue->first) ? itQueue->first : 0; + proposalGroups[it2->first] = itQueue->first.IsGroup() ? itQueue->first : ObjectGuid::Empty; +; numPlayers += itQueue->second.roles.size(); @@ -309,9 +310,9 @@ namespace lfg // If it's single group no need to check for duplicate players, ignores, bad roles or bad dungeons as it's been checked before joining if (check.size() > 1) { - for (uint8 i = 0; i < 5 && check.guid[i]; ++i) + for (uint8 i = 0; i < 5 && check.guids[i]; ++i) { - const LfgRolesMap& roles = QueueDataStore[check.guid[i]].roles; + const LfgRolesMap& roles = QueueDataStore[check.guids[i]].roles; for (LfgRolesMap::const_iterator itRoles = roles.begin(); itRoles != roles.end(); ++itRoles) { LfgRolesMap::const_iterator itPlayer; @@ -320,7 +321,7 @@ namespace lfg if (itRoles->first == itPlayer->first) { // pussywizard: LFG ZOMG! this means that this player was in two different LfgQueueData (in QueueDataStore), and at least one of them is a group guid, because we do checks so there aren't 2 same guids in current CHECK - //LOG_ERROR("server", "LFGQueue::CheckCompatibility: ERROR! Player multiple times in queue! [" UI64FMTD "]", itRoles->first); + //LOG_ERROR("server", "LFGQueue::CheckCompatibility: ERROR! Player multiple times in queue! [%s]", itRoles->first.ToString().c_str()); break; } else if (sLFGMgr->HasIgnore(itRoles->first, itPlayer->first)) @@ -365,10 +366,10 @@ namespace lfg addToFoundMask |= (((uint64)1) << (roleCheckResult - 1)); proposalDungeons = QueueDataStore[check.front()].dungeons; - for (uint8 i = 1; i < 5 && check.guid[i]; ++i) + for (uint8 i = 1; i < 5 && check.guids[i]; ++i) { LfgDungeonSet temporal; - LfgDungeonSet& dungeons = QueueDataStore[check.guid[i]].dungeons; + LfgDungeonSet& dungeons = QueueDataStore[check.guids[i]].dungeons; std::set_intersection(proposalDungeons.begin(), proposalDungeons.end(), dungeons.begin(), dungeons.end(), std::inserter(temporal, temporal.begin())); proposalDungeons = temporal; } @@ -378,7 +379,7 @@ namespace lfg } else { - uint64 gguid = check.front(); + ObjectGuid gguid = check.front(); const LfgQueueData& queue = QueueDataStore[gguid]; proposalDungeons = queue.dungeons; proposalRoles = queue.roles; @@ -389,9 +390,9 @@ namespace lfg if (numPlayers != MAXGROUPSIZE) { strGuids.addRoles(proposalRoles); - for (uint8 i = 0; i < 5 && check.guid[i]; ++i) + for (uint8 i = 0; i < 5 && check.guids[i]; ++i) { - LfgQueueDataContainer::iterator itr = QueueDataStore.find(check.guid[i]); + LfgQueueDataContainer::iterator itr = QueueDataStore.find(check.guids[i]); if (!itr->second.bestCompatible.empty()) // update if groups don't have it empty (for empty it will be generated in UpdateQueueTimers) UpdateBestCompatibleInQueue(itr, strGuids); } @@ -401,7 +402,7 @@ namespace lfg return LFG_COMPATIBLES_WITH_LESS_PLAYERS; } - uint64 gguid = check.front(); + ObjectGuid gguid = check.front(); proposal.queues = strGuids; proposal.isNew = numLfgGroups != 1 || sLFGMgr->GetOldState(gguid) != LFG_STATE_DUNGEON; @@ -411,7 +412,7 @@ namespace lfg // Create a new proposal proposal.cancelTime = time(nullptr) + LFG_TIME_PROPOSAL; proposal.state = LFG_PROPOSAL_INITIATING; - proposal.leader = 0; + proposal.leader.Clear(); proposal.dungeonId = acore::Containers::SelectRandomContainerElement(proposalDungeons); bool leader = false; @@ -435,8 +436,8 @@ namespace lfg data.accept = LFG_ANSWER_AGREE; } - for (uint8 i = 0; i < 5 && proposal.queues.guid[i]; ++i) - RemoveFromQueue(proposal.queues.guid[i], true); + for (uint8 i = 0; i < 5 && proposal.queues.guids[i]; ++i) + RemoveFromQueue(proposal.queues.guids[i], true); sLFGMgr->AddProposal(proposal); @@ -473,7 +474,7 @@ namespace lfg { if (currTime - itQueue->second.joinTime > 2 * HOUR) { - uint64 guid = itQueue->first; + ObjectGuid guid = itQueue->first; QueueDataStore.erase(itQueue++); sLFGMgr->LeaveAllLfgQueues(guid, true); continue; @@ -537,13 +538,13 @@ namespace lfg LfgQueueStatusData queueData(dungeonId, waitTime, wtAvg, wtTank, wtHealer, wtDps, queuedTime, queueinfo.tanks, queueinfo.healers, queueinfo.dps); for (LfgRolesMap::const_iterator itPlayer = queueinfo.roles.begin(); itPlayer != queueinfo.roles.end(); ++itPlayer) { - uint64 pguid = itPlayer->first; + ObjectGuid pguid = itPlayer->first; LFGMgr::SendLfgQueueStatus(pguid, queueData); } } } - time_t LFGQueue::GetJoinTime(uint64 guid) + time_t LFGQueue::GetJoinTime(ObjectGuid guid) { return QueueDataStore[guid].joinTime; } diff --git a/src/server/game/DungeonFinding/LFGQueue.h b/src/server/game/DungeonFinding/LFGQueue.h index 86e856b80a..df4bfedfaf 100644 --- a/src/server/game/DungeonFinding/LFGQueue.h +++ b/src/server/game/DungeonFinding/LFGQueue.h @@ -55,7 +55,7 @@ namespace lfg }; typedef std::map<uint32, LfgWaitTime> LfgWaitTimesContainer; - typedef std::map<uint64, LfgQueueData> LfgQueueDataContainer; + typedef std::map<ObjectGuid, LfgQueueData> LfgQueueDataContainer; typedef std::list<Lfg5Guids> LfgCompatibleContainer; /** @@ -65,10 +65,10 @@ namespace lfg { public: // Add/Remove from queue - void AddToQueue(uint64 guid, bool failedProposal = false); - void RemoveFromQueue(uint64 guid, bool partial = false); // xinef: partial remove, dont delete data from list! - void AddQueueData(uint64 guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap); - void RemoveQueueData(uint64 guid); + void AddToQueue(ObjectGuid guid, bool failedProposal = false); + void RemoveFromQueue(ObjectGuid guid, bool partial = false); // xinef: partial remove, dont delete data from list! + void AddQueueData(ObjectGuid guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap); + void RemoveQueueData(ObjectGuid guid); // Update Timers (when proposal success) void UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId); @@ -78,7 +78,7 @@ namespace lfg // Update Queue timers void UpdateQueueTimers(uint32 diff); - time_t GetJoinTime(uint64 guid); + time_t GetJoinTime(ObjectGuid guid); // Find new group uint8 FindGroups(); @@ -86,17 +86,17 @@ namespace lfg private: void SetQueueUpdateData(std::string const& strGuids, LfgRolesMap const& proposalRoles); - void AddToNewQueue(uint64 guid, bool front); - void RemoveFromNewQueue(uint64 guid); + void AddToNewQueue(ObjectGuid guid, bool front); + void RemoveFromNewQueue(ObjectGuid guid); - void RemoveFromCompatibles(uint64 guid); + void RemoveFromCompatibles(ObjectGuid guid); void AddToCompatibles(Lfg5Guids const& key); uint32 FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue); void UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, Lfg5Guids const& key); - LfgCompatibility FindNewGroups(const uint64& newGuid); - LfgCompatibility CheckCompatibility(Lfg5Guids const& checkWith, const uint64& newGuid, uint64& foundMask, uint32& foundCount, const std::set<Lfg5Guids>& currentCompatibles); + LfgCompatibility FindNewGroups(const ObjectGuid& newGuid); + LfgCompatibility CheckCompatibility(Lfg5Guids const& checkWith, const ObjectGuid& newGuid, uint64& foundMask, uint32& foundCount, const std::set<Lfg5Guids>& currentCompatibles); // Queue uint32 m_QueueStatusTimer; ///< used to check interval of sending queue status diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index 46ba514759..fd5cb2d521 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -42,7 +42,7 @@ namespace lfg { player->GetSession()->SendLfgLfrList(false); sLFGMgr->LeaveLfg(player->GetGUID()); - sLFGMgr->LeaveAllLfgQueues(player->GetGUID(), true, player->GetGroup() ? player->GetGroup()->GetGUID() : 0); + sLFGMgr->LeaveAllLfgQueues(player->GetGUID(), true, player->GetGroup() ? player->GetGroup()->GetGUID() : ObjectGuid::Empty); // pussywizard: after all necessary actions handle raid browser // pussywizard: already done above @@ -59,16 +59,16 @@ namespace lfg return; // Temporal: Trying to determine when group data and LFG data gets desynched - uint64 guid = player->GetGUID(); - uint64 gguid = sLFGMgr->GetGroup(guid); + ObjectGuid guid = player->GetGUID(); + ObjectGuid gguid = sLFGMgr->GetGroup(guid); if (Group const* group = player->GetGroup()) { - uint64 gguid2 = group->GetGUID(); + ObjectGuid gguid2 = group->GetGUID(); if (gguid != gguid2) { - //LOG_ERROR("server", "%s on group %u but LFG has group %u saved... Fixing.", - // player->GetSession()->GetPlayerInfo().c_str(), GUID_LOPART(gguid2), GUID_LOPART(gguid)); + //LOG_ERROR("server", "%s on group %s but LFG has group %s saved... Fixing.", + // player->GetSession()->GetPlayerInfo().c_str(), gguid2.ToString().c_str(), gguid.ToString().c_str()); sLFGMgr->SetupGroupMember(guid, group->GetGUID()); } } @@ -103,7 +103,8 @@ namespace lfg player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW); player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, 0.0f); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGPlayerScript::OnMapChanged, Player %s (%u) is in LFG dungeon map but does not have a valid group! Teleporting to homebind.", player->GetName().c_str(), player->GetGUIDLow()); + LOG_DEBUG("lfg", "LFGPlayerScript::OnMapChanged, Player %s (%s) is in LFG dungeon map but does not have a valid group! Teleporting to homebind.", + player->GetName().c_str(), player->GetGUID().ToString().c_str()); #endif return; } @@ -130,18 +131,18 @@ namespace lfg { } - void LFGGroupScript::OnAddMember(Group* group, uint64 guid) + void LFGGroupScript::OnAddMember(Group* group, ObjectGuid guid) { if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; - uint64 gguid = group->GetGUID(); - uint64 leader = group->GetLeaderGUID(); + ObjectGuid gguid = group->GetGUID(); + ObjectGuid leader = group->GetLeaderGUID(); if (leader == guid) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGScripts::OnAddMember [" UI64FMTD "]: added [" UI64FMTD "] leader " UI64FMTD "]", gguid, guid, leader); + LOG_DEBUG("lfg", "LFGScripts::OnAddMember [%s]: added [%s] leader [%s]", gguid.ToString().c_str(), guid.ToString().c_str(), leader.ToString().c_str()); #endif sLFGMgr->SetLeader(gguid, guid); } @@ -150,7 +151,8 @@ namespace lfg LfgState gstate = sLFGMgr->GetState(gguid); LfgState state = sLFGMgr->GetState(guid); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGScripts::OnAddMember [" UI64FMTD "]: added [" UI64FMTD "] leader " UI64FMTD "] gstate: %u, state: %u", gguid, guid, leader, gstate, state); + LOG_DEBUG("lfg", "LFGScripts::OnAddMember [%s]: added [%s] leader [%s] gstate: %u, state: %u", + gguid.ToString().c_str(), guid.ToString().c_str(), leader.ToString().c_str(), gstate, state); #endif if (state == LFG_STATE_QUEUED) @@ -174,7 +176,7 @@ namespace lfg sLFGMgr->LeaveLfg(guid); } - void LFGGroupScript::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, char const* reason) + void LFGGroupScript::OnRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, char const* reason) { // used only with EXTRA_LOGS UNUSED(kicker); @@ -183,9 +185,10 @@ namespace lfg if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; - uint64 gguid = group->GetGUID(); + ObjectGuid gguid = group->GetGUID(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGScripts::OnRemoveMember [" UI64FMTD "]: remove [" UI64FMTD "] Method: %d Kicker: [" UI64FMTD "] Reason: %s", gguid, guid, method, kicker, (reason ? reason : "")); + LOG_DEBUG("lfg", "LFGScripts::OnRemoveMember [%s]: remove [%s] Method: %d Kicker: [%s] Reason: %s", + gguid.ToString().c_str(), guid.ToString().c_str(), method, kicker.ToString().c_str(), (reason ? reason : "")); #endif bool isLFG = group->isLFGGroup(); @@ -195,14 +198,14 @@ namespace lfg if (state == LFG_STATE_PROPOSAL && method == GROUP_REMOVEMETHOD_DEFAULT) { // LfgData: Remove player from group - sLFGMgr->SetGroup(guid, 0); + sLFGMgr->SetGroup(guid, ObjectGuid::Empty); sLFGMgr->RemovePlayerFromGroup(gguid, guid); return; } sLFGMgr->LeaveLfg(guid); sLFGMgr->LeaveAllLfgQueues(guid, true, gguid); - sLFGMgr->SetGroup(guid, 0); + sLFGMgr->SetGroup(guid, ObjectGuid::Empty); uint8 players = sLFGMgr->RemovePlayerFromGroup(gguid, guid); // pussywizard: after all necessary actions handle raid browser @@ -214,7 +217,7 @@ namespace lfg if (!isLFG) return; - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) { // xinef: fixed dungeon deserter if (method != GROUP_REMOVEMETHOD_KICK_LFG && state != LFG_STATE_FINISHED_DUNGEON && @@ -235,7 +238,7 @@ namespace lfg } if (state != LFG_STATE_FINISHED_DUNGEON) // Need more players to finish the dungeon - if (Player* leader = ObjectAccessor::FindPlayerInOrOutOfWorld(sLFGMgr->GetLeader(gguid))) + if (Player* leader = ObjectAccessor::FindConnectedPlayer(sLFGMgr->GetLeader(gguid))) leader->GetSession()->SendLfgOfferContinue(sLFGMgr->GetDungeon(gguid, false)); } @@ -244,9 +247,9 @@ namespace lfg if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; - uint64 gguid = group->GetGUID(); + ObjectGuid gguid = group->GetGUID(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGScripts::OnDisband [" UI64FMTD "]", gguid); + LOG_DEBUG("lfg", "LFGScripts::OnDisband [%s]", gguid.ToString().c_str()); #endif // pussywizard: after all necessary actions handle raid browser @@ -256,15 +259,16 @@ namespace lfg sLFGMgr->RemoveGroupData(gguid); } - void LFGGroupScript::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid) + void LFGGroupScript::OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid) { if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; - uint64 gguid = group->GetGUID(); + ObjectGuid gguid = group->GetGUID(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGScripts::OnChangeLeader [" UI64FMTD "]: old [" UI64FMTD "] new [" UI64FMTD "]", gguid, newLeaderGuid, oldLeaderGuid); + LOG_DEBUG("lfg", "LFGScripts::OnChangeLeader [%s]: old [%s] new [%s]", + gguid.ToString().c_str(), newLeaderGuid.ToString().c_str(), oldLeaderGuid.ToString().c_str()); #endif sLFGMgr->SetLeader(gguid, newLeaderGuid); @@ -273,7 +277,7 @@ namespace lfg sLFGMgr->LeaveLfg(oldLeaderGuid); } - void LFGGroupScript::OnInviteMember(Group* group, uint64 guid) + void LFGGroupScript::OnInviteMember(Group* group, ObjectGuid guid) { // used only with EXTRA_LOGS UNUSED(guid); @@ -281,10 +285,10 @@ namespace lfg if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; - uint64 gguid = group->GetGUID(); - uint64 leader = group->GetLeaderGUID(); + ObjectGuid gguid = group->GetGUID(); + ObjectGuid leader = group->GetLeaderGUID(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("lfg", "LFGScripts::OnInviteMember [" UI64FMTD "]: invite [" UI64FMTD "] leader [" UI64FMTD "]", gguid, guid, leader); + LOG_DEBUG("lfg", "LFGScripts::OnInviteMember [%s]: invite [%s] leader [%s]", gguid.ToString().c_str(), guid.ToString().c_str(), leader.ToString().c_str()); #endif // No gguid == new group being formed // No leader == after group creation first invite is new leader diff --git a/src/server/game/DungeonFinding/LFGScripts.h b/src/server/game/DungeonFinding/LFGScripts.h index 5fec1ddcc9..3a8f164a57 100644 --- a/src/server/game/DungeonFinding/LFGScripts.h +++ b/src/server/game/DungeonFinding/LFGScripts.h @@ -37,11 +37,11 @@ namespace lfg LFGGroupScript(); // Group Hooks - void OnAddMember(Group* group, uint64 guid) override; - void OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, char const* reason) override; + void OnAddMember(Group* group, ObjectGuid guid) override; + void OnRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, char const* reason) override; void OnDisband(Group* group) override; - void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid) override; - void OnInviteMember(Group* group, uint64 guid) override; + void OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid) override; + void OnInviteMember(Group* group, ObjectGuid guid) override; }; } // namespace lfg diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index 37564870a4..db9a33a013 100644 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -36,7 +36,7 @@ void Corpse::AddToWorld() { ///- Register the corpse for guid lookup if (!IsInWorld()) - sObjectAccessor->AddObject(this); + GetMap()->GetObjectsStore().Insert<Corpse>(GetGUID(), this); Object::AddToWorld(); } @@ -45,19 +45,18 @@ void Corpse::RemoveFromWorld() { ///- Remove the corpse from the accessor if (IsInWorld()) - sObjectAccessor->RemoveObject(this); + GetMap()->GetObjectsStore().Remove<Corpse>(GetGUID()); - Object::RemoveFromWorld(); + WorldObject::RemoveFromWorld(); } -bool Corpse::Create(uint32 guidlow, Map* map) +bool Corpse::Create(ObjectGuid::LowType guidlow) { - SetMap(map); - Object::_Create(guidlow, 0, HIGHGUID_CORPSE); + Object::_Create(guidlow, 0, HighGuid::Corpse); return true; } -bool Corpse::Create(uint32 guidlow, Player* owner) +bool Corpse::Create(ObjectGuid::LowType guidlow, Player* owner) { ASSERT(owner); @@ -70,16 +69,12 @@ bool Corpse::Create(uint32 guidlow, Player* owner) return false; } - //we need to assign owner's map for corpse - //in other way we will get a crash in Corpse::SaveToDB() - SetMap(owner->GetMap()); - - WorldObject::_Create(guidlow, HIGHGUID_CORPSE, owner->GetPhaseMask()); + WorldObject::_Create(guidlow, HighGuid::Corpse, owner->GetPhaseMask()); SetObjectScale(1); - SetUInt64Value(CORPSE_FIELD_OWNER, owner->GetGUID()); + SetGuidValue(CORPSE_FIELD_OWNER, owner->GetGUID()); - _gridCoord = acore::ComputeGridCoord(GetPositionX(), GetPositionY()); + _cellCoord = acore::ComputeCellCoord(GetPositionX(), GetPositionY()); return true; } @@ -91,24 +86,23 @@ void Corpse::SaveToDB() DeleteFromDB(trans); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE); - stmt->setUInt32(0, GetGUIDLow()); // corpseGuid - stmt->setUInt32(1, GUID_LOPART(GetOwnerGUID())); // guid - stmt->setFloat (2, GetPositionX()); // posX - stmt->setFloat (3, GetPositionY()); // posY - stmt->setFloat (4, GetPositionZ()); // posZ - stmt->setFloat (5, GetOrientation()); // orientation - stmt->setUInt16(6, GetMapId()); // mapId - stmt->setUInt32(7, GetUInt32Value(CORPSE_FIELD_DISPLAY_ID)); // displayId - stmt->setString(8, _ConcatFields(CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END)); // itemCache - stmt->setUInt32(9, GetUInt32Value(CORPSE_FIELD_BYTES_1)); // bytes1 - stmt->setUInt32(10, GetUInt32Value(CORPSE_FIELD_BYTES_2)); // bytes2 - stmt->setUInt32(11, GetUInt32Value(CORPSE_FIELD_GUILD)); // guildId - stmt->setUInt8 (12, GetUInt32Value(CORPSE_FIELD_FLAGS)); // flags - stmt->setUInt8 (13, GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS)); // dynFlags - stmt->setUInt32(14, uint32(m_time)); // time - stmt->setUInt8 (15, GetType()); // corpseType - stmt->setUInt32(16, GetInstanceId()); // instanceId - stmt->setUInt32(17, GetPhaseMask()); // phaseMask + stmt->setUInt32(0, GetOwnerGUID().GetCounter()); // guid + stmt->setFloat (1, GetPositionX()); // posX + stmt->setFloat (2, GetPositionY()); // posY + stmt->setFloat (3, GetPositionZ()); // posZ + stmt->setFloat (4, GetOrientation()); // orientation + stmt->setUInt16(5, GetMapId()); // mapId + stmt->setUInt32(6, GetUInt32Value(CORPSE_FIELD_DISPLAY_ID)); // displayId + stmt->setString(7, _ConcatFields(CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END)); // itemCache + stmt->setUInt32(8, GetUInt32Value(CORPSE_FIELD_BYTES_1)); // bytes1 + stmt->setUInt32(9, GetUInt32Value(CORPSE_FIELD_BYTES_2)); // bytes2 + stmt->setUInt32(10, GetUInt32Value(CORPSE_FIELD_GUILD)); // guildId + stmt->setUInt8 (11, GetUInt32Value(CORPSE_FIELD_FLAGS)); // flags + stmt->setUInt8 (12, GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS)); // dynFlags + stmt->setUInt32(13, uint32(m_time)); // time + stmt->setUInt8 (14, GetType()); // corpseType + stmt->setUInt32(15, GetInstanceId()); // instanceId + stmt->setUInt32(16, GetPhaseMask()); // phaseMask trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); @@ -116,34 +110,29 @@ void Corpse::SaveToDB() void Corpse::DeleteFromDB(SQLTransaction& trans) { - PreparedStatement* stmt = nullptr; - if (GetType() == CORPSE_BONES) - { - // Only specific bones - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE); - stmt->setUInt32(0, GetGUIDLow()); - } - else - { - // all corpses (not bones) - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_CORPSES); - stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID())); - } - trans->Append(stmt); + DeleteFromDB(GetOwnerGUID(), trans); +} + +void Corpse::DeleteFromDB(ObjectGuid const ownerGuid, SQLTransaction& trans) +{ + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE); + stmt->setUInt32(0, ownerGuid.GetCounter()); + CharacterDatabase.ExecuteOrAppend(trans, stmt); } -bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields) +bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields) { - uint32 ownerGuid = fields[17].GetUInt32(); - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, corpseGuid, guid FROM corpse WHERE corpseType <> 0 + ObjectGuid::LowType ownerGuid = fields[16].GetUInt32(); + + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ? float posX = fields[0].GetFloat(); float posY = fields[1].GetFloat(); float posZ = fields[2].GetFloat(); float o = fields[3].GetFloat(); uint32 mapId = fields[4].GetUInt16(); - Object::_Create(guid, 0, HIGHGUID_CORPSE); + Object::_Create(guid, 0, HighGuid::Corpse); SetObjectScale(1.0f); SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].GetUInt32()); @@ -153,7 +142,7 @@ bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields) SetUInt32Value(CORPSE_FIELD_GUILD, fields[9].GetUInt32()); SetUInt32Value(CORPSE_FIELD_FLAGS, fields[10].GetUInt8()); SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[11].GetUInt8()); - SetUInt64Value(CORPSE_FIELD_OWNER, MAKE_NEW_GUID(ownerGuid, 0, HIGHGUID_PLAYER)); + SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid::Create<HighGuid::Player>(ownerGuid)); m_time = time_t(fields[12].GetUInt32()); @@ -168,17 +157,21 @@ bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields) if (!IsPositionValid()) { - LOG_ERROR("server", "Corpse (guid: %u, owner: %u) is not created, given coordinates are not valid (X: %f, Y: %f, Z: %f)", - GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), posX, posY, posZ); + LOG_ERROR("server", "Corpse ( %s, owner: %s) is not created, given coordinates are not valid (X: %f, Y: %f, Z: %f)", + GetGUID().ToString().c_str(), GetOwnerGUID().ToString().c_str(), posX, posY, posZ); return false; } - _gridCoord = acore::ComputeGridCoord(GetPositionX(), GetPositionY()); + _cellCoord = acore::ComputeCellCoord(GetPositionX(), GetPositionY()); return true; } bool Corpse::IsExpired(time_t t) const { + // Deleted character + if (!sWorld->GetGlobalPlayerData(GetOwnerGUID().GetCounter())) + return true; + if (m_type == CORPSE_BONES) return m_time < t - 60 * MINUTE; else diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h index 83e90baf58..4f0b9b97e6 100644 --- a/src/server/game/Entities/Corpse/Corpse.h +++ b/src/server/game/Entities/Corpse/Corpse.h @@ -43,22 +43,23 @@ public: void AddToWorld() override; void RemoveFromWorld() override; - bool Create(uint32 guidlow, Map* map); - bool Create(uint32 guidlow, Player* owner); + bool Create(ObjectGuid::LowType guidlow); + bool Create(ObjectGuid::LowType guidlow, Player* owner); void SaveToDB(); - bool LoadCorpseFromDB(uint32 guid, Field* fields); + bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields); void DeleteFromDB(SQLTransaction& trans); + static void DeleteFromDB(ObjectGuid const ownerGuid, SQLTransaction& trans); - [[nodiscard]] uint64 GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); } + [[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(CORPSE_FIELD_OWNER); } [[nodiscard]] time_t const& GetGhostTime() const { return m_time; } void ResetGhostTime() { m_time = time(nullptr); } [[nodiscard]] CorpseType GetType() const { return m_type; } - [[nodiscard]] GridCoord const& GetGridCoord() const { return _gridCoord; } - void SetGridCoord(GridCoord const& gridCoord) { _gridCoord = gridCoord; } + CellCoord const& GetCellCoord() const { return _cellCoord; } + void SetCellCoord(CellCoord const& cellCoord) { _cellCoord = cellCoord; } Loot loot; // remove insignia ONLY at BG Player* lootRecipient; @@ -68,6 +69,6 @@ public: private: CorpseType m_type; time_t m_time; - GridCoord _gridCoord; // gride for corpse position for fast search + CellCoord _cellCoord; }; #endif diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 6d1fd3cfac..e6b6f4c34d 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -163,10 +163,10 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) return true; } -Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipient(0), m_lootRecipientGroup(0), +Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipientGroup(0), m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f), m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE), - m_DBTableGuid(0), m_equipmentId(0), m_originalEquipmentId(0), m_originalAnimTier(UNIT_BYTE1_FLAG_GROUND), m_AlreadyCallAssistance(false), + m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_originalAnimTier(UNIT_BYTE1_FLAG_GROUND), m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false), m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_waypointID(0), m_path_id(0), m_formation(nullptr), _lastDamagedTime(nullptr), m_cannotReachTarget(false), m_cannotReachTimer(0), _isMissingSwimmingFlagOutOfCombat(false) @@ -217,10 +217,16 @@ void Creature::AddToWorld() if (GetZoneScript()) GetZoneScript()->OnCreatureCreate(this); - sObjectAccessor->AddObject(this); + GetMap()->GetObjectsStore().Insert<Creature>(GetGUID(), this); + if (m_spawnId) + GetMap()->GetCreatureBySpawnIdStore().insert(std::make_pair(m_spawnId, this)); + Unit::AddToWorld(); + SearchFormation(); + AIM_Initialize(); + if (IsVehicle()) GetVehicleKit()->Install(); #ifdef ELUNA @@ -238,12 +244,19 @@ void Creature::RemoveFromWorld() #endif if (GetZoneScript()) GetZoneScript()->OnCreatureRemove(this); + if (m_formation) sFormationMgr->RemoveCreatureFromGroup(m_formation, this); + if (Transport* transport = GetTransport()) transport->RemovePassenger(this, true); + Unit::RemoveFromWorld(); - sObjectAccessor->RemoveObject(this); + + if (m_spawnId) + acore::Containers::MultimapErasePair(GetMap()->GetCreatureBySpawnIdStore(), m_spawnId, this); + + GetMap()->GetObjectsStore().Remove<Creature>(GetGUID()); } } @@ -262,11 +275,11 @@ void Creature::SearchFormation() if (IsSummon()) return; - uint32 lowguid = GetDBTableGUIDLow(); - if (!lowguid) + ObjectGuid::LowType spawnId = GetSpawnId(); + if (!spawnId) return; - CreatureGroupInfoType::iterator frmdata = sFormationMgr->CreatureGroupMap.find(lowguid); + CreatureGroupInfoType::iterator frmdata = sFormationMgr->CreatureGroupMap.find(spawnId); if (frmdata != sFormationMgr->CreatureGroupMap.end()) sFormationMgr->AddCreatureToGroup(frmdata->second->leaderGUID, this); } @@ -520,11 +533,11 @@ void Creature::Update(uint32 diff) { case JUST_RESPAWNED: // Must not be called, see Creature::setDeathState JUST_RESPAWNED -> ALIVE promoting. - LOG_ERROR("server", "Creature (GUID: %u Entry: %u) in wrong state: JUST_RESPAWNED (4)", GetGUIDLow(), GetEntry()); + LOG_ERROR("server", "Creature (%s) in wrong state: JUST_RESPAWNED (4)", GetGUID().ToString().c_str()); break; case JUST_DIED: // Must not be called, see Creature::setDeathState JUST_DIED -> CORPSE promoting. - LOG_ERROR("server", "Creature (GUID: %u Entry: %u) in wrong state: JUST_DEAD (1)", GetGUIDLow(), GetEntry()); + LOG_ERROR("server", "Creature (%s) in wrong state: JUST_DEAD (1)", GetGUID().ToString().c_str()); break; case DEAD: { @@ -535,13 +548,13 @@ void Creature::Update(uint32 diff) if (!allowed) // Will be rechecked on next Update call break; - uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_UNIT); + ObjectGuid dbtableHighGuid = ObjectGuid::Create<HighGuid::Unit>(GetEntry(), m_spawnId); time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid); if (!linkedRespawntime) // Can respawn Respawn(); else // the master is dead { - uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid); + ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid); if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day) SetRespawnTime(DAY); else @@ -695,7 +708,7 @@ void Creature::Update(uint32 diff) if (IsInWorld() && !IsDuringRemoveFromWorld()) { // pussywizard: - if (IS_PLAYER_GUID(GetOwnerGUID())) + if (GetOwnerGUID().IsPlayer()) { if (m_transportCheckTimer <= diff) { @@ -739,7 +752,7 @@ void Creature::Regenerate(Powers power) uint32 maxValue = GetMaxPower(power); // Xinef: implement power regeneration flag - if (!HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER) && !IS_PLAYER_GUID(GetOwnerGUID())) + if (!HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER) && !GetOwnerGUID().IsPlayer()) return; if (curValue >= maxValue) @@ -892,7 +905,7 @@ bool Creature::AIM_Initialize(CreatureAI* ai) i_AI->InitializeAI(); // Xinef: Initialize vehicle if it is not summoned! - if (GetVehicleKit() && GetDBTableGUIDLow()) + if (GetVehicleKit() && m_spawnId) GetVehicleKit()->Reset(); return true; } @@ -912,7 +925,7 @@ void Creature::Motion_Initialize() GetMotionMaster()->Initialize(); } -bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data) +bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data) { ASSERT(map); SetMap(map); @@ -1088,7 +1101,7 @@ Player* Creature::GetLootRecipient() const { if (!m_lootRecipient) return nullptr; - return ObjectAccessor::FindPlayerInOrOutOfWorld(m_lootRecipient); + return ObjectAccessor::FindConnectedPlayer(m_lootRecipient); } Group* Creature::GetLootRecipientGroup() const @@ -1106,7 +1119,7 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup) if (!unit) { - m_lootRecipient = 0; + m_lootRecipient.Clear(); m_lootRecipientGroup = 0; RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE | UNIT_DYNFLAG_TAPPED); return; @@ -1124,7 +1137,7 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup) if (withGroup) { if (Group* group = player->GetGroup()) - m_lootRecipientGroup = group->GetLowGUID(); + m_lootRecipientGroup = group->GetGUID().GetCounter(); } else m_lootRecipientGroup = 0; @@ -1149,7 +1162,7 @@ void Creature::SaveToDB() { // this should only be used when the creature has already been loaded // preferably after adding to map, because mapid may not be valid otherwise - CreatureData const* data = sObjectMgr->GetCreatureData(m_DBTableGuid); + CreatureData const* data = sObjectMgr->GetCreatureData(m_spawnId); if (!data) { LOG_ERROR("server", "Creature::SaveToDB failed, cannot get creature data!"); @@ -1163,9 +1176,10 @@ void Creature::SaveToDB() void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) { // update in loaded data - if (!m_DBTableGuid) - m_DBTableGuid = GetGUIDLow(); - CreatureData& data = sObjectMgr->NewOrExistCreatureData(m_DBTableGuid); + if (!m_spawnId) + m_spawnId = sObjectMgr->GenerateCreatureSpawnId(); + + CreatureData& data = sObjectMgr->NewOrExistCreatureData(m_spawnId); uint32 displayId = GetNativeDisplayId(); uint32 npcflag = GetUInt32Value(UNIT_NPC_FLAGS); @@ -1190,7 +1204,6 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) dynamicflags = 0; } - // data->guid = guid must not be updated at save data.id = GetEntry(); data.mapid = mapid; data.phaseMask = phaseMask; @@ -1229,13 +1242,13 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) SQLTransaction trans = WorldDatabase.BeginTransaction(); PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE); - stmt->setUInt32(0, m_DBTableGuid); + stmt->setUInt32(0, m_spawnId); trans->Append(stmt); uint8 index = 0; stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE); - stmt->setUInt32(index++, m_DBTableGuid); + stmt->setUInt32(index++, m_spawnId); stmt->setUInt32(index++, GetEntry()); stmt->setUInt16(index++, uint16(mapid)); stmt->setUInt8(index++, spawnMask); @@ -1377,7 +1390,7 @@ float Creature::GetSpellDamageMod(int32 Rank) } } -bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const CreatureData* data) +bool Creature::CreateFromProto(ObjectGuid::LowType guidlow, uint32 Entry, uint32 vehId, const CreatureData* data) { SetZoneScript(); if (GetZoneScript() && data) @@ -1396,7 +1409,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const SetOriginalEntry(Entry); - Object::_Create(guidlow, Entry, (vehId || normalInfo->VehicleId) ? HIGHGUID_VEHICLE : HIGHGUID_UNIT); + Object::_Create(guidlow, Entry, (vehId || normalInfo->VehicleId) ? HighGuid::Vehicle : HighGuid::Unit); // Xinef: select proper vehicle id if (!vehId) @@ -1434,13 +1447,42 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const return true; } -bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gridLoad) +bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap, bool gridLoad, bool allowDuplicate /*= false*/) { - CreatureData const* data = sObjectMgr->GetCreatureData(guid); + if (!allowDuplicate) + { + // If an alive instance of this spawnId is already found, skip creation + // If only dead instance(s) exist, despawn them and spawn a new (maybe also dead) version + const auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(spawnId); + std::vector <Creature*> despawnList; + + if (creatureBounds.first != creatureBounds.second) + { + for (auto itr = creatureBounds.first; itr != creatureBounds.second; ++itr) + { + if (itr->second->IsAlive()) + { + LOG_DEBUG("maps", "Would have spawned %u but %s already exists", spawnId, creatureBounds.first->second->GetGUID().ToString().c_str()); + return false; + } + else + { + despawnList.push_back(itr->second); + LOG_DEBUG("maps", "Despawned dead instance of spawn %u (%s)", spawnId, itr->second->GetGUID().ToString().c_str()); + } + } + for (Creature* despawnCreature : despawnList) + { + despawnCreature->AddObjectToRemoveList(); + } + } + } + + CreatureData const* data = sObjectMgr->GetCreatureData(spawnId); if (!data) { - LOG_ERROR("sql.sql", "Creature (GUID: %u) not found in table `creature`, can't load. ", guid); + LOG_ERROR("sql.sql", "Creature (SpawnId: %u) not found in table `creature`, can't load. ", spawnId); return false; } @@ -1456,17 +1498,9 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gri // xinef: this has to be assigned before Create function, properly loads equipment id from DB m_creatureData = data; - m_DBTableGuid = guid; - - if (map->GetInstanceId() == 0) - { - if (map->GetCreature(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT))) - return false; - } - else - guid = sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT); + m_spawnId = spawnId; - if (!Create(guid, map, data->phaseMask, data->id, 0, data->posX, data->posY, data->posZ, data->orientation, data)) + if (!Create(map->GenerateLowGuid<HighGuid::Unit>(), map, data->phaseMask, data->id, 0, data->posX, data->posY, data->posZ, data->orientation, data)) return false; //We should set first home position, because then AI calls home movement @@ -1477,7 +1511,7 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gri m_respawnDelay = data->spawntimesecs; m_deathState = ALIVE; - m_respawnTime = GetMap()->GetCreatureRespawnTime(m_DBTableGuid); + m_respawnTime = GetMap()->GetCreatureRespawnTime(m_spawnId); if (m_respawnTime) // respawn on Update { m_deathState = DEAD; @@ -1572,31 +1606,31 @@ bool Creature::hasInvolvedQuest(uint32 quest_id) const void Creature::DeleteFromDB() { - if (!m_DBTableGuid) + if (!m_spawnId) { - LOG_ERROR("server", "Trying to delete not saved creature! LowGUID: %u, Entry: %u", GetGUIDLow(), GetEntry()); + LOG_ERROR("server", "Trying to delete not saved creature: %s", GetGUID().ToString().c_str()); return; } - GetMap()->RemoveCreatureRespawnTime(m_DBTableGuid); - sObjectMgr->DeleteCreatureData(m_DBTableGuid); + GetMap()->RemoveCreatureRespawnTime(m_spawnId); + sObjectMgr->DeleteCreatureData(m_spawnId); SQLTransaction trans = WorldDatabase.BeginTransaction(); PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE); - stmt->setUInt32(0, m_DBTableGuid); + stmt->setUInt32(0, m_spawnId); trans->Append(stmt); stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE_ADDON); - stmt->setUInt32(0, m_DBTableGuid); + stmt->setUInt32(0, m_spawnId); trans->Append(stmt); stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_CREATURE); - stmt->setUInt32(0, m_DBTableGuid); + stmt->setUInt32(0, m_spawnId); trans->Append(stmt); stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP); - stmt->setUInt32(0, m_DBTableGuid); + stmt->setUInt32(0, m_spawnId); trans->Append(stmt); WorldDatabase.CommitTransaction(trans); @@ -1683,7 +1717,7 @@ void Creature::setDeathState(DeathState s, bool despawn) if (GetMap()->IsDungeon() || isWorldBoss() || GetCreatureTemplate()->rank >= CREATURE_ELITE_ELITE) SaveRespawnTime(); - SetTarget(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState) + SetTarget(); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState) SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); Dismount(); // if creature is mounted on a virtual mount, remove it at death @@ -1761,11 +1795,11 @@ void Creature::Respawn(bool force) if (getDeathState() == DEAD) { - if (m_DBTableGuid) - GetMap()->RemoveCreatureRespawnTime(m_DBTableGuid); + if (m_spawnId) + GetMap()->RemoveCreatureRespawnTime(m_spawnId); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Respawning creature %s (GuidLow: %u, Full GUID: " UI64FMTD " Entry: %u)", GetName().c_str(), GetGUIDLow(), GetGUID(), GetEntry()); + LOG_DEBUG("server", "Respawning creature %s (SpawnId: %u, %s)", GetName().c_str(), GetSpawnId(), GetGUID().ToString().c_str()); #endif m_respawnTime = 0; ResetPickPocketLootTime(); @@ -1796,9 +1830,9 @@ void Creature::Respawn(bool force) TriggerJustRespawned = true;//delay event to next tick so all creatures are created on the map before processing } - uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0; + uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<Creature>(m_spawnId) : 0; if (poolid) - sPoolMgr->UpdatePool<Creature>(poolid, GetDBTableGUIDLow()); + sPoolMgr->UpdatePool<Creature>(poolid, m_spawnId); //Re-initialize reactstate that could be altered by movementgenerators InitializeReactState(); @@ -1848,7 +1882,7 @@ void Creature::InitializeReactState() bool Creature::HasMechanicTemplateImmunity(uint32 mask) const { - return !IS_PLAYER_GUID(GetOwnerGUID()) && (GetCreatureTemplate()->MechanicImmuneMask & mask); + return !GetOwnerGUID().IsPlayer() && (GetCreatureTemplate()->MechanicImmuneMask & mask); } void Creature::LoadSpellTemplateImmunity() @@ -1864,7 +1898,7 @@ void Creature::LoadSpellTemplateImmunity() } // don't inherit immunities for hunter pets - if (IS_PLAYER_GUID(GetOwnerGUID()) && IsHunterPet()) + if (GetOwnerGUID().IsPlayer() && IsHunterPet()) { return; } @@ -2071,7 +2105,7 @@ void Creature::SendAIReaction(AiReaction reactionType) { WorldPacket data(SMSG_AI_REACTION, 12); - data << uint64(GetGUID()); + data << GetGUID(); data << uint32(reactionType); ((WorldObject*)this)->SendMessageToSet(&data, true); @@ -2262,10 +2296,10 @@ void Creature::UpdateMoveInLineOfSightState() void Creature::SaveRespawnTime() { - if (IsSummon() || !GetDBTableGUIDLow() || (m_creatureData && !m_creatureData->dbData)) + if (IsSummon() || !m_spawnId || (m_creatureData && !m_creatureData->dbData)) return; - GetMap()->SaveCreatureRespawnTime(GetDBTableGUIDLow(), m_respawnTime); + GetMap()->SaveCreatureRespawnTime(m_spawnId, m_respawnTime); } bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const @@ -2296,7 +2330,7 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const return false; } - if (!IS_PLAYER_GUID(GetCharmerOrOwnerGUID())) + if (!GetCharmerOrOwnerGUID().IsPlayer()) { if (GetMap()->IsDungeon()) return true; @@ -2327,9 +2361,9 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const CreatureAddon const* Creature::GetCreatureAddon() const { - if (m_DBTableGuid) + if (m_spawnId) { - if (CreatureAddon const* addon = sObjectMgr->GetCreatureAddon(m_DBTableGuid)) + if (CreatureAddon const* addon = sObjectMgr->GetCreatureAddon(m_spawnId)) return addon; } @@ -2407,7 +2441,7 @@ bool Creature::LoadCreaturesAddon(bool reload) SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(*itr); if (!AdditionalSpellInfo) { - LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has wrong spell %u defined in `auras` field.", GetGUIDLow(), GetEntry(), *itr); + LOG_ERROR("sql.sql", "Creature (%s) has wrong spell %u defined in `auras` field.", GetGUID().ToString().c_str(), *itr); continue; } @@ -2415,14 +2449,14 @@ bool Creature::LoadCreaturesAddon(bool reload) if (HasAura(*itr)) { if (!reload) - LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has duplicate aura (spell %u) in `auras` field.", GetGUIDLow(), GetEntry(), *itr); + LOG_ERROR("sql.sql", "Creature (%s) has duplicate aura (spell %u) in `auras` field.", GetGUID().ToString().c_str(), *itr); continue; } AddAura(*itr, this); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.unit", "Spell: %u added to creature (GUID: %u Entry: %u)", *itr, GetGUIDLow(), GetEntry()); + LOG_DEBUG("entities.unit", "Spell: %u added to creature (%s)", *itr, GetGUID().ToString().c_str()); #endif } } @@ -2576,9 +2610,9 @@ time_t Creature::GetRespawnTimeEx() const void Creature::GetRespawnPosition(float& x, float& y, float& z, float* ori, float* dist) const { - if (m_DBTableGuid) + if (m_spawnId) { - if (CreatureData const* data = sObjectMgr->GetCreatureData(GetDBTableGUIDLow())) + if (CreatureData const* data = sObjectMgr->GetCreatureData(m_spawnId)) { x = data->posX; y = data->posY; @@ -2775,7 +2809,7 @@ void Creature::SetPosition(float x, float y, float z, float o) bool Creature::IsDungeonBoss() const { - if (IS_PLAYER_GUID(GetOwnerGUID())) + if (GetOwnerGUID().IsPlayer()) return false; CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry()); @@ -2784,7 +2818,7 @@ bool Creature::IsDungeonBoss() const bool Creature::IsImmuneToKnockback() const { - if (IS_PLAYER_GUID(GetOwnerGUID())) + if (GetOwnerGUID().IsPlayer()) return false; CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry()); @@ -2797,7 +2831,7 @@ bool Creature::SetWalk(bool enable) return false; WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_WALK_MODE : SMSG_SPLINE_MOVE_SET_RUN_MODE, 9); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, false); return true; } @@ -2815,7 +2849,7 @@ bool Creature::SetDisableGravity(bool disable, bool packetOnly/*=false*/) return true; WorldPacket data(disable ? SMSG_SPLINE_MOVE_GRAVITY_DISABLE : SMSG_SPLINE_MOVE_GRAVITY_ENABLE, 9); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, false); return true; } @@ -2849,7 +2883,7 @@ bool Creature::SetSwim(bool enable) return true; WorldPacket data(enable ? SMSG_SPLINE_MOVE_START_SWIM : SMSG_SPLINE_MOVE_STOP_SWIM); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, true); return true; } @@ -2866,7 +2900,7 @@ bool Creature::CanSwim() const if (Unit::CanSwim()) return true; - if (IsPet() || IS_PLAYER_GUID(GetOwnerGUID())) + if (IsPet() || GetOwnerGUID().IsPlayer()) return true; return false; @@ -2900,7 +2934,7 @@ bool Creature::SetCanFly(bool enable, bool /*packetOnly*/ /* = false */) return true; WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_FLYING : SMSG_SPLINE_MOVE_UNSET_FLYING, 9); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, false); return true; } @@ -2922,7 +2956,7 @@ bool Creature::SetWaterWalking(bool enable, bool packetOnly /* = false */) return true; WorldPacket data(enable ? SMSG_SPLINE_MOVE_WATER_WALK : SMSG_SPLINE_MOVE_LAND_WALK, 9); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, true); return true; } @@ -2936,7 +2970,7 @@ bool Creature::SetFeatherFall(bool enable, bool packetOnly /* = false */) return true; WorldPacket data(enable ? SMSG_SPLINE_MOVE_FEATHER_FALL : SMSG_SPLINE_MOVE_NORMAL_FALL, 9); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, true); return true; } @@ -2953,7 +2987,7 @@ bool Creature::SetHover(bool enable, bool packetOnly /*= false*/) //! Not always a packet is sent WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_HOVER : SMSG_SPLINE_MOVE_UNSET_HOVER, 9); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, false); return true; } @@ -3038,10 +3072,10 @@ void Creature::SetDisplayId(uint32 modelId) SetFloatValue(UNIT_FIELD_COMBATREACH, combatReach * GetObjectScale()); } -void Creature::SetTarget(uint64 guid) +void Creature::SetTarget(ObjectGuid guid) { if (!_focusSpell) - SetUInt64Value(UNIT_FIELD_TARGET, guid); + SetGuidValue(UNIT_FIELD_TARGET, guid); } void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target) @@ -3051,7 +3085,7 @@ void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target) return; _focusSpell = focusSpell; - SetUInt64Value(UNIT_FIELD_TARGET, this == target ? 0 : target->GetGUID()); + SetGuidValue(UNIT_FIELD_TARGET, this == target ? ObjectGuid::Empty : target->GetGUID()); if (focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST)) AddUnitState(UNIT_STATE_ROTATING); @@ -3080,9 +3114,9 @@ void Creature::ReleaseFocus(Spell const* focusSpell) _focusSpell = nullptr; if (Unit* victim = GetVictim()) - SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); + SetGuidValue(UNIT_FIELD_TARGET, victim->GetGUID()); else - SetUInt64Value(UNIT_FIELD_TARGET, 0); + SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty); if (focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST)) ClearUnitState(UNIT_STATE_ROTATING); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 4a8510702f..de79c537db 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -444,12 +444,12 @@ public: void DisappearAndDie(); - bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data = nullptr); + bool Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data = nullptr); bool LoadCreaturesAddon(bool reload = false); void SelectLevel(bool changelevel = true); void LoadEquipment(int8 id = 1, bool force = false); - [[nodiscard]] uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } + [[nodiscard]] ObjectGuid::LowType GetSpawnId() const { return m_spawnId; } void Update(uint32 time) override; // overwrited Unit::Update void GetRespawnPosition(float& x, float& y, float& z, float* ori = nullptr, float* dist = nullptr) const; @@ -527,7 +527,7 @@ public: { ::Spell const* Spell = nullptr; uint32 Delay = 0; // ms until the creature's target should snap back (0 = no snapback scheduled) - uint64 Target; // the creature's "real" target while casting + ObjectGuid Target; // the creature's "real" target while casting float Orientation = 0.0f; // the creature's "real" orientation while casting } _spellFocusInfo; @@ -584,15 +584,15 @@ public: void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState - bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false, true); } - bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true, bool gridLoad = false); + bool LoadFromDB(ObjectGuid::LowType guid, Map* map, bool allowDuplicate = false) { return LoadCreatureFromDB(guid, map, false, true, allowDuplicate); } + bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map* map, bool addToMap = true, bool gridLoad = false, bool allowDuplicate = false); void SaveToDB(); // overriden in Pet virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); virtual void DeleteFromDB(); // overriden in Pet Loot loot; - [[nodiscard]] uint64 GetLootRecipientGUID() const { return m_lootRecipient; } + [[nodiscard]] ObjectGuid GetLootRecipientGUID() const { return m_lootRecipient; } [[nodiscard]] Player* GetLootRecipient() const; [[nodiscard]] Group* GetLootRecipientGroup() const; [[nodiscard]] bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; } @@ -733,7 +733,7 @@ public: bool m_isTempWorldObject; //true when possessed // Handling caster facing during spellcast - void SetTarget(uint64 guid) override; + void SetTarget(ObjectGuid guid = ObjectGuid::Empty) override; void FocusTarget(Spell const* focusSpell, WorldObject const* target); void ReleaseFocus(Spell const* focusSpell); bool IsMovementPreventedByCasting() const; @@ -757,7 +757,7 @@ public: void RefreshSwimmingFlag(bool recheck = false); protected: - bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr); + bool CreateFromProto(ObjectGuid::LowType guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr); bool InitEntry(uint32 entry, const CreatureData* data = nullptr); // vendor items @@ -765,7 +765,7 @@ protected: static float _GetHealthMod(int32 Rank); - uint64 m_lootRecipient; + ObjectGuid m_lootRecipient; uint32 m_lootRecipientGroup; /// Timers @@ -782,7 +782,7 @@ protected: void RegenerateHealth(); void Regenerate(Powers power); MovementGeneratorType m_defaultMovementType; - uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid + ObjectGuid::LowType m_spawnId; ///< For new or temporary creatures is 0 for saved it is lowguid uint8 m_equipmentId; int8 m_originalEquipmentId; // can be -1 @@ -838,15 +838,16 @@ private: class AssistDelayEvent : public BasicEvent { public: - AssistDelayEvent(uint64 victim, Creature* owner) : BasicEvent(), m_victim(victim), m_owner(owner) { } + AssistDelayEvent(ObjectGuid victim, Creature* owner) : BasicEvent(), m_victim(victim), m_owner(owner) { } bool Execute(uint64 e_time, uint32 p_time) override; - void AddAssistant(uint64 guid) { m_assistants.push_back(guid); } + void AddAssistant(ObjectGuid guid) { m_assistants.push_back(guid); } + private: AssistDelayEvent(); - uint64 m_victim; - std::list<uint64> m_assistants; + ObjectGuid m_victim; + GuidList m_assistants; Creature* m_owner; }; diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index dafd1a8a60..e2ff76d1b8 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -34,7 +34,7 @@ void FormationMgr::AddCreatureToGroup(uint32 groupId, Creature* member) if (itr != map->CreatureGroupHolder.end()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.unit", "Group found: %u, inserting creature GUID: %u, Group InstanceID %u", groupId, member->GetGUIDLow(), member->GetInstanceId()); + LOG_DEBUG("entities.unit", "Group found: %u, inserting creature %s, Group InstanceID %u", groupId, member->GetGUID().ToString().c_str(), member->GetInstanceId()); #endif itr->second->AddMember(member); } @@ -53,7 +53,7 @@ void FormationMgr::AddCreatureToGroup(uint32 groupId, Creature* member) void FormationMgr::RemoveCreatureFromGroup(CreatureGroup* group, Creature* member) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.unit", "Deleting member pointer to GUID: %u from group %u", group->GetId(), member->GetDBTableGUIDLow()); + LOG_DEBUG("entities.unit", "Deleting member pointer to spawnId: %u from group %u", member->GetSpawnId(), group->GetId()); #endif group->RemoveMember(member); @@ -100,7 +100,7 @@ void FormationMgr::LoadCreatureFormations() //Load group member data group_member = new FormationInfo(); group_member->leaderGUID = fields[0].GetUInt32(); - uint32 memberGUID = fields[1].GetUInt32(); + ObjectGuid::LowType memberGUID = fields[1].GetUInt32(); group_member->groupAI = fields[4].GetUInt32(); group_member->point_1 = fields[5].GetUInt16(); group_member->point_2 = fields[6].GetUInt16(); @@ -144,19 +144,19 @@ void FormationMgr::LoadCreatureFormations() void CreatureGroup::AddMember(Creature* member) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.unit", "CreatureGroup::AddMember: Adding unit GUID: %u.", member->GetGUIDLow()); + LOG_DEBUG("entities.unit", "CreatureGroup::AddMember: Adding unit %s.", member->GetGUID().ToString().c_str()); #endif //Check if it is a leader - if (member->GetDBTableGUIDLow() == m_groupID) + if (member->GetSpawnId() == m_groupID) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.unit", "Unit GUID: %u is formation leader. Adding group.", member->GetGUIDLow()); + LOG_DEBUG("entities.unit", "Unit %s is formation leader. Adding group.", member->GetGUID().ToString().c_str()); #endif m_leader = member; } - m_members[member] = sFormationMgr->CreatureGroupMap.find(member->GetDBTableGUIDLow())->second; + m_members[member] = sFormationMgr->CreatureGroupMap.find(member->GetSpawnId())->second; member->SetFormation(this); } @@ -171,7 +171,7 @@ void CreatureGroup::RemoveMember(Creature* member) void CreatureGroup::MemberAttackStart(Creature* member, Unit* target) { - uint8 groupAI = sFormationMgr->CreatureGroupMap[member->GetDBTableGUIDLow()]->groupAI; + uint8 groupAI = sFormationMgr->CreatureGroupMap[member->GetSpawnId()]->groupAI; if (!groupAI) return; @@ -214,7 +214,7 @@ void CreatureGroup::FormationReset(bool dismiss) else itr->first->GetMotionMaster()->MoveIdle(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.unit", "Set %s movement for member GUID: %u", dismiss ? "default" : "idle", itr->first->GetGUIDLow()); + LOG_DEBUG("entities.unit", "Set %s movement for member %s", dismiss ? "default" : "idle", itr->first->GetGUID().ToString().c_str()); #endif } } @@ -228,7 +228,7 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z, bool run) if (!m_leader) return; - uint8 groupAI = sFormationMgr->CreatureGroupMap[m_leader->GetDBTableGUIDLow()]->groupAI; + uint8 groupAI = sFormationMgr->CreatureGroupMap[m_leader->GetSpawnId()]->groupAI; if (groupAI == 5) return; diff --git a/src/server/game/Entities/Creature/CreatureGroups.h b/src/server/game/Entities/Creature/CreatureGroups.h index 3f821f10bb..c3b17bb7d4 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.h +++ b/src/server/game/Entities/Creature/CreatureGroups.h @@ -17,7 +17,7 @@ class CreatureGroup; struct FormationInfo { - uint32 leaderGUID; + ObjectGuid::LowType leaderGUID; float follow_dist; float follow_angle; uint8 groupAI; @@ -25,7 +25,7 @@ struct FormationInfo uint16 point_2; }; -typedef std::unordered_map<uint32/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType; +typedef std::unordered_map<ObjectGuid::LowType/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType; class FormationMgr { diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 6c2a656624..2c16eb82ed 100644 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -177,10 +177,10 @@ void PlayerMenu::ClearMenus() _questMenu.ClearMenu(); } -void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const +void PlayerMenu::SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID) const { WorldPacket data(SMSG_GOSSIP_MESSAGE, 24 + _gossipMenu.GetMenuItemCount() * 100 + _questMenu.GetMenuItemCount() * 75); // guess size - data << uint64(objectGUID); + data << objectGUID; data << uint32(_gossipMenu.GetMenuId()); // new 2.4.0 data << uint32(titleTextId); data << uint32(_gossipMenu.GetMenuItemCount()); // max count 0x10 @@ -297,10 +297,10 @@ void QuestMenu::ClearMenu() _questMenuItems.clear(); } -void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID) +void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, ObjectGuid npcGUID) { WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100 + _questMenu.GetMenuItemCount() * 75); // guess size - data << uint64(npcGUID); + data << npcGUID; data << Title; data << uint32(eEmote._Delay); // player emote data << uint32(eEmote._Emote); // NPC emote @@ -335,23 +335,23 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string data.put<uint8>(count_pos, count); _session->SendPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID)); + LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC %s", npcGUID.ToString().c_str()); #endif } -void PlayerMenu::SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const +void PlayerMenu::SendQuestGiverStatus(uint8 questStatus, ObjectGuid npcGUID) const { WorldPacket data(SMSG_QUESTGIVER_STATUS, 9); - data << uint64(npcGUID); + data << npcGUID; data << uint8(questStatus); _session->SendPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u", GUID_LOPART(npcGUID), questStatus); + LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC %s, status=%u", npcGUID.ToString().c_str(), questStatus); #endif } -void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const +void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGUID, bool activateAccept) const { std::string questTitle = quest->GetTitle(); std::string questDetails = quest->GetDetails(); @@ -368,8 +368,8 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, } WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 500); // guess size - data << uint64(npcGUID); - data << uint64(_session->GetPlayer()->GetDivider()); + data << npcGUID; + data << _session->GetPlayer()->GetDivider(); data << uint32(quest->GetQuestId()); data << questTitle; data << questDetails; @@ -451,7 +451,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, _session->SendPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId()); + LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS %s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId()); #endif } @@ -588,7 +588,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const #endif } -void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const +void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool enableNext) const { std::string questTitle = quest->GetTitle(); std::string RewardText = quest->GetOfferRewardText(); @@ -601,7 +601,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, locale, RewardText); WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 400); // guess size - data << uint64(npcGUID); + data << npcGUID; data << uint32(quest->GetQuestId()); data << questTitle; data << RewardText; @@ -674,11 +674,11 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b _session->SendPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId()); + LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD %s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId()); #endif } -void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const +void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGUID, bool canComplete, bool closeOnCancel) const { // We can always call to RequestItems, but this packet only goes out if there are actually // items. Otherwise, we'll skip straight to the OfferReward @@ -717,7 +717,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, } WorldPacket data(SMSG_QUESTGIVER_REQUEST_ITEMS, 300); // guess size - data << uint64(npcGUID); + data << npcGUID; data << uint32(quest->GetQuestId()); data << questTitle; data << requestItemsText; @@ -767,6 +767,6 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, _session->SendPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId()); + LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS %s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId()); #endif } diff --git a/src/server/game/Entities/Creature/GossipDef.h b/src/server/game/Entities/Creature/GossipDef.h index 0a928afde1..39783d5326 100644 --- a/src/server/game/Entities/Creature/GossipDef.h +++ b/src/server/game/Entities/Creature/GossipDef.h @@ -12,6 +12,7 @@ #include "QuestDef.h" class WorldSession; +class ObjectGuid; #define GOSSIP_MAX_MENU_ITEMS 32 #define DEFAULT_GOSSIP_MESSAGE 0xffffff @@ -253,22 +254,22 @@ public: [[nodiscard]] uint32 GetGossipOptionAction(uint32 selection) const { return _gossipMenu.GetMenuItemAction(selection); } [[nodiscard]] bool IsGossipOptionCoded(uint32 selection) const { return _gossipMenu.IsMenuItemCoded(selection); } - void SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const; + void SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID) const; void SendCloseGossip() const; void SendPointOfInterest(uint32 poiId) const; /*********************************************************/ /*** QUEST SYSTEM ***/ /*********************************************************/ - void SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const; + void SendQuestGiverStatus(uint8 questStatus, ObjectGuid npcGUID) const; - void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID); + void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, ObjectGuid npcGUID); void SendQuestQueryResponse(Quest const* quest) const; - void SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const; + void SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGUID, bool activateAccept) const; - void SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const; - void SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const; + void SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool enableNext) const; + void SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGUID, bool canComplete, bool closeOnCancel) const; private: GossipMenu _gossipMenu; diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index 4b12ac61de..e730df511c 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -13,7 +13,7 @@ #include "ScriptMgr.h" #include "TemporarySummon.h" -TempSummon::TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) : +TempSummon::TempSummon(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject) : Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN), m_timer(0), m_lifetime(0) { @@ -260,7 +260,7 @@ void TempSummon::RemoveFromWorld() if (uint32 slot = m_Properties->Slot) if (Unit* owner = GetSummoner()) if (owner->m_SummonSlot[slot] == GetGUID()) - owner->m_SummonSlot[slot] = 0; + owner->m_SummonSlot[slot].Clear(); //if (GetOwnerGUID()) // LOG_ERROR("server", "Unit %u has owner guid when removed from world", GetEntry()); @@ -268,7 +268,7 @@ void TempSummon::RemoveFromWorld() Creature::RemoveFromWorld(); } -Minion::Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) : TempSummon(properties, owner, isWorldObject) +Minion::Minion(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject) : TempSummon(properties, owner, isWorldObject) , m_owner(owner) { ASSERT(m_owner); @@ -325,7 +325,7 @@ void Minion::setDeathState(DeathState s, bool despawn) } } -Guardian::Guardian(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) : Minion(properties, owner, isWorldObject) +Guardian::Guardian(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject) : Minion(properties, owner, isWorldObject) { m_unitTypeMask |= UNIT_MASK_GUARDIAN; if (properties && properties->Type == SUMMON_TYPE_PET) @@ -359,9 +359,9 @@ void Guardian::InitSummon() m_owner->ToPlayer()->CharmSpellInitialize(); } -Puppet::Puppet(SummonPropertiesEntry const* properties, uint64 owner) : Minion(properties, owner, false), m_owner(owner) //maybe true? +Puppet::Puppet(SummonPropertiesEntry const* properties, ObjectGuid owner) : Minion(properties, owner, false), m_owner(owner) //maybe true? { - ASSERT(IS_PLAYER_GUID(owner)); + ASSERT(owner.IsPlayer()); m_unitTypeMask |= UNIT_MASK_PUPPET; } @@ -378,7 +378,7 @@ void Puppet::InitSummon() if (!SetCharmedBy(GetOwner(), CHARM_TYPE_POSSESS)) { if (Player* p = GetOwner()) - LOG_INFO("misc", "Puppet::InitSummon (A1) - %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u", p->GetTypeId(), p->GetEntry(), p->GetUnitTypeMask(), p->GetGUIDLow(), p->GetMapId(), p->GetInstanceId(), p->FindMap()->GetId(), p->IsInWorld() ? 1 : 0, p->IsDuringRemoveFromWorld() ? 1 : 0, p->IsBeingTeleported() ? 1 : 0, p->isBeingLoaded() ? 1 : 0); + LOG_INFO("misc", "Puppet::InitSummon (A1) - %s, %u, %u, %u, %u, %u, %u, %u", p->GetGUID().ToString().c_str(), p->GetMapId(), p->GetInstanceId(), p->FindMap()->GetId(), p->IsInWorld() ? 1 : 0, p->IsDuringRemoveFromWorld() ? 1 : 0, p->IsBeingTeleported() ? 1 : 0, p->isBeingLoaded() ? 1 : 0); else { LOG_INFO("misc", "Puppet::InitSummon (B1)"); diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h index c9229013b3..cde06a0770 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.h +++ b/src/server/game/Entities/Creature/TemporarySummon.h @@ -28,7 +28,7 @@ struct TempSummonData class TempSummon : public Creature { public: - explicit TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject); + explicit TempSummon(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject); ~TempSummon() override = default; void Update(uint32 time) override; virtual void InitStats(uint32 lifetime); @@ -38,7 +38,7 @@ public: void SetTempSummonType(TempSummonType type); void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) override {} [[nodiscard]] Unit* GetSummoner() const; - uint64 GetSummonerGUID() { return m_summonerGUID; } + ObjectGuid GetSummonerGUID() { return m_summonerGUID; } TempSummonType const& GetSummonType() { return m_type; } uint32 GetTimer() { return m_timer; } void SetTimer(uint32 t) { m_timer = t; } @@ -48,13 +48,13 @@ private: TempSummonType m_type; uint32 m_timer; uint32 m_lifetime; - uint64 m_summonerGUID; + ObjectGuid m_summonerGUID; }; class Minion : public TempSummon { public: - Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject); + Minion(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject); void InitStats(uint32 duration) override; void RemoveFromWorld() override; [[nodiscard]] Unit* GetOwner() const; @@ -64,14 +64,14 @@ public: [[nodiscard]] bool IsGuardianPet() const; void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState protected: - const uint64 m_owner; + const ObjectGuid m_owner; float m_followAngle; }; class Guardian : public Minion { public: - Guardian(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject); + Guardian(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject); void InitStats(uint32 duration) override; bool InitStatsForLevel(uint8 level); void InitSummon() override; @@ -88,14 +88,14 @@ public: class Puppet : public Minion { public: - Puppet(SummonPropertiesEntry const* properties, uint64 owner); + Puppet(SummonPropertiesEntry const* properties, ObjectGuid owner); void InitStats(uint32 duration) override; void InitSummon() override; void Update(uint32 time) override; void RemoveFromWorld() override; protected: [[nodiscard]] Player* GetOwner() const; - const uint64 m_owner; + const ObjectGuid m_owner; }; class ForcedUnsummonDelayEvent : public BasicEvent diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.cpp b/src/server/game/Entities/DynamicObject/DynamicObject.cpp index 013eac3d49..9c56b4d3d9 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.cpp +++ b/src/server/game/Entities/DynamicObject/DynamicObject.cpp @@ -54,8 +54,10 @@ void DynamicObject::AddToWorld() ///- Register the dynamicObject for guid lookup and for caster if (!IsInWorld()) { - sObjectAccessor->AddObject(this); + GetMap()->GetObjectsStore().Insert<DynamicObject>(GetGUID(), this); + WorldObject::AddToWorld(); + BindToCaster(); } } @@ -76,14 +78,17 @@ void DynamicObject::RemoveFromWorld() return; UnbindFromCaster(); + if (Transport* transport = GetTransport()) transport->RemovePassenger(this, true); + WorldObject::RemoveFromWorld(); - sObjectAccessor->RemoveObject(this); + + GetMap()->GetObjectsStore().Remove<DynamicObject>(GetGUID()); } } -bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type) +bool DynamicObject::CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type) { SetMap(caster->GetMap()); Relocate(pos); @@ -93,11 +98,11 @@ bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spe return false; } - WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask()); + WorldObject::_Create(guidlow, HighGuid::DynamicObject, caster->GetPhaseMask()); SetEntry(spellId); SetObjectScale(1); - SetUInt64Value(DYNAMICOBJECT_CASTER, caster->GetGUID()); + SetGuidValue(DYNAMICOBJECT_CASTER, caster->GetGUID()); // The lower word of DYNAMICOBJECT_BYTES must be 0x0001. This value means that the visual radius will be overriden // by client for most of the "ground patch" visual effect spells and a few "skyfall" ones like Hurricane. diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.h b/src/server/game/Entities/DynamicObject/DynamicObject.h index 1ee903098c..259dee7f08 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.h +++ b/src/server/game/Entities/DynamicObject/DynamicObject.h @@ -31,7 +31,7 @@ public: void CleanupsBeforeDelete(bool finalCleanup = true) override; - bool CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type); + bool CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type); void Update(uint32 p_time) override; void Remove(); void SetDuration(int32 newDuration); @@ -45,7 +45,7 @@ public: void BindToCaster(); void UnbindFromCaster(); [[nodiscard]] uint32 GetSpellId() const { return GetUInt32Value(DYNAMICOBJECT_SPELLID); } - [[nodiscard]] uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); } + [[nodiscard]] ObjectGuid GetCasterGUID() const { return GetGuidValue(DYNAMICOBJECT_CASTER); } [[nodiscard]] float GetRadius() const { return GetFloatValue(DYNAMICOBJECT_RADIUS); } [[nodiscard]] bool IsViewpoint() const { return _isViewpoint; } diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 74a1ff170a..1c0d4ea152 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -47,13 +47,11 @@ GameObject::GameObject() : WorldObject(false), MovableMapObject(), m_spellId = 0; m_cooldownTime = 0; m_goInfo = nullptr; - m_ritualOwnerGUIDLow = 0; m_goData = nullptr; m_packedRotation = 0; - m_DBTableGuid = 0; + m_spawnId = 0; - m_lootRecipient = 0; m_lootRecipientGroup = 0; m_groupLootTimer = 0; lootingGroupLowGUID = 0; @@ -109,7 +107,7 @@ void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/) void GameObject::RemoveFromOwner() { - uint64 ownerGUID = GetOwnerGUID(); + ObjectGuid ownerGUID = GetOwnerGUID(); if (!ownerGUID) return; @@ -120,16 +118,10 @@ void GameObject::RemoveFromOwner() return; } - // Xinef: not needed - /*const char * ownerType = "creature"; - if (IS_PLAYER_GUID(ownerGUID)) - ownerType = "player"; - else if (IS_PET_GUID(ownerGUID)) - ownerType = "pet"; + LOG_FATAL("server", "Delete GameObject (%s Entry: %u SpellId %u LinkedGO %u) that lost references to owner %s GO list. Crash possible later.", + GetGUID().ToString().c_str(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString().c_str()); - LOG_FATAL("server", "Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.", - GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(ownerGUID), ownerType);*/ - SetOwnerGUID(0); + SetOwnerGUID(ObjectGuid::Empty); } void GameObject::AddToWorld() @@ -140,7 +132,9 @@ void GameObject::AddToWorld() if (m_zoneScript) m_zoneScript->OnGameObjectCreate(this); - sObjectAccessor->AddObject(this); + GetMap()->GetObjectsStore().Insert<GameObject>(GetGUID(), this); + if (m_spawnId) + GetMap()->GetGameObjectBySpawnIdStore().insert(std::make_pair(m_spawnId, this)); if (m_model) { @@ -169,13 +163,19 @@ void GameObject::RemoveFromWorld() m_zoneScript->OnGameObjectRemove(this); RemoveFromOwner(); + if (m_model) if (GetMap()->ContainsGameObjectModel(*m_model)) GetMap()->RemoveGameObjectModel(*m_model); + if (Transport* transport = GetTransport()) transport->RemovePassenger(this, true); + WorldObject::RemoveFromWorld(); - sObjectAccessor->RemoveObject(this); + + if (m_spawnId) + acore::Containers::MultimapErasePair(GetMap()->GetGameObjectBySpawnIdStore(), m_spawnId, this); + GetMap()->GetObjectsStore().Remove<GameObject>(GetGUID()); } } @@ -183,13 +183,15 @@ void GameObject::CheckRitualList() { if (m_unique_users.empty()) return; - for (std::set<uint64>::iterator itr = m_unique_users.begin(); itr != m_unique_users.end();) + + for (GuidSet::iterator itr = m_unique_users.begin(); itr != m_unique_users.end();) { if (*itr == GetOwnerGUID()) { ++itr; continue; } + bool erase = true; if (Player* channeler = ObjectAccessor::GetPlayer(*this, *itr)) if (Spell* spell = channeler->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) @@ -208,9 +210,10 @@ void GameObject::ClearRitualList() uint32 animSpell = GetGOInfo()->summoningRitual.animSpell; if (!animSpell || m_unique_users.empty()) return; - for (std::set<uint64>::iterator itr = m_unique_users.begin(); itr != m_unique_users.end(); ++itr) + + for (ObjectGuid const guid : m_unique_users) { - if (Player* channeler = ObjectAccessor::GetPlayer(*this, *itr)) + if (Player* channeler = ObjectAccessor::GetPlayer(*this, guid)) if (Spell* spell = channeler->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) if (spell->m_spellInfo->Id == animSpell) { @@ -218,10 +221,11 @@ void GameObject::ClearRitualList() spell->finish(); } } + m_unique_users.clear(); } -bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit) +bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit) { ASSERT(map); SetMap(map); @@ -251,7 +255,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa return false; } - Object::_Create(guidlow, goinfo->entry, HIGHGUID_GAMEOBJECT); + Object::_Create(guidlow, goinfo->entry, HighGuid::GameObject); m_goInfo = goinfo; @@ -431,7 +435,7 @@ void GameObject::Update(uint32 diff) bool triggered = info->summoningRitual.animSpell; Unit* owner = GetOwner(); - Unit* spellCaster = owner ? owner : ObjectAccessor::GetPlayer(*this, MAKE_NEW_GUID(m_ritualOwnerGUIDLow, 0, HIGHGUID_PLAYER)); + Unit* spellCaster = owner ? owner : ObjectAccessor::GetPlayer(*this, m_ritualOwnerGUID); if (!spellCaster) { SetLootState(GO_JUST_DEACTIVATED); @@ -493,11 +497,11 @@ void GameObject::Update(uint32 diff) time_t now = time(nullptr); if (m_respawnTime <= now) // timer expired { - uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_GAMEOBJECT); + ObjectGuid dbtableHighGuid = ObjectGuid::Create<HighGuid::GameObject>(GetEntry(), m_spawnId); time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid); if (linkedRespawntime) // Can't respawn, the master is dead { - uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid); + ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid); if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day) SetRespawnTime(DAY); else @@ -552,9 +556,9 @@ void GameObject::Update(uint32 diff) AI()->Reset(); // respawn timer - uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0; + uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<GameObject>(m_spawnId) : 0; if (poolid) - sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow()); + sPoolMgr->UpdatePool<GameObject>(poolid, m_spawnId); else GetMap()->AddToMap(this); } @@ -793,9 +797,9 @@ void GameObject::Delete() if (GetGOInfo()->type == GAMEOBJECT_TYPE_SUMMONING_RITUAL) ClearRitualList(); - uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0; + uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<GameObject>(m_spawnId) : 0; if (poolid) - sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow()); + sPoolMgr->UpdatePool<GameObject>(poolid, m_spawnId); else AddObjectToRemoveList(); } @@ -844,7 +848,7 @@ void GameObject::SaveToDB() { // this should only be used when the gameobject has already been loaded // preferably after adding to map, because mapid may not be valid otherwise - GameObjectData const* data = sObjectMgr->GetGOData(m_DBTableGuid); + GameObjectData const* data = sObjectMgr->GetGOData(m_spawnId); if (!data) { LOG_ERROR("server", "GameObject::SaveToDB failed, cannot get gameobject data!"); @@ -861,12 +865,12 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) if (!goI) return; - if (!m_DBTableGuid) - m_DBTableGuid = GetGUIDLow(); + if (!m_spawnId) + m_spawnId = sObjectMgr->GenerateGameObjectSpawnId(); + // update in loaded data (changing data only in this place) - GameObjectData& data = sObjectMgr->NewGOData(m_DBTableGuid); + GameObjectData& data = sObjectMgr->NewGOData(m_spawnId); - // data->guid = guid must not be updated at save data.id = GetEntry(); data.mapid = mapid; data.phaseMask = phaseMask; @@ -887,11 +891,11 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) uint8 index = 0; PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT); - stmt->setUInt32(0, m_DBTableGuid); + stmt->setUInt32(0, m_spawnId); trans->Append(stmt); stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT); - stmt->setUInt32(index++, m_DBTableGuid); + stmt->setUInt32(index++, m_spawnId); stmt->setUInt32(index++, GetEntry()); stmt->setUInt16(index++, uint16(mapid)); stmt->setUInt8(index++, spawnMask); @@ -912,13 +916,13 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) WorldDatabase.CommitTransaction(trans); } -bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap) +bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap) { - GameObjectData const* data = sObjectMgr->GetGOData(guid); + GameObjectData const* data = sObjectMgr->GetGOData(spawnId); if (!data) { - LOG_ERROR("sql.sql", "Gameobject (GUID: %u) not found in table `gameobject`, can't load. ", guid); + LOG_ERROR("sql.sql", "Gameobject (GUID: %u) not found in table `gameobject`, can't load. ", spawnId); return false; } @@ -934,10 +938,9 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap) GOState go_state = data->go_state; uint32 artKit = data->artKit; - m_DBTableGuid = guid; - if (map->GetInstanceId() != 0) guid = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT); + m_spawnId = spawnId; - if (!Create(guid, entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state, artKit)) + if (!Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state, artKit)) return false; if (data->spawntimesecs >= 0) @@ -953,13 +956,13 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap) else { m_respawnDelayTime = data->spawntimesecs; - m_respawnTime = GetMap()->GetGORespawnTime(m_DBTableGuid); + m_respawnTime = GetMap()->GetGORespawnTime(m_spawnId); // ready to respawn if (m_respawnTime && m_respawnTime <= time(nullptr)) { m_respawnTime = 0; - GetMap()->RemoveGORespawnTime(m_DBTableGuid); + GetMap()->RemoveGORespawnTime(m_spawnId); } } } @@ -980,19 +983,15 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap) void GameObject::DeleteFromDB() { - GetMap()->RemoveGORespawnTime(m_DBTableGuid); - sObjectMgr->DeleteGOData(m_DBTableGuid); + GetMap()->RemoveGORespawnTime(m_spawnId); + sObjectMgr->DeleteGOData(m_spawnId); PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT); - - stmt->setUInt32(0, m_DBTableGuid); - + stmt->setUInt32(0, m_spawnId); WorldDatabase.Execute(stmt); stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_EVENT_GAMEOBJECT); - - stmt->setUInt32(0, m_DBTableGuid); - + stmt->setUInt32(0, m_spawnId); WorldDatabase.Execute(stmt); } @@ -1041,7 +1040,7 @@ Unit* GameObject::GetOwner() const void GameObject::SaveRespawnTime() { if (m_goData && m_goData->dbData && m_respawnTime > time(nullptr) && m_spawnedByDefault) - GetMap()->SaveGORespawnTime(m_DBTableGuid, m_respawnTime); + GetMap()->SaveGORespawnTime(m_spawnId, m_respawnTime); } bool GameObject::IsNeverVisible() const @@ -1067,7 +1066,7 @@ bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const return false; // Always seen by owner and friendly units - if (uint64 guid = GetOwnerGUID()) + if (ObjectGuid guid = GetOwnerGUID()) { if (seer->GetGUID() == guid) return true; @@ -1100,7 +1099,7 @@ void GameObject::Respawn() if (m_spawnedByDefault && m_respawnTime > 0) { m_respawnTime = time(nullptr); - GetMap()->RemoveGORespawnTime(m_DBTableGuid); + GetMap()->RemoveGORespawnTime(m_spawnId); } } @@ -1239,12 +1238,12 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f void GameObject::SetGoArtKit(uint8 kit) { SetByteValue(GAMEOBJECT_BYTES_1, 2, kit); - GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_DBTableGuid)); + GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_spawnId)); if (data) data->artKit = kit; } -void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid) +void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid) { const GameObjectData* data = nullptr; if (go) @@ -1358,9 +1357,9 @@ void GameObject::Use(Unit* user) { if (info->chair.slots > 0) // sometimes chairs in DB have error in fields and we dont know number of slots for (uint32 i = 0; i < info->chair.slots; ++i) - ChairListSlots[i] = 0; // Last user of current slot set to 0 (none sit here yet) + ChairListSlots[i].Clear(); // Last user of current slot set to 0 (none sit here yet) else - ChairListSlots[0] = 0; // error in DB, make one default slot + ChairListSlots[0].Clear(); // error in DB, make one default slot } Player* player = user->ToPlayer(); @@ -1393,10 +1392,10 @@ void GameObject::Use(Unit* user) if (ChairUser->IsSitState() && ChairUser->getStandState() != UNIT_STAND_STATE_SIT && ChairUser->GetExactDist2d(x_i, y_i) < 0.1f) continue; // This seat is already occupied by ChairUser. NOTE: Not sure if the ChairUser->getStandState() != UNIT_STAND_STATE_SIT check is required. else - itr->second = 0; // This seat is unoccupied. + itr->second.Clear(); // This seat is unoccupied. } else - itr->second = 0; // The seat may of had an occupant, but they're offline. + itr->second.Clear(); // The seat may of had an occupant, but they're offline. } found_free_slot = true; @@ -1455,7 +1454,7 @@ void GameObject::Use(Unit* user) if (info->goober.eventId) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("maps.script", "Goober ScriptStart id %u for GO entry %u (GUID %u).", info->goober.eventId, GetEntry(), GetDBTableGUIDLow()); + LOG_DEBUG("maps.script", "Goober ScriptStart id %u for GO entry %u (spawnId %u).", info->goober.eventId, GetEntry(), m_spawnId); #endif GetMap()->ScriptsStart(sEventScripts, info->goober.eventId, player, this); EventInform(info->goober.eventId); @@ -1617,8 +1616,8 @@ void GameObject::Use(Unit* user) GameObjectTemplate const* info = GetGOInfo(); // ritual owner is set for GO's without owner (not summoned) - if (m_ritualOwnerGUIDLow == 0 && !owner) - m_ritualOwnerGUIDLow = player->GetGUIDLow(); + if (!m_ritualOwnerGUID && !owner) + m_ritualOwnerGUID = player->GetGUID(); if (owner) { @@ -1635,7 +1634,7 @@ void GameObject::Use(Unit* user) } else { - Player* ritualOwner = ObjectAccessor::GetPlayer(*this, MAKE_NEW_GUID(m_ritualOwnerGUIDLow, 0, HIGHGUID_PLAYER)); + Player* ritualOwner = ObjectAccessor::GetPlayer(*this, m_ritualOwnerGUID); if (!ritualOwner) return; if (player != ritualOwner && (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(ritualOwner))) @@ -1677,7 +1676,7 @@ void GameObject::Use(Unit* user) if (info->spellcaster.partyOnly) { - Player const* caster = ObjectAccessor::GetObjectInOrOutOfWorld(GetOwnerGUID(), (Player*)nullptr); + Player const* caster = ObjectAccessor::FindConnectedPlayer(GetOwnerGUID()); if (!caster || user->GetTypeId() != TYPEID_PLAYER || !user->ToPlayer()->IsInSameRaidWith(caster)) return; } @@ -1839,8 +1838,8 @@ void GameObject::Use(Unit* user) } default: if (GetGoType() >= MAX_GAMEOBJECT_TYPE) - LOG_ERROR("server", "GameObject::Use(): unit (type: %u, guid: %u, name: %s) tries to use object (guid: %u, entry: %u, name: %s) of unknown type (%u)", - user->GetTypeId(), user->GetGUIDLow(), user->GetName().c_str(), GetGUIDLow(), GetEntry(), GetGOInfo()->name.c_str(), GetGoType()); + LOG_ERROR("server", "GameObject::Use(): unit (%s, name: %s) tries to use object (%s, name: %s) of unknown type (%u)", + user->GetGUID().ToString().c_str(), user->GetName().c_str(), GetGUID().ToString().c_str(), GetGOInfo()->name.c_str(), GetGoType()); break; } @@ -1924,7 +1923,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId) // xinef: set proper orientation, fixes cast against stealthed targets if (target) trigger->SetInFront(target); - trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, target ? target->GetGUID() : 0); + trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, target ? target->GetGUID() : ObjectGuid::Empty); } } @@ -2071,9 +2070,9 @@ void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= nullptr*/ if (player) { WorldPacket data(SMSG_DESTRUCTIBLE_BUILDING_DAMAGE, 8 + 8 + 8 + 4 + 4); - data.appendPackGUID(GetGUID()); - data.appendPackGUID(attackerOrHealer->GetGUID()); - data.appendPackGUID(player->GetGUID()); + data << GetPackGUID(); + data << attackerOrHealer->GetPackGUID(); + data << player->GetPackGUID(); data << uint32(-change); // change < 0 triggers SPELL_BUILDING_HEAL combat log event // change >= 0 triggers SPELL_BUILDING_DAMAGE event data << uint32(spellId); @@ -2299,7 +2298,7 @@ Player* GameObject::GetLootRecipient() const { if (!m_lootRecipient) return nullptr; - return ObjectAccessor::FindPlayerInOrOutOfWorld(m_lootRecipient); + return ObjectAccessor::FindConnectedPlayer(m_lootRecipient); } Group* GameObject::GetLootRecipientGroup() const @@ -2317,7 +2316,7 @@ void GameObject::SetLootRecipient(Unit* unit) if (!unit) { - m_lootRecipient = 0; + m_lootRecipient.Clear(); m_lootRecipientGroup = 0; return; } @@ -2331,7 +2330,7 @@ void GameObject::SetLootRecipient(Unit* unit) m_lootRecipient = player->GetGUID(); if (Group* group = player->GetGroup()) - m_lootRecipientGroup = group->GetLowGUID(); + m_lootRecipientGroup = group->GetGUID().GetCounter(); } bool GameObject::IsLootAllowedFor(Player const* player) const @@ -2449,9 +2448,9 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t void GameObject::GetRespawnPosition(float& x, float& y, float& z, float* ori /* = nullptr*/) const { - if (m_DBTableGuid) + if (m_spawnId) { - if (GameObjectData const* data = sObjectMgr->GetGOData(GetDBTableGUIDLow())) + if (GameObjectData const* data = sObjectMgr->GetGOData(m_spawnId)) { x = data->posX; y = data->posY; diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 0b1cd35d87..aa88c63bcf 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -738,7 +738,7 @@ public: void RemoveFromWorld() override; void CleanupsBeforeDelete(bool finalCleanup = true) override; - virtual bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0); + virtual bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0); void Update(uint32 p_time) override; [[nodiscard]] GameObjectTemplate const* GetGOInfo() const { return m_goInfo; } [[nodiscard]] GameObjectTemplateAddon const* GetTemplateAddon() const; @@ -748,7 +748,7 @@ public: [[nodiscard]] bool IsTransport() const; [[nodiscard]] bool IsDestructibleBuilding() const; - [[nodiscard]] uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } + [[nodiscard]] ObjectGuid::LowType GetSpawnId() const { return m_spawnId; } // z_rot, y_rot, x_rot - rotation angles around z, y and x axes void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot); @@ -761,11 +761,11 @@ public: void SaveToDB(); void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); - bool LoadFromDB(uint32 guid, Map* map) { return LoadGameObjectFromDB(guid, map, false); } - bool LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap = true); + bool LoadFromDB(ObjectGuid::LowType guid, Map* map) { return LoadGameObjectFromDB(guid, map, false); } + bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map* map, bool addToMap = true); void DeleteFromDB(); - void SetOwnerGUID(uint64 owner) + void SetOwnerGUID(ObjectGuid owner) { // Owner already found and different than expected owner - remove object from old owner if (owner && GetOwnerGUID() && GetOwnerGUID() != owner) @@ -773,9 +773,9 @@ public: ABORT(); } m_spawnedByDefault = false; // all object with owner is despawned after delay - SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner); + SetGuidValue(OBJECT_FIELD_CREATED_BY, owner); } - [[nodiscard]] uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); } + [[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(OBJECT_FIELD_CREATED_BY); } [[nodiscard]] Unit* GetOwner() const; void SetSpellId(uint32 id) @@ -822,7 +822,7 @@ public: void SetGoArtKit(uint8 artkit); [[nodiscard]] uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); } void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); } - static void SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid = 0); + static void SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid = 0); void SetPhaseMask(uint32 newPhaseMask, bool update) override; void EnableCollision(bool enable); @@ -840,11 +840,11 @@ public: void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; } void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; } - void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); } - [[nodiscard]] bool IsInSkillupList(uint32 PlayerGuidLow) const + void AddToSkillupList(ObjectGuid playerGuid) { m_SkillupList.push_back(playerGuid); } + [[nodiscard]] bool IsInSkillupList(ObjectGuid playerGuid) const { - for (unsigned int i : m_SkillupList) - if (i == PlayerGuidLow) + for (ObjectGuid const guid : m_SkillupList) + if (guid == playerGuid) return true; return false; @@ -961,16 +961,16 @@ protected: bool m_spawnedByDefault; uint32 m_cooldownTime; // used as internal reaction delay time store (not state change reaction). // For traps this: spell casting cooldown, for doors/buttons: reset time. - std::list<uint32> m_SkillupList; + GuidList m_SkillupList; - uint32 m_ritualOwnerGUIDLow; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner) - std::set<uint64> m_unique_users; + ObjectGuid m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner) + GuidSet m_unique_users; uint32 m_usetimes; - typedef std::map<uint32, uint64> ChairSlotAndUser; + typedef std::map<uint32, ObjectGuid> ChairSlotAndUser; ChairSlotAndUser ChairListSlots; - uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid + ObjectGuid::LowType m_spawnId; ///< For new or temporary gameobjects is 0 for saved it is lowguid GameObjectTemplate const* m_goInfo; GameObjectData const* m_goData; GameObjectValue m_goValue; @@ -980,7 +980,7 @@ protected: G3D::Quat m_worldRotation; Position m_stationaryPosition; - uint64 m_lootRecipient; + ObjectGuid m_lootRecipient; uint32 m_lootRecipientGroup; uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable uint32 m_lootGenerationTime; diff --git a/src/server/game/Entities/Item/Container/Bag.cpp b/src/server/game/Entities/Item/Container/Bag.cpp index cb9a7d824c..e1f6329adf 100644 --- a/src/server/game/Entities/Item/Container/Bag.cpp +++ b/src/server/game/Entities/Item/Container/Bag.cpp @@ -56,20 +56,20 @@ void Bag::RemoveFromWorld() Item::RemoveFromWorld(); } -bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) +bool Bag::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner) { ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid); if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE) return false; - Object::_Create(guidlow, 0, HIGHGUID_CONTAINER); + Object::_Create(guidlow, 0, HighGuid::Item); SetEntry(itemid); SetObjectScale(1.0f); - SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0); - SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0); + SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : ObjectGuid::Empty); + SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : ObjectGuid::Empty); SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability); SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability); @@ -81,7 +81,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) // Cleaning 20 slots for (uint8 i = 0; i < MAX_BAG_SIZE; ++i) { - SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i * 2), 0); + SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid::Empty); m_bagslot[i] = nullptr; } @@ -93,7 +93,7 @@ void Bag::SaveToDB(SQLTransaction& trans) Item::SaveToDB(trans); } -bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry) +bool Bag::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) { if (!Item::LoadFromDB(guid, owner_guid, fields, entry)) return false; @@ -103,7 +103,7 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`) for (uint8 i = 0; i < MAX_BAG_SIZE; ++i) { - SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i * 2), 0); + SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid::Empty); delete m_bagslot[i]; m_bagslot[i] = nullptr; } @@ -138,7 +138,7 @@ void Bag::RemoveItem(uint8 slot, bool /*update*/) m_bagslot[slot]->SetContainer(nullptr); m_bagslot[slot] = nullptr; - SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (slot * 2), 0); + SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), ObjectGuid::Empty); } void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/) @@ -148,9 +148,9 @@ void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/) if (pItem && pItem->GetGUID() != this->GetGUID()) { m_bagslot[slot] = pItem; - SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetGUID()); - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, GetGUID()); - pItem->SetUInt64Value(ITEM_FIELD_OWNER, GetOwnerGUID()); + SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetGUID()); + pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID()); + pItem->SetGuidValue(ITEM_FIELD_OWNER, GetOwnerGUID()); pItem->SetContainer(this); pItem->SetSlot(slot); } @@ -212,7 +212,7 @@ uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem) return count; } -uint8 Bag::GetSlotByItemGUID(uint64 guid) const +uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const { for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i] != 0) diff --git a/src/server/game/Entities/Item/Container/Bag.h b/src/server/game/Entities/Item/Container/Bag.h index 5cc5f6a1d5..4058e7cc5d 100644 --- a/src/server/game/Entities/Item/Container/Bag.h +++ b/src/server/game/Entities/Item/Container/Bag.h @@ -22,7 +22,7 @@ public: void AddToWorld() override; void RemoveFromWorld() override; - bool Create(uint32 guidlow, uint32 itemid, Player const* owner) override; + bool Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner) override; void Clear(); void StoreItem(uint8 slot, Item* pItem, bool update); @@ -32,7 +32,7 @@ public: uint32 GetItemCount(uint32 item, Item* eItem = nullptr) const; uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const; - [[nodiscard]] uint8 GetSlotByItemGUID(uint64 guid) const; + [[nodiscard]] uint8 GetSlotByItemGUID(ObjectGuid guid) const; [[nodiscard]] bool IsEmpty() const; [[nodiscard]] uint32 GetFreeSlots() const; [[nodiscard]] uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); } @@ -41,7 +41,7 @@ public: // overwrite virtual Item::SaveToDB void SaveToDB(SQLTransaction& trans) override; // overwrite virtual Item::LoadFromDB - bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry) override; + bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) override; // overwrite virtual Item::DeleteFromDB void DeleteFromDB(SQLTransaction& trans) override; diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 52de3b548e..85720f2b47 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -247,15 +247,15 @@ Item::Item() m_paidExtendedCost = 0; } -bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner) +bool Item::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner) { - Object::_Create(guidlow, 0, HIGHGUID_ITEM); + Object::_Create(guidlow, 0, HighGuid::Item); SetEntry(itemid); SetObjectScale(1.0f); - SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0); - SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0); + SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : ObjectGuid::Empty); + SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : ObjectGuid::Empty); ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid); if (!itemProto) @@ -309,7 +309,7 @@ void Item::SaveToDB(SQLTransaction& trans) if (!isInTransaction) trans = CharacterDatabase.BeginTransaction(); - uint32 guid = GetGUIDLow(); + ObjectGuid::LowType guid = GetGUID().GetCounter(); switch (uState) { case ITEM_NEW: @@ -318,9 +318,9 @@ void Item::SaveToDB(SQLTransaction& trans) uint8 index = 0; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE); stmt->setUInt32( index, GetEntry()); - stmt->setUInt32(++index, GUID_LOPART(GetOwnerGUID())); - stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_CREATOR))); - stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_GIFTCREATOR))); + stmt->setUInt32(++index, GetOwnerGUID().GetCounter()); + stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter()); + stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter()); stmt->setUInt32(++index, GetCount()); stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION)); @@ -351,7 +351,7 @@ void Item::SaveToDB(SQLTransaction& trans) if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED)) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER); - stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID())); + stmt->setUInt32(0, GetOwnerGUID().GetCounter()); stmt->setUInt32(1, guid); trans->Append(stmt); } @@ -386,14 +386,14 @@ void Item::SaveToDB(SQLTransaction& trans) CharacterDatabase.CommitTransaction(trans); } -bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry) +bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) { // 0 1 2 3 4 5 6 7 8 9 10 //result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid); // create item before any checks for store correct guid // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB - Object::_Create(guid, 0, HIGHGUID_ITEM); + Object::_Create(guid, 0, HighGuid::Item); // Set entry, MUST be before proto check SetEntry(entry); @@ -404,12 +404,12 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr return false; // set owner (not if item is only loaded for gbank/auction/mail - if (owner_guid != 0) + if (owner_guid) SetOwnerGUID(owner_guid); bool need_save = false; // need explicit save data at load fixes - SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER)); - SetUInt64Value(ITEM_FIELD_GIFTCREATOR, MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER)); + SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32())); + SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32())); SetCount(fields[2].GetUInt32()); uint32 duration = fields[3].GetUInt32(); @@ -470,7 +470,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr } /*static*/ -void Item::DeleteFromDB(SQLTransaction& trans, uint32 itemGuid) +void Item::DeleteFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid) { sScriptMgr->OnGlobalItemDelFromDB(trans, itemGuid); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); @@ -480,11 +480,11 @@ void Item::DeleteFromDB(SQLTransaction& trans, uint32 itemGuid) void Item::DeleteFromDB(SQLTransaction& trans) { - DeleteFromDB(trans, GetGUIDLow()); + DeleteFromDB(trans, GetGUID().GetCounter()); } /*static*/ -void Item::DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid) +void Item::DeleteFromInventoryDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); stmt->setUInt32(0, itemGuid); @@ -493,7 +493,7 @@ void Item::DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid) void Item::DeleteFromInventoryDB(SQLTransaction& trans) { - DeleteFromInventoryDB(trans, GetGUIDLow()); + DeleteFromInventoryDB(trans, GetGUID().GetCounter()); } ItemTemplate const* Item::GetTemplate() const @@ -674,7 +674,7 @@ void Item::SetState(ItemUpdateState state, Player* forplayer) if (forplayer) { RemoveFromUpdateQueueOf(forplayer); - forplayer->DeleteRefundReference(GetGUIDLow()); + forplayer->DeleteRefundReference(GetGUID()); } delete this; return; @@ -706,7 +706,7 @@ void Item::AddToUpdateQueueOf(Player* player) if (player->GetGUID() != GetOwnerGUID()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow()); + LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!", GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str()); #endif return; } @@ -728,7 +728,7 @@ void Item::RemoveFromUpdateQueueOf(Player* player) if (player->GetGUID() != GetOwnerGUID()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow()); + LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!", GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str()); #endif return; } @@ -880,7 +880,7 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const return true; } -void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster /*= 0*/) +void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster /*= ObjectGuid::Empty*/) { // Better lost small time at check in comparison lost time at item save to DB. if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges)) @@ -890,7 +890,7 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT) { if (uint32 oldEnchant = GetEnchantmentId(slot)) - owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), 0, GetEntry(), oldEnchant); + owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), ObjectGuid::Empty, GetEntry(), oldEnchant); if (id) owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetEntry(), id); @@ -1025,7 +1025,7 @@ bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) cons void Item::SendUpdateSockets() { WorldPacket data(SMSG_SOCKET_GEMS_RESULT, 8 + 4 + 4 + 4 + 4); - data << uint64(GetGUID()); + data << GetGUID(); for (uint32 i = SOCK_ENCHANTMENT_SLOT; i <= BONUS_ENCHANTMENT_SLOT; ++i) data << uint32(GetEnchantmentId(EnchantmentSlot(i))); @@ -1042,7 +1042,7 @@ void Item::SendTimeUpdate(Player* owner) return; WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4)); - data << uint64(GetGUID()); + data << GetGUID(); data << uint32(duration); owner->GetSession()->SendPacket(&data); } @@ -1061,7 +1061,7 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, bool clo ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already"); Item* pItem = NewItemOrBag(pProto); - if (pItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), item, player)) + if (pItem->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(), item, player)) { pItem->SetCount(count); if (!clone) @@ -1103,7 +1103,7 @@ bool Item::IsBindedNotWith(Player const* player) const return false; if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE)) - if (allowedGUIDs.find(player->GetGUIDLow()) != allowedGUIDs.end()) + if (allowedGUIDs.find(player->GetGUID()) != allowedGUIDs.end()) return false; // BOA item case @@ -1120,16 +1120,28 @@ void Item::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&) ClearUpdateMask(false); } +void Item::AddToObjectUpdate() +{ + if (Player* owner = GetOwner()) + owner->GetMap()->AddUpdateObject(this); +} + +void Item::RemoveFromObjectUpdate() +{ + if (Player* owner = GetOwner()) + owner->GetMap()->RemoveUpdateObject(this); +} + void Item::SaveRefundDataToDB() { SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_REFUND_INSTANCE); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, GetRefundRecipient()); stmt->setUInt32(2, GetPaidMoney()); stmt->setUInt16(3, uint16(GetPaidExtendedCost())); @@ -1143,7 +1155,7 @@ void Item::DeleteRefundDataFromDB(SQLTransaction* trans) if (trans) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); (*trans)->Append(stmt); } } @@ -1163,7 +1175,7 @@ void Item::SetNotRefundable(Player* owner, bool changestate /*=true*/, SQLTransa SetPaidExtendedCost(0); DeleteRefundDataFromDB(trans); - owner->DeleteRefundReference(GetGUIDLow()); + owner->DeleteRefundReference(GetGUID()); } void Item::UpdatePlayedTime(Player* owner) @@ -1221,7 +1233,7 @@ void Item::ClearSoulboundTradeable(Player* currentOwner) allowedGUIDs.clear(); SetState(ITEM_CHANGED, currentOwner); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index 2f2a659786..f3274d2b1c 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -204,12 +204,12 @@ public: Item(); - virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner); + virtual bool Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner); [[nodiscard]] ItemTemplate const* GetTemplate() const; - [[nodiscard]] uint64 GetOwnerGUID() const { return GetUInt64Value(ITEM_FIELD_OWNER); } - void SetOwnerGUID(uint64 guid) { SetUInt64Value(ITEM_FIELD_OWNER, guid); } + [[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(ITEM_FIELD_OWNER); } + void SetOwnerGUID(ObjectGuid guid) { SetGuidValue(ITEM_FIELD_OWNER, guid); } [[nodiscard]] Player* GetOwner() const; void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_SOULBOUND, val); } @@ -219,10 +219,10 @@ public: [[nodiscard]] bool IsBoundByEnchant() const; [[nodiscard]] bool IsBoundByTempEnchant() const; virtual void SaveToDB(SQLTransaction& trans); - virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry); - static void DeleteFromDB(SQLTransaction& trans, uint32 itemGuid); + virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry); + static void DeleteFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid); virtual void DeleteFromDB(SQLTransaction& trans); - static void DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid); + static void DeleteFromInventoryDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid); void DeleteFromInventoryDB(SQLTransaction& trans); void SaveRefundDataToDB(); void DeleteRefundDataFromDB(SQLTransaction* trans); @@ -274,7 +274,7 @@ public: void SetItemRandomProperties(int32 randomPropId); void UpdateItemSuffixFactor(); static int32 GenerateItemRandomPropertyId(uint32 item_id); - void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster = 0); + void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster = ObjectGuid::Empty); void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner); void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges); void ClearEnchantment(EnchantmentSlot slot); @@ -318,10 +318,10 @@ public: // Item Refund system void SetNotRefundable(Player* owner, bool changestate = true, SQLTransaction* trans = nullptr); - void SetRefundRecipient(uint32 pGuidLow) { m_refundRecipient = pGuidLow; } + void SetRefundRecipient(ObjectGuid::LowType pGuidLow) { m_refundRecipient = pGuidLow; } void SetPaidMoney(uint32 money) { m_paidMoney = money; } void SetPaidExtendedCost(uint32 iece) { m_paidExtendedCost = iece; } - uint32 GetRefundRecipient() { return m_refundRecipient; } + ObjectGuid::LowType GetRefundRecipient() { return m_refundRecipient; } uint32 GetPaidMoney() { return m_paidMoney; } uint32 GetPaidExtendedCost() { return m_paidExtendedCost; } @@ -335,6 +335,8 @@ public: bool CheckSoulboundTradeExpire(); void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&) override; + void AddToObjectUpdate() override; + void RemoveFromObjectUpdate() override; [[nodiscard]] uint32 GetScriptId() const { return GetTemplate()->ScriptId; } private: diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 2d9135121e..3adfa1e8fb 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -47,33 +47,6 @@ #include "LuaEngine.h" #endif -uint32 GuidHigh2TypeId(uint32 guid_hi) -{ - switch (guid_hi) - { - case HIGHGUID_ITEM: - return TYPEID_ITEM; - //case HIGHGUID_CONTAINER: return TYPEID_CONTAINER; HIGHGUID_CONTAINER == HIGHGUID_ITEM currently - case HIGHGUID_UNIT: - return TYPEID_UNIT; - case HIGHGUID_PET: - return TYPEID_UNIT; - case HIGHGUID_PLAYER: - return TYPEID_PLAYER; - case HIGHGUID_GAMEOBJECT: - return TYPEID_GAMEOBJECT; - case HIGHGUID_DYNAMICOBJECT: - return TYPEID_DYNAMICOBJECT; - case HIGHGUID_CORPSE: - return TYPEID_CORPSE; - case HIGHGUID_MO_TRANSPORT: - return TYPEID_GAMEOBJECT; - case HIGHGUID_VEHICLE: - return TYPEID_UNIT; - } - return NUM_CLIENT_OBJECT_TYPES; // unknown -} - Object::Object() : m_PackGUID(sizeof(uint64) + 1) { m_objectTypeId = TYPEID_OBJECT; @@ -86,8 +59,6 @@ Object::Object() : m_PackGUID(sizeof(uint64) + 1) m_inWorld = false; m_objectUpdated = false; - m_PackGUID.appendPackGUID(0); - sScriptMgr->OnConstructObject(this); } @@ -103,7 +74,7 @@ WorldObject::~WorldObject() { if (GetTypeId() == TYPEID_CORPSE) { - LOG_FATAL("server", "Object::~Object Corpse guid=" UI64FMTD ", type=%d, entry=%u deleted but still in map!!", GetGUID(), ((Corpse*)this)->GetType(), GetEntry()); + LOG_FATAL("server", "Object::~Object Corpse %s, type=%d deleted but still in map!!", GetGUID().ToString().c_str(), ((Corpse*)this)->GetType()); ABORT(); } ResetMap(); @@ -116,18 +87,16 @@ Object::~Object() if (IsInWorld()) { - LOG_FATAL("server", "Object::~Object - guid=" UI64FMTD ", typeid=%d, entry=%u deleted but still in world!!", GetGUID(), GetTypeId(), GetEntry()); + LOG_FATAL("server", "Object::~Object - %s deleted but still in world!!", GetGUID().ToString().c_str()); if (isType(TYPEMASK_ITEM)) LOG_FATAL("server", "Item slot %u", ((Item*)this)->GetSlot()); ABORT(); - RemoveFromWorld(); } if (m_objectUpdated) { - LOG_FATAL("server", "Object::~Object - guid=" UI64FMTD ", typeid=%d, entry=%u deleted but still in update list!!", GetGUID(), GetTypeId(), GetEntry()); + LOG_FATAL("server", "Object::~Object - %s deleted but still in update list!!", GetGUID().ToString().c_str()); ABORT(); - sObjectAccessor->RemoveUpdateObject(this); } delete [] m_uint32Values; @@ -144,15 +113,14 @@ void Object::_InitValues() m_objectUpdated = false; } -void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh) +void Object::_Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh) { if (!m_uint32Values) _InitValues(); - uint64 guid = MAKE_NEW_GUID(guidlow, entry, guidhigh); - SetUInt64Value(OBJECT_FIELD_GUID, guid); + ObjectGuid guid(guidhigh, entry, guidlow); + SetGuidValue(OBJECT_FIELD_GUID, guid); SetUInt32Value(OBJECT_FIELD_TYPE, m_objectType); - m_PackGUID.wpos(0); - m_PackGUID.appendPackGUID(GetGUID()); + m_PackGUID.Set(guid); } std::string Object::_ConcatFields(uint16 startIndex, uint16 size) const @@ -173,7 +141,8 @@ void Object::AddToWorld() m_inWorld = true; // synchronize values mirror with values array (changes will send in updatecreate opcode any way - ClearUpdateMask(true); + ASSERT(!m_objectUpdated); + ClearUpdateMask(false); } void Object::RemoveFromWorld() @@ -192,7 +161,7 @@ void Object::BuildMovementUpdateBlock(UpdateData* data, uint32 flags) const ByteBuffer buf(500); buf << uint8(UPDATETYPE_MOVEMENT); - buf.append(GetPackGUID()); + buf << GetPackGUID(); BuildMovementUpdate(&buf, flags); @@ -248,7 +217,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c ByteBuffer buf(500); buf << (uint8)updatetype; - buf.append(GetPackGUID()); + buf << GetPackGUID(); buf << (uint8)m_objectTypeId; BuildMovementUpdate(&buf, flags); @@ -272,7 +241,7 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) c ByteBuffer buf(500); buf << (uint8) UPDATETYPE_VALUES; - buf.append(GetPackGUID()); + buf << GetPackGUID(); BuildValuesUpdate(UPDATETYPE_VALUES, &buf, target); @@ -295,14 +264,14 @@ void Object::DestroyForPlayer(Player* target, bool onDeath) const if (bg->isArena()) { WorldPacket data(SMSG_ARENA_UNIT_DESTROYED, 8); - data << uint64(GetGUID()); + data << GetGUID(); target->GetSession()->SendPacket(&data); } } } WorldPacket data(SMSG_DESTROY_OBJECT, 8 + 1); - data << uint64(GetGUID()); + data << GetGUID(); //! If the following bool is true, the client will call "void CGUnit_C::OnDeath()" for this object. //! OnDeath() does for eg trigger death animation and interrupts certain spells/missiles/auras/sounds... data << uint8(onDeath ? 1 : 0); @@ -353,7 +322,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const Transport* transport = object->GetTransport(); if (transport) - data->append(transport->GetPackGUID()); + *data << transport->GetPackGUID(); else *data << uint8(0); @@ -411,7 +380,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const case TYPEID_GAMEOBJECT: case TYPEID_DYNAMICOBJECT: case TYPEID_CORPSE: - *data << uint32(GetGUIDLow()); // GetGUIDLow() + *data << uint32(GetGUID().GetCounter()); break; //! Unit, Player and default here are sending wrong values. /// @todo Research the proper formula @@ -434,7 +403,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const if (flags & UPDATEFLAG_HAS_TARGET) { if (Unit* victim = unit->GetVictim()) - data->append(victim->GetPackGUID()); + *data << victim->GetPackGUID(); else *data << uint8(0); } @@ -492,6 +461,15 @@ void Object::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* targe data->append(fieldBuffer); } +void Object::AddToObjectUpdateIfNeeded() +{ + if (m_inWorld && !m_objectUpdated) + { + AddToObjectUpdate(); + m_objectUpdated = true; + } +} + void Object::ClearUpdateMask(bool remove) { _changesMask.Clear(); @@ -499,7 +477,7 @@ void Object::ClearUpdateMask(bool remove) if (m_objectUpdated) { if (remove) - sObjectAccessor->RemoveUpdateObject(this); + RemoveFromObjectUpdate(); m_objectUpdated = false; } } @@ -597,11 +575,7 @@ void Object::SetInt32Value(uint16 index, int32 value) m_int32Values[index] = value; _changesMask.SetBit(index); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } } @@ -614,11 +588,7 @@ void Object::SetUInt32Value(uint16 index, uint32 value) m_uint32Values[index] = value; _changesMask.SetBit(index); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } } @@ -633,6 +603,7 @@ void Object::UpdateUInt32Value(uint16 index, uint32 value) void Object::SetUInt64Value(uint16 index, uint64 value) { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); + if (*((uint64*) & (m_uint32Values[index])) != value) { m_uint32Values[index] = PAIR64_LOPART(value); @@ -640,29 +611,21 @@ void Object::SetUInt64Value(uint16 index, uint64 value) _changesMask.SetBit(index); _changesMask.SetBit(index + 1); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } } -bool Object::AddUInt64Value(uint16 index, uint64 value) +bool Object::AddGuidValue(uint16 index, ObjectGuid value) { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); - if (value && !*((uint64*) & (m_uint32Values[index]))) + + if (value && !*((ObjectGuid*)&(m_uint32Values[index]))) { - m_uint32Values[index] = PAIR64_LOPART(value); - m_uint32Values[index + 1] = PAIR64_HIPART(value); + *((ObjectGuid*)&(m_uint32Values[index])) = value; _changesMask.SetBit(index); _changesMask.SetBit(index + 1); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); return true; } @@ -670,21 +633,18 @@ bool Object::AddUInt64Value(uint16 index, uint64 value) return false; } -bool Object::RemoveUInt64Value(uint16 index, uint64 value) +bool Object::RemoveGuidValue(uint16 index, ObjectGuid value) { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); - if (value && *((uint64*) & (m_uint32Values[index])) == value) + + if (value && *((ObjectGuid*)&(m_uint32Values[index])) == value) { m_uint32Values[index] = 0; m_uint32Values[index + 1] = 0; _changesMask.SetBit(index); _changesMask.SetBit(index + 1); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); return true; } @@ -692,6 +652,20 @@ bool Object::RemoveUInt64Value(uint16 index, uint64 value) return false; } +void Object::SetGuidValue(uint16 index, ObjectGuid value) +{ + ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); + + if (*((ObjectGuid*)&(m_uint32Values[index])) != value) + { + *((ObjectGuid*)&(m_uint32Values[index])) = value; + _changesMask.SetBit(index); + _changesMask.SetBit(index + 1); + + AddToObjectUpdateIfNeeded(); + } +} + void Object::SetFloatValue(uint16 index, float value) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); @@ -701,11 +675,7 @@ void Object::SetFloatValue(uint16 index, float value) m_floatValues[index] = value; _changesMask.SetBit(index); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } } @@ -725,11 +695,7 @@ void Object::SetByteValue(uint16 index, uint8 offset, uint8 value) m_uint32Values[index] |= uint32(uint32(value) << (offset * 8)); _changesMask.SetBit(index); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } } @@ -749,11 +715,7 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value) m_uint32Values[index] |= uint32(uint32(value) << (offset * 16)); _changesMask.SetBit(index); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } } @@ -816,11 +778,7 @@ void Object::SetFlag(uint16 index, uint32 newFlag) m_uint32Values[index] = newval; _changesMask.SetBit(index); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } } @@ -837,11 +795,7 @@ void Object::RemoveFlag(uint16 index, uint32 oldFlag) m_uint32Values[index] = newval; _changesMask.SetBit(index); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } } @@ -860,11 +814,7 @@ void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag) m_uint32Values[index] |= uint32(uint32(newFlag) << (offset * 8)); _changesMask.SetBit(index); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } } @@ -883,11 +833,7 @@ void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag) m_uint32Values[index] &= ~uint32(uint32(oldFlag) << (offset * 8)); _changesMask.SetBit(index); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } } @@ -966,7 +912,7 @@ ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& st void MovementInfo::OutDebug() { LOG_INFO("server", "MOVEMENT INFO"); - LOG_INFO("server", "guid " UI64FMTD, guid); + LOG_INFO("server", "guid %s", guid.ToString().c_str()); LOG_INFO("server", "flags %u", flags); LOG_INFO("server", "flags2 %u", flags2); LOG_INFO("server", "time %u current time " UI64FMTD "", flags2, uint64(::time(nullptr))); @@ -974,7 +920,7 @@ void MovementInfo::OutDebug() if (flags & MOVEMENTFLAG_ONTRANSPORT) { LOG_INFO("server", "TRANSPORT:"); - LOG_INFO("server", "guid: " UI64FMTD, transport.guid); + LOG_INFO("server", "guid: %s", transport.guid.ToString().c_str()); LOG_INFO("server", "position: `%s`", transport.pos.ToString().c_str()); LOG_INFO("server", "seat: %i", transport.seat); LOG_INFO("server", "time: %u", transport.time); @@ -1082,7 +1028,7 @@ void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/) RemoveFromWorld(); } -void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask) +void WorldObject::_Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask) { Object::_Create(guidlow, 0, guidhigh); SetPhaseMask(phaseMask, false); @@ -1122,7 +1068,7 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool float sizefactor = GetObjectSize() + obj->GetObjectSize(); float maxdist = dist2compare + sizefactor; - if (m_transport && obj->GetTransport() && obj->GetTransport()->GetGUIDLow() == m_transport->GetGUIDLow()) + if (m_transport && obj->GetTransport() && obj->GetTransport()->GetGUID() == m_transport->GetGUID()) { float dtx = m_movementInfo.transport.pos.m_positionX - obj->m_movementInfo.transport.pos.m_positionX; float dty = m_movementInfo.transport.pos.m_positionY - obj->m_movementInfo.transport.pos.m_positionY; @@ -1951,11 +1897,7 @@ void WorldObject::SendPlayMusic(uint32 Music, bool OnlySelf) void Object::ForceValuesUpdateAtIndex(uint32 i) { _changesMask.SetBit(i); - if (m_inWorld && !m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + AddToObjectUpdateIfNeeded(); } namespace acore @@ -2120,7 +2062,7 @@ void WorldObject::MonsterWhisper(int32 textId, Player const* target, bool IsBoss void Unit::BuildHeartBeatMsg(WorldPacket* data) const { data->Initialize(MSG_MOVE_HEARTBEAT, 32); - data->append(GetPackGUID()); + *data << GetPackGUID(); BuildMovementPacket(data); } @@ -2134,17 +2076,17 @@ void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /* VisitNearbyWorldObject(dist, notifier); } -void WorldObject::SendObjectDeSpawnAnim(uint64 guid) +void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid) { WorldPacket data(SMSG_GAMEOBJECT_DESPAWN_ANIM, 8); - data << uint64(guid); + data << guid; SendMessageToSet(&data, true); } void WorldObject::SetMap(Map* map) { ASSERT(map); - ASSERT(!IsInWorld() || GetTypeId() == TYPEID_CORPSE); + ASSERT(!IsInWorld()); if (m_currMap == map) // command add npc: first create, than loadfromdb return; if (m_currMap) @@ -2197,7 +2139,7 @@ void WorldObject::AddObjectToRemoveList() Map* map = FindMap(); if (!map) { - LOG_ERROR("server", "Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list not have valid map (Id: %u).", GetTypeId(), GetEntry(), GetGUIDLow(), GetMapId()); + LOG_ERROR("server", "Object %s at attempt add to move list not have valid map (Id: %u).", GetGUID().ToString().c_str(), GetMapId()); return; } @@ -2263,26 +2205,26 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert switch (mask) { case UNIT_MASK_SUMMON: - summon = new TempSummon(properties, summoner ? summoner->GetGUID() : 0, false); + summon = new TempSummon(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false); break; case UNIT_MASK_GUARDIAN: - summon = new Guardian(properties, summoner ? summoner->GetGUID() : 0, false); + summon = new Guardian(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false); break; case UNIT_MASK_PUPPET: - summon = new Puppet(properties, summoner ? summoner->GetGUID() : 0); + summon = new Puppet(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty); break; case UNIT_MASK_TOTEM: - summon = new Totem(properties, summoner ? summoner->GetGUID() : 0); + summon = new Totem(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty); break; case UNIT_MASK_MINION: - summon = new Minion(properties, summoner ? summoner->GetGUID() : 0, false); + summon = new Minion(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false); break; default: return nullptr; } EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY())); - if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation())) + if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation())) { delete summon; return nullptr; @@ -2293,7 +2235,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert summon->SetHomePosition(pos); summon->InitStats(duration); - AddToMap(summon->ToCreature(), (IS_PLAYER_GUID(summon->GetOwnerGUID()) || (summoner && summoner->GetTransport()))); + AddToMap(summon->ToCreature(), summon->GetOwnerGUID().IsPlayer() || (summoner && summoner->GetTransport())); summon->InitSummon(); //ObjectAccessor::UpdateObjectVisibility(summon); @@ -2330,7 +2272,7 @@ GameObject* Map::SummonGameObject(uint32 entry, float x, float y, float z, float } GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject(); - if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, this, PHASEMASK_NORMAL, x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY)) + if (!go->Create(GenerateLowGuid<HighGuid::GameObject>(), entry, this, PHASEMASK_NORMAL, x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY)) { delete go; return nullptr; @@ -2363,6 +2305,11 @@ void WorldObject::SetZoneScript() } } +void WorldObject::ClearZoneScript() +{ + m_zoneScript = nullptr; +} + TempSummon* WorldObject::SummonCreature(uint32 entry, const Position& pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/, SummonPropertiesEntry const* properties) const { if (Map* map = FindMap()) @@ -2391,7 +2338,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float Map* map = GetMap(); GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject(); - if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, GetPhaseMask(), x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY)) + if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, GetPhaseMask(), x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY)) { delete go; return nullptr; @@ -2857,7 +2804,7 @@ void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= nullptr* { WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8); data << uint32(sound_id); - data << uint64(GetGUID()); + data << GetGUID(); if (target) target->SendDirectMessage(&data); else @@ -2996,13 +2943,13 @@ struct WorldObjectChangeAccumulator for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { source = iter->GetSource(); - uint64 guid = source->GetCasterGUID(); + ObjectGuid guid = source->GetCasterGUID(); - if (IS_PLAYER_GUID(guid)) + if (guid) { //Caster may be nullptr if DynObj is in removelist if (Player* caster = ObjectAccessor::FindPlayer(guid)) - if (caster->GetUInt64Value(PLAYER_FARSIGHT) == source->GetGUID()) + if (caster->GetGuidValue(PLAYER_FARSIGHT) == source->GetGUID()) BuildPacket(caster); } } @@ -3011,10 +2958,10 @@ struct WorldObjectChangeAccumulator void BuildPacket(Player* player) { // Only send update once to a player - if (i_playerSet.find(player->GetGUIDLow()) == i_playerSet.end() && player->HaveAtClient(&i_object)) + if (i_playerSet.find(player->GetGUID()) == i_playerSet.end() && player->HaveAtClient(&i_object)) { i_object.BuildFieldsUpdate(player, i_updateDatas); - i_playerSet.insert(player->GetGUIDLow()); + i_playerSet.insert(player->GetGUID()); } } @@ -3051,11 +2998,22 @@ void WorldObject::GetCreaturesWithEntryInRange(std::list<Creature*>& creatureLis cell.Visit(pair, grid_visitor, *(this->GetMap()), *this, radius); } -uint64 WorldObject::GetTransGUID() const +void WorldObject::AddToObjectUpdate() +{ + GetMap()->AddUpdateObject(this); +} + +void WorldObject::RemoveFromObjectUpdate() +{ + GetMap()->RemoveUpdateObject(this); +} + +ObjectGuid WorldObject::GetTransGUID() const { if (GetTransport()) return GetTransport()->GetGUID(); - return 0; + + return ObjectGuid::Empty; } float WorldObject::GetMapHeight(float x, float y, float z, bool vmap/* = true*/, float distanceToSearch/* = DEFAULT_HEIGHT_SEARCH*/) const diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index aa83c99bef..39eb57c20f 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -13,6 +13,7 @@ #include "GridReference.h" #include "Map.h" #include "ObjectDefines.h" +#include "ObjectGuid.h" #include "UpdateData.h" #include "UpdateMask.h" #include <set> @@ -23,35 +24,6 @@ class ElunaEventProcessor; #endif -enum TypeMask -{ - TYPEMASK_OBJECT = 0x0001, - TYPEMASK_ITEM = 0x0002, - TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004 - TYPEMASK_UNIT = 0x0008, // creature - TYPEMASK_PLAYER = 0x0010, - TYPEMASK_GAMEOBJECT = 0x0020, - TYPEMASK_DYNAMICOBJECT = 0x0040, - TYPEMASK_CORPSE = 0x0080, - TYPEMASK_SEER = TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT -}; - -enum TypeID -{ - TYPEID_OBJECT = 0, - TYPEID_ITEM = 1, - TYPEID_CONTAINER = 2, - TYPEID_UNIT = 3, - TYPEID_PLAYER = 4, - TYPEID_GAMEOBJECT = 5, - TYPEID_DYNAMICOBJECT = 6, - TYPEID_CORPSE = 7 -}; - -#define NUM_CLIENT_OBJECT_TYPES 8 - -uint32 GuidHigh2TypeId(uint32 guid_hi); - enum TempSummonType { TEMPSUMMON_TIMED_OR_DEAD_DESPAWN = 1, // despawns after a specified time OR when the creature disappears @@ -97,7 +69,7 @@ class StaticTransport; class MotionTransport; typedef std::unordered_map<Player*, UpdateData> UpdateDataMapType; -typedef std::unordered_set<uint32> UpdatePlayerSet; +typedef GuidUnorderedSet UpdatePlayerSet; class Object { @@ -109,11 +81,9 @@ public: virtual void AddToWorld(); virtual void RemoveFromWorld(); - [[nodiscard]] uint64 GetGUID() const { return GetUInt64Value(0); } - [[nodiscard]] uint32 GetGUIDLow() const { return GUID_LOPART(GetUInt64Value(0)); } - [[nodiscard]] uint32 GetGUIDMid() const { return GUID_ENPART(GetUInt64Value(0)); } - [[nodiscard]] uint32 GetGUIDHigh() const { return GUID_HIPART(GetUInt64Value(0)); } - [[nodiscard]] const ByteBuffer& GetPackGUID() const { return m_PackGUID; } + [[nodiscard]] static ObjectGuid GetGUID(Object const* o) { return o ? o->GetGUID() : ObjectGuid::Empty; } + [[nodiscard]] ObjectGuid GetGUID() const { return GetGuidValue(OBJECT_FIELD_GUID); } + [[nodiscard]] PackedGuid const& GetPackGUID() const { return m_PackGUID; } [[nodiscard]] uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); } void SetEntry(uint32 entry) { SetUInt32Value(OBJECT_FIELD_ENTRY, entry); } @@ -170,6 +140,12 @@ public: return *(((uint16*)&m_uint32Values[index]) + offset); } + [[nodiscard]] ObjectGuid GetGuidValue(uint16 index) const + { + ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false)); + return *((ObjectGuid*)&(m_uint32Values[index])); + } + void SetInt32Value(uint16 index, int32 value); void SetUInt32Value(uint16 index, uint32 value); void UpdateUInt32Value(uint16 index, uint32 value); @@ -178,11 +154,12 @@ public: void SetByteValue(uint16 index, uint8 offset, uint8 value); void SetUInt16Value(uint16 index, uint8 offset, uint16 value); void SetInt16Value(uint16 index, uint8 offset, int16 value) { SetUInt16Value(index, offset, (uint16)value); } + void SetGuidValue(uint16 index, ObjectGuid value); void SetStatFloatValue(uint16 index, float value); void SetStatInt32Value(uint16 index, int32 value); - bool AddUInt64Value(uint16 index, uint64 value); - bool RemoveUInt64Value(uint16 index, uint64 value); + bool AddGuidValue(uint16 index, ObjectGuid value); + bool RemoveGuidValue(uint16 index, ObjectGuid value); void ApplyModUInt32Value(uint16 index, int32 val, bool apply); void ApplyModInt32Value(uint16 index, int32 val, bool apply); @@ -311,7 +288,7 @@ protected: Object(); void _InitValues(); - void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh); + void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh); [[nodiscard]] std::string _ConcatFields(uint16 startIndex, uint16 size) const; void _LoadIntoDataField(std::string const& data, uint32 startOffset, uint32 count); @@ -338,12 +315,16 @@ protected: uint16 _fieldNotifyFlags; + virtual void AddToObjectUpdate() = 0; + virtual void RemoveFromObjectUpdate() = 0; + void AddToObjectUpdateIfNeeded(); + bool m_objectUpdated; private: bool m_inWorld; - ByteBuffer m_PackGUID; + PackedGuid m_PackGUID; // for output helpfull error messages from asserts [[nodiscard]] bool PrintIndexError(uint32 index, bool set) const; @@ -586,7 +567,7 @@ ByteBuffer& operator >> (ByteBuffer& buf, Position::PositionXYZOStreamer const& struct MovementInfo { // common - uint64 guid{0}; + ObjectGuid guid; uint32 flags{0}; uint16 flags2{0}; Position pos; @@ -597,14 +578,14 @@ struct MovementInfo { void Reset() { - guid = 0; + guid.Clear(); pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f); seat = -1; time = 0; time2 = 0; } - uint64 guid; + ObjectGuid guid; Position pos; int8 seat; uint32 time; @@ -674,6 +655,12 @@ public: Relocate(loc); } + void WorldRelocate(uint32 mapId = MAPID_INVALID, float x = 0.f, float y = 0.f, float z = 0.f, float o = 0.f) + { + m_mapId = mapId; + Relocate(x, y, z, o); + } + [[nodiscard]] uint32 GetMapId() const { return m_mapId; @@ -758,7 +745,7 @@ public: #else virtual void Update(uint32 /*time_diff*/) { }; #endif - void _Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask); + void _Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask); void RemoveFromWorld() override { @@ -928,7 +915,7 @@ public: void PlayDirectSound(uint32 sound_id, Player* target = nullptr); void PlayDirectMusic(uint32 music_id, Player* target = nullptr); - void SendObjectDeSpawnAnim(uint64 guid); + void SendObjectDeSpawnAnim(ObjectGuid guid); virtual void SaveRespawnTime() {} void AddObjectToRemoveList(); @@ -962,6 +949,7 @@ public: [[nodiscard]] Map const* GetBaseMap() const; void SetZoneScript(); + void ClearZoneScript(); [[nodiscard]] ZoneScript* GetZoneScript() const { return m_zoneScript; } TempSummon* SummonCreature(uint32 id, const Position& pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0, SummonPropertiesEntry const* properties = nullptr) const; @@ -993,6 +981,9 @@ public: void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet& player_set) override; void GetCreaturesWithEntryInRange(std::list<Creature*>& creatureList, float radius, uint32 entry); + void AddToObjectUpdate() override; + void RemoveFromObjectUpdate() override; + //relocation and visibility system functions void AddToNotify(uint16 f); void RemoveFromNotify(uint16 f) { m_notifyflags &= ~f; } @@ -1037,7 +1028,7 @@ public: [[nodiscard]] float GetTransOffsetO() const { return m_movementInfo.transport.pos.GetOrientation(); } [[nodiscard]] uint32 GetTransTime() const { return m_movementInfo.transport.time; } [[nodiscard]] int8 GetTransSeat() const { return m_movementInfo.transport.seat; } - [[nodiscard]] virtual uint64 GetTransGUID() const; + [[nodiscard]] virtual ObjectGuid GetTransGUID() const; void SetTransport(Transport* t) { m_transport = t; } MovementInfo m_movementInfo; diff --git a/src/server/game/Entities/Object/ObjectDefines.h b/src/server/game/Entities/Object/ObjectDefines.h index b2690c480a..4603918acc 100644 --- a/src/server/game/Entities/Object/ObjectDefines.h +++ b/src/server/game/Entities/Object/ObjectDefines.h @@ -30,25 +30,7 @@ #define MELEE_RANGE (NOMINAL_MELEE_RANGE - MIN_MELEE_REACH * 2) //center to center for players #define DEFAULT_COLLISION_HEIGHT 2.03128f // Most common value in dbc -enum HighGuid -{ - HIGHGUID_ITEM = 0x4000, // blizz 4000 - HIGHGUID_CONTAINER = 0x4000, // blizz 4000 - HIGHGUID_PLAYER = 0x0000, // blizz 0000 - HIGHGUID_GAMEOBJECT = 0xF110, // blizz F110 - HIGHGUID_TRANSPORT = 0xF120, // blizz F120 (for GAMEOBJECT_TYPE_TRANSPORT) - HIGHGUID_UNIT = 0xF130, // blizz F130 - HIGHGUID_PET = 0xF140, // blizz F140 - HIGHGUID_VEHICLE = 0xF150, // blizz F550 - HIGHGUID_DYNAMICOBJECT = 0xF100, // blizz F100 - HIGHGUID_CORPSE = 0xF101, // blizz F100 - HIGHGUID_MO_TRANSPORT = 0x1FC0, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT) - HIGHGUID_GROUP = 0x1F50, - HIGHGUID_INSTANCE = 0x1F42, // blizz 1F42/1F44/1F44/1F47 -}; - // used for creating values for respawn for example -inline uint64 MAKE_PAIR64(uint32 l, uint32 h); inline uint32 PAIR64_HIPART(uint64 x); inline uint32 PAIR64_LOPART(uint64 x); inline uint16 MAKE_PAIR16(uint8 l, uint8 h); @@ -56,40 +38,6 @@ inline uint32 MAKE_PAIR32(uint16 l, uint16 h); inline uint16 PAIR32_HIPART(uint32 x); inline uint16 PAIR32_LOPART(uint32 x); -inline bool IS_EMPTY_GUID(uint64 guid); -inline bool IS_CREATURE_GUID(uint64 guid); -inline bool IS_PET_GUID(uint64 guid); -inline bool IS_VEHICLE_GUID(uint64 guid); -inline bool IS_CRE_OR_VEH_GUID(uint64 guid); -inline bool IS_CRE_OR_VEH_OR_PET_GUID(uint64 guid); -inline bool IS_PLAYER_GUID(uint64 guid); -inline bool IS_UNIT_GUID(uint64 guid); -inline bool IS_ITEM_GUID(uint64 guid); -inline bool IS_GAMEOBJECT_GUID(uint64 guid); -inline bool IS_DYNAMICOBJECT_GUID(uint64 guid); -inline bool IS_CORPSE_GUID(uint64 guid); -inline bool IS_TRANSPORT_GUID(uint64 guid); -inline bool IS_MO_TRANSPORT_GUID(uint64 guid); -inline bool IS_GROUP_GUID(uint64 guid); - -// l - OBJECT_FIELD_GUID -// e - OBJECT_FIELD_ENTRY for GO (except GAMEOBJECT_TYPE_MO_TRANSPORT) and creatures or UNIT_FIELD_PETNUMBER for pets -// h - OBJECT_FIELD_GUID + 1 -inline uint64 MAKE_NEW_GUID(uint32 l, uint32 e, uint32 h); - -//#define GUID_HIPART(x) (uint32)((uint64(x) >> 52)) & 0x0000FFFF) -inline uint32 GUID_HIPART(uint64 guid); -inline uint32 GUID_ENPART(uint64 x); -inline uint32 GUID_LOPART(uint64 x); - -inline bool IsGuidHaveEnPart(uint64 guid); -inline char const* GetLogNameForGuid(uint64 guid); - -uint64 MAKE_PAIR64(uint32 l, uint32 h) -{ - return uint64(l | (uint64(h) << 32)); -} - uint32 PAIR64_HIPART(uint64 x) { return (uint32)((x >> 32) & UI64LIT(0x00000000FFFFFFFF)); @@ -120,155 +68,4 @@ uint16 PAIR32_LOPART(uint32 x) return (uint16)(x & 0x0000FFFF); } -bool IS_EMPTY_GUID(uint64 guid) -{ - return guid == 0; -} - -bool IS_CREATURE_GUID(uint64 guid) -{ - return GUID_HIPART(guid) == HIGHGUID_UNIT; -} - -bool IS_PET_GUID(uint64 guid) -{ - return GUID_HIPART(guid) == HIGHGUID_PET; -} - -bool IS_VEHICLE_GUID(uint64 guid) -{ - return GUID_HIPART(guid) == HIGHGUID_VEHICLE; -} - -bool IS_CRE_OR_VEH_GUID(uint64 guid) -{ - return IS_CREATURE_GUID(guid) || IS_VEHICLE_GUID(guid); -} - -bool IS_CRE_OR_VEH_OR_PET_GUID(uint64 guid) -{ - return IS_CRE_OR_VEH_GUID(guid) || IS_PET_GUID(guid); -} - -bool IS_PLAYER_GUID(uint64 guid) -{ - return guid != 0 && GUID_HIPART(guid) == HIGHGUID_PLAYER; -} - -bool IS_UNIT_GUID(uint64 guid) -{ - return IS_CRE_OR_VEH_OR_PET_GUID(guid) || IS_PLAYER_GUID(guid); -} - -bool IS_ITEM_GUID(uint64 guid) -{ - return GUID_HIPART(guid) == HIGHGUID_ITEM; -} - -bool IS_GAMEOBJECT_GUID(uint64 guid) -{ - return GUID_HIPART(guid) == HIGHGUID_GAMEOBJECT; -} - -bool IS_DYNAMICOBJECT_GUID(uint64 guid) -{ - return GUID_HIPART(guid) == HIGHGUID_DYNAMICOBJECT; -} - -bool IS_CORPSE_GUID(uint64 guid) -{ - return GUID_HIPART(guid) == HIGHGUID_CORPSE; -} - -bool IS_TRANSPORT_GUID(uint64 guid) -{ - return GUID_HIPART(guid) == HIGHGUID_TRANSPORT; -} - -bool IS_MO_TRANSPORT_GUID(uint64 guid) -{ - return GUID_HIPART(guid) == HIGHGUID_MO_TRANSPORT; -} - -bool IS_GROUP_GUID(uint64 guid) -{ - return GUID_HIPART(guid) == HIGHGUID_GROUP; -} - -uint64 MAKE_NEW_GUID(uint32 l, uint32 e, uint32 h) -{ - return uint64(uint64(l) | (uint64(e) << 24) | (uint64(h) << 48)); -} - -uint32 GUID_HIPART(uint64 guid) -{ - return (uint32)((uint64(guid) >> 48) & 0x0000FFFF); -} - -uint32 GUID_ENPART(uint64 x) -{ - return IsGuidHaveEnPart(x) - ? (uint32)((x >> 24) & UI64LIT(0x0000000000FFFFFF)) - : 0; -} - -uint32 GUID_LOPART(uint64 x) -{ - return IsGuidHaveEnPart(x) - ? (uint32)(x & UI64LIT(0x0000000000FFFFFF)) - : (uint32)(x & UI64LIT(0x00000000FFFFFFFF)); -} - -bool IsGuidHaveEnPart(uint64 guid) -{ - switch (GUID_HIPART(guid)) - { - case HIGHGUID_ITEM: - case HIGHGUID_PLAYER: - case HIGHGUID_DYNAMICOBJECT: - case HIGHGUID_CORPSE: - case HIGHGUID_GROUP: - return false; - case HIGHGUID_GAMEOBJECT: - case HIGHGUID_TRANSPORT: - case HIGHGUID_UNIT: - case HIGHGUID_PET: - case HIGHGUID_VEHICLE: - case HIGHGUID_MO_TRANSPORT: - default: - return true; - } -} - -char const* GetLogNameForGuid(uint64 guid) -{ - switch (GUID_HIPART(guid)) - { - case HIGHGUID_ITEM: - return "item"; - case HIGHGUID_PLAYER: - return guid ? "player" : "none"; - case HIGHGUID_GAMEOBJECT: - return "gameobject"; - case HIGHGUID_TRANSPORT: - return "transport"; - case HIGHGUID_UNIT: - return "creature"; - case HIGHGUID_PET: - return "pet"; - case HIGHGUID_VEHICLE: - return "vehicle"; - case HIGHGUID_DYNAMICOBJECT: - return "dynobject"; - case HIGHGUID_CORPSE: - return "corpse"; - case HIGHGUID_MO_TRANSPORT: - return "mo_transport"; - case HIGHGUID_GROUP: - return "group"; - default: - return "<unknown>"; - } -} - #endif diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp new file mode 100644 index 0000000000..3932040942 --- /dev/null +++ b/src/server/game/Entities/Object/ObjectGuid.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 + * Copyright (C) 2008-2021 TrinityCore <http://www.trinitycore.org/> + */ + +#include "ObjectGuid.h" +#include "Log.h" +#include "World.h" +#include <sstream> +#include <iomanip> + +ObjectGuid const ObjectGuid::Empty = ObjectGuid(); + +char const* ObjectGuid::GetTypeName(HighGuid high) +{ + switch (high) + { + case HighGuid::Item: return "Item"; + case HighGuid::Player: return "Player"; + case HighGuid::GameObject: return "Gameobject"; + case HighGuid::Transport: return "Transport"; + case HighGuid::Unit: return "Creature"; + case HighGuid::Pet: return "Pet"; + case HighGuid::Vehicle: return "Vehicle"; + case HighGuid::DynamicObject: return "DynObject"; + case HighGuid::Corpse: return "Corpse"; + case HighGuid::Mo_Transport: return "MoTransport"; + case HighGuid::Instance: return "InstanceID"; + case HighGuid::Group: return "Group"; + default: + return "<unknown>"; + } +} + +std::string ObjectGuid::ToString() const +{ + std::ostringstream str; + str << "GUID Full: 0x" << std::hex << std::setw(16) << std::setfill('0') << _guid << std::dec; + str << " Type: " << GetTypeName(); + if (HasEntry()) + str << (IsPet() ? " Pet number: " : " Entry: ") << GetEntry() << " "; + + str << " Low: " << GetCounter(); + return str.str(); +} + +ObjectGuid ObjectGuid::Global(HighGuid type, LowType counter) +{ + return ObjectGuid(type, counter); +} + +ObjectGuid ObjectGuid::MapSpecific(HighGuid type, uint32 entry, LowType counter) +{ + return ObjectGuid(type, entry, counter); +} + +ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid) +{ + buf << uint64(guid.GetRawValue()); + return buf; +} + +ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid) +{ + guid.Set(buf.read<uint64>()); + return buf; +} + +ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid) +{ + buf.append(guid._packedGuid); + return buf; +} + +ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid) +{ + buf.readPackGUID(reinterpret_cast<uint64&>(guid.Guid)); + return buf; +} + +void ObjectGuidGeneratorBase::HandleCounterOverflow(HighGuid high) +{ + LOG_ERROR("server", "%s guid overflow!! Can't continue, shutting down server. ", ObjectGuid::GetTypeName(high)); + World::StopNow(ERROR_EXIT_CODE); +} + +#define GUID_TRAIT_INSTANTIATE_GUID( HIGH_GUID ) \ + template class ObjectGuidGenerator< HIGH_GUID >; + +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Container) +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Player) +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::GameObject) +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Transport) +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Unit) +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Pet) +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Vehicle) +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::DynamicObject) +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Mo_Transport) +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Instance) +GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Group) diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h new file mode 100644 index 0000000000..d33c44be39 --- /dev/null +++ b/src/server/game/Entities/Object/ObjectGuid.h @@ -0,0 +1,323 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 + * Copyright (C) 2008-2021 TrinityCore <http://www.trinitycore.org/> + */ + +#ifndef ObjectGuid_h__ +#define ObjectGuid_h__ + +#include "ByteBuffer.h" +#include "Define.h" +#include <deque> +#include <functional> +#include <list> +#include <memory> +#include <set> +#include <type_traits> +#include <vector> +#include <unordered_set> + +enum TypeID +{ + TYPEID_OBJECT = 0, + TYPEID_ITEM = 1, + TYPEID_CONTAINER = 2, + TYPEID_UNIT = 3, + TYPEID_PLAYER = 4, + TYPEID_GAMEOBJECT = 5, + TYPEID_DYNAMICOBJECT = 6, + TYPEID_CORPSE = 7 +}; + +#define NUM_CLIENT_OBJECT_TYPES 8 + +enum TypeMask +{ + TYPEMASK_OBJECT = 0x0001, + TYPEMASK_ITEM = 0x0002, + TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004 + TYPEMASK_UNIT = 0x0008, // creature + TYPEMASK_PLAYER = 0x0010, + TYPEMASK_GAMEOBJECT = 0x0020, + TYPEMASK_DYNAMICOBJECT = 0x0040, + TYPEMASK_CORPSE = 0x0080, + TYPEMASK_SEER = TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT +}; + +enum class HighGuid +{ + Item = 0x4000, // blizz 4000 + Container = 0x4000, // blizz 4000 + Player = 0x0000, // blizz 0000 + GameObject = 0xF110, // blizz F110 + Transport = 0xF120, // blizz F120 (for GAMEOBJECT_TYPE_TRANSPORT) + Unit = 0xF130, // blizz F130 + Pet = 0xF140, // blizz F140 + Vehicle = 0xF150, // blizz F550 + DynamicObject = 0xF100, // blizz F100 + Corpse = 0xF101, // blizz F100 + Mo_Transport = 0x1FC0, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT) + Instance = 0x1F40, // blizz 1F40 + Group = 0x1F50, +}; + +template<HighGuid high> +struct ObjectGuidTraits +{ + static bool const Global = false; + static bool const MapSpecific = false; +}; + +#define GUID_TRAIT_GLOBAL(highguid) \ + template<> struct ObjectGuidTraits<highguid> \ + { \ + static bool const Global = true; \ + static bool const MapSpecific = false; \ + }; + +#define GUID_TRAIT_MAP_SPECIFIC(highguid) \ + template<> struct ObjectGuidTraits<highguid> \ + { \ + static bool const Global = false; \ + static bool const MapSpecific = true; \ + }; + +GUID_TRAIT_GLOBAL(HighGuid::Player) +GUID_TRAIT_GLOBAL(HighGuid::Item) +GUID_TRAIT_GLOBAL(HighGuid::Mo_Transport) +GUID_TRAIT_GLOBAL(HighGuid::Group) +GUID_TRAIT_GLOBAL(HighGuid::Instance) +GUID_TRAIT_MAP_SPECIFIC(HighGuid::Transport) +GUID_TRAIT_MAP_SPECIFIC(HighGuid::Unit) +GUID_TRAIT_MAP_SPECIFIC(HighGuid::Vehicle) +GUID_TRAIT_MAP_SPECIFIC(HighGuid::Pet) +GUID_TRAIT_MAP_SPECIFIC(HighGuid::GameObject) +GUID_TRAIT_MAP_SPECIFIC(HighGuid::DynamicObject) +GUID_TRAIT_MAP_SPECIFIC(HighGuid::Corpse) + +class ObjectGuid; +class PackedGuid; + +struct PackedGuidReader +{ + explicit PackedGuidReader(ObjectGuid& guid) : Guid(guid) { } + ObjectGuid& Guid; +}; + +class ObjectGuid +{ + public: + static ObjectGuid const Empty; + + typedef uint32 LowType; + + template<HighGuid type> + static typename std::enable_if<ObjectGuidTraits<type>::Global, ObjectGuid>::type Create(LowType counter) { return Global(type, counter); } + + template<HighGuid type> + static typename std::enable_if<ObjectGuidTraits<type>::MapSpecific, ObjectGuid>::type Create(uint32 entry, LowType counter) { return MapSpecific(type, entry, counter); } + + ObjectGuid() : _guid(0) { } + explicit ObjectGuid(uint64 guid) : _guid(guid) { } + ObjectGuid(HighGuid hi, uint32 entry, LowType counter) : _guid(counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48) : 0) { } + ObjectGuid(HighGuid hi, LowType counter) : _guid(counter ? uint64(counter) | (uint64(hi) << 48) : 0) { } + + PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); } + + void Set(uint64 guid) { _guid = guid; } + void Clear() { _guid = 0; } + + PackedGuid WriteAsPacked() const; + + uint64 GetRawValue() const { return _guid; } + HighGuid GetHigh() const { return HighGuid((_guid >> 48) & 0x0000FFFF); } + uint32 GetEntry() const { return HasEntry() ? uint32((_guid >> 24) & UI64LIT(0x0000000000FFFFFF)) : 0; } + LowType GetCounter() const + { + return HasEntry() + ? LowType(_guid & UI64LIT(0x0000000000FFFFFF)) + : LowType(_guid & UI64LIT(0x00000000FFFFFFFF)); + } + + static LowType GetMaxCounter(HighGuid high) + { + return HasEntry(high) + ? LowType(0x00FFFFFF) + : LowType(0xFFFFFFFF); + } + + ObjectGuid::LowType GetMaxCounter() const { return GetMaxCounter(GetHigh()); } + + bool IsEmpty() const { return _guid == 0; } + bool IsCreature() const { return GetHigh() == HighGuid::Unit; } + bool IsPet() const { return GetHigh() == HighGuid::Pet; } + bool IsVehicle() const { return GetHigh() == HighGuid::Vehicle; } + bool IsCreatureOrPet() const { return IsCreature() || IsPet(); } + bool IsCreatureOrVehicle() const { return IsCreature() || IsVehicle(); } + bool IsAnyTypeCreature() const { return IsCreature() || IsPet() || IsVehicle(); } + bool IsPlayer() const { return !IsEmpty() && GetHigh() == HighGuid::Player; } + bool IsUnit() const { return IsAnyTypeCreature() || IsPlayer(); } + bool IsItem() const { return GetHigh() == HighGuid::Item; } + bool IsGameObject() const { return GetHigh() == HighGuid::GameObject; } + bool IsDynamicObject() const { return GetHigh() == HighGuid::DynamicObject; } + bool IsCorpse() const { return GetHigh() == HighGuid::Corpse; } + bool IsTransport() const { return GetHigh() == HighGuid::Transport; } + bool IsMOTransport() const { return GetHigh() == HighGuid::Mo_Transport; } + bool IsAnyTypeGameObject() const { return IsGameObject() || IsTransport() || IsMOTransport(); } + bool IsInstance() const { return GetHigh() == HighGuid::Instance; } + bool IsGroup() const { return GetHigh() == HighGuid::Group; } + + static TypeID GetTypeId(HighGuid high) + { + switch (high) + { + case HighGuid::Item: return TYPEID_ITEM; + //case HighGuid::Container: return TYPEID_CONTAINER; HighGuid::Container == HighGuid::Item currently + case HighGuid::Unit: return TYPEID_UNIT; + case HighGuid::Pet: return TYPEID_UNIT; + case HighGuid::Player: return TYPEID_PLAYER; + case HighGuid::GameObject: return TYPEID_GAMEOBJECT; + case HighGuid::DynamicObject: return TYPEID_DYNAMICOBJECT; + case HighGuid::Corpse: return TYPEID_CORPSE; + case HighGuid::Mo_Transport: return TYPEID_GAMEOBJECT; + case HighGuid::Vehicle: return TYPEID_UNIT; + // unknown + case HighGuid::Instance: + case HighGuid::Group: + default: return TYPEID_OBJECT; + } + } + + TypeID GetTypeId() const { return GetTypeId(GetHigh()); } + + operator bool() const { return !IsEmpty(); } + bool operator!() const { return !(bool(*this)); } + 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 GetRawValue() <= guid.GetRawValue(); } + + static char const* GetTypeName(HighGuid high); + char const* GetTypeName() const { return !IsEmpty() ? GetTypeName(GetHigh()) : "None"; } + std::string ToString() const; + + private: + static bool HasEntry(HighGuid high) + { + switch (high) + { + case HighGuid::Item: + case HighGuid::Player: + case HighGuid::DynamicObject: + case HighGuid::Corpse: + case HighGuid::Mo_Transport: + case HighGuid::Instance: + case HighGuid::Group: + return false; + case HighGuid::GameObject: + case HighGuid::Transport: + case HighGuid::Unit: + case HighGuid::Pet: + case HighGuid::Vehicle: + default: + return true; + } + } + + bool HasEntry() const { return HasEntry(GetHigh()); } + + static ObjectGuid Global(HighGuid type, LowType counter); + static ObjectGuid MapSpecific(HighGuid type, uint32 entry, LowType counter); + + explicit ObjectGuid(uint32 const&) = delete; // no implementation, used to catch wrong type assignment + ObjectGuid(HighGuid, uint32, uint64 counter) = delete; // no implementation, used to catch wrong type assignment + ObjectGuid(HighGuid, uint64 counter) = delete; // no implementation, used to catch wrong type assignment + + // used to catch wrong type assignment + operator int64() const = delete; + + uint64 _guid; +}; + +// Some Shared defines +typedef std::set<ObjectGuid> GuidSet; +typedef std::list<ObjectGuid> GuidList; +typedef std::deque<ObjectGuid> GuidDeque; +typedef std::vector<ObjectGuid> GuidVector; +typedef std::unordered_set<ObjectGuid> GuidUnorderedSet; + +// minimum buffer size for packed guid is 9 bytes +#define PACKED_GUID_MIN_BUFFER_SIZE 9 + +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()); } + + void Set(uint64 guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid); } + void Set(ObjectGuid guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid.GetRawValue()); } + + std::size_t size() const { return _packedGuid.size(); } + + private: + ByteBuffer _packedGuid; +}; + +class ObjectGuidGeneratorBase +{ +public: + ObjectGuidGeneratorBase(ObjectGuid::LowType start = 1) : _nextGuid(start) { } + + virtual void Set(ObjectGuid::LowType val) { _nextGuid = val; } + virtual ObjectGuid::LowType Generate() = 0; + ObjectGuid::LowType GetNextAfterMaxUsed() const { return _nextGuid; } + virtual ~ObjectGuidGeneratorBase() { } + +protected: + static void HandleCounterOverflow(HighGuid high); + ObjectGuid::LowType _nextGuid; +}; + +template<HighGuid high> +class ObjectGuidGenerator : public ObjectGuidGeneratorBase +{ +public: + explicit ObjectGuidGenerator(ObjectGuid::LowType start = 1) : ObjectGuidGeneratorBase(start) { } + + ObjectGuid::LowType Generate() override + { + if (_nextGuid >= ObjectGuid::GetMaxCounter(high) - 1) + HandleCounterOverflow(high); + + return _nextGuid++; + } +}; + +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); + +inline PackedGuid ObjectGuid::WriteAsPacked() const { return PackedGuid(*this); } + +namespace std +{ + template<> + struct hash<ObjectGuid> + { + public: + size_t operator()(ObjectGuid const& key) const + { + return std::hash<uint64>()(key.GetRawValue()); + } + }; +} + +#endif // ObjectGuid_h__ diff --git a/src/server/game/Entities/Object/Updates/UpdateData.cpp b/src/server/game/Entities/Object/Updates/UpdateData.cpp index ac32ec67a5..d0bb1fb143 100644 --- a/src/server/game/Entities/Object/Updates/UpdateData.cpp +++ b/src/server/game/Entities/Object/Updates/UpdateData.cpp @@ -18,7 +18,7 @@ UpdateData::UpdateData() : m_blockCount(0) m_outOfRangeGUIDs.reserve(15); } -void UpdateData::AddOutOfRangeGUID(uint64 guid) +void UpdateData::AddOutOfRangeGUID(ObjectGuid guid) { m_outOfRangeGUIDs.push_back(guid); } @@ -104,9 +104,9 @@ bool UpdateData::BuildPacket(WorldPacket* packet) buf << (uint8) UPDATETYPE_OUT_OF_RANGE_OBJECTS; buf << (uint32) m_outOfRangeGUIDs.size(); - for (std::vector<uint64>::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i) + for (ObjectGuid const guid : m_outOfRangeGUIDs) { - buf.appendPackGUID(*i); + buf << guid.WriteAsPacked(); } } diff --git a/src/server/game/Entities/Object/Updates/UpdateData.h b/src/server/game/Entities/Object/Updates/UpdateData.h index ea8e30d804..be2f0198c1 100644 --- a/src/server/game/Entities/Object/Updates/UpdateData.h +++ b/src/server/game/Entities/Object/Updates/UpdateData.h @@ -8,6 +8,7 @@ #define __UPDATEDATA_H #include "ByteBuffer.h" +#include "ObjectGuid.h" class WorldPacket; @@ -41,7 +42,7 @@ class UpdateData public: UpdateData(); - void AddOutOfRangeGUID(uint64 guid); + void AddOutOfRangeGUID(ObjectGuid guid); void AddUpdateBlock(const ByteBuffer& block); void AddUpdateBlock(const UpdateData& block); bool BuildPacket(WorldPacket* packet); @@ -50,7 +51,7 @@ public: protected: uint32 m_blockCount; - std::vector<uint64> m_outOfRangeGUIDs; + GuidVector m_outOfRangeGUIDs; ByteBuffer m_data; void Compress(void* dst, uint32* dst_size, void* src, int src_size); diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 5e98764746..ad8bc379dd 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -24,7 +24,7 @@ #include "WorldPacket.h" #include "WorldSession.h" -Pet::Pet(Player* owner, PetType type) : Guardian(nullptr, owner ? owner->GetGUID() : 0, true), +Pet::Pet(Player* owner, PetType type) : Guardian(nullptr, owner ? owner->GetGUID() : ObjectGuid::Empty, true), m_usedTalentCount(0), m_removed(false), m_owner(owner), m_happinessTimer(PET_LOSE_HAPPINES_INTERVAL), m_petType(type), m_duration(0), m_auraRaidUpdateMask(0), m_loading(false), m_petRegenTimer(PET_FOCUS_REGEN_INTERVAL), m_declinedname(nullptr), m_tempspellTarget(nullptr), m_tempoldTarget(nullptr), m_tempspellIsPositive(false), m_tempspell(0), asynchLoadType(PET_LOAD_DEFAULT) @@ -53,14 +53,14 @@ void Pet::AddToWorld() if (!IsInWorld()) { ///- Register the pet for guid lookup - sObjectAccessor->AddObject(this); + GetMap()->GetObjectsStore().Insert<Pet>(GetGUID(), this); Unit::AddToWorld(); Motion_Initialize(); AIM_Initialize(); } // pussywizard: apply ICC buff to pets - if (IS_PLAYER_GUID(GetOwnerGUID()) && GetMapId() == 631 && FindMap() && FindMap()->ToInstanceMap() && FindMap()->ToInstanceMap()->GetInstanceScript() && FindMap()->ToInstanceMap()->GetInstanceScript()->GetData(251 /*DATA_BUFF_AVAILABLE*/)) + if (GetOwnerGUID().IsPlayer() && GetMapId() == 631 && FindMap() && FindMap()->ToInstanceMap() && FindMap()->ToInstanceMap()->GetInstanceScript() && FindMap()->ToInstanceMap()->GetInstanceScript()->GetData(251 /*DATA_BUFF_AVAILABLE*/)) if (Unit* owner = GetOwner()) if (Player* plr = owner->ToPlayer()) { @@ -91,14 +91,14 @@ void Pet::RemoveFromWorld() { ///- Don't call the function for Creature, normal mobs + totems go in a different storage Unit::RemoveFromWorld(); - sObjectAccessor->RemoveObject(this); + GetMap()->GetObjectsStore().Remove<Pet>(GetGUID()); } } SpellCastResult Pet::TryLoadFromDB(Player* owner, bool current /*= false*/, PetType mandatoryPetType /*= MAX_PET_TYPE*/) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT); - stmt->setUInt32(0, owner->GetGUIDLow()); + stmt->setUInt32(0, owner->GetGUID().GetCounter()); stmt->setUInt8(1, uint8(current ? PET_SAVE_AS_CURRENT : PET_SAVE_NOT_IN_SLOT)); PreparedQueryResult result = CharacterDatabase.AsyncQuery(stmt); @@ -157,28 +157,28 @@ bool Pet::LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry, ui if (owner->getClass() == CLASS_DEATH_KNIGHT && !owner->CanSeeDKPet()) // DK Pet exception return false; - uint32 ownerid = owner->GetGUIDLow(); + ObjectGuid::LowType ownerGuid = owner->GetGUID().GetCounter(); PreparedStatement* stmt; if (petnumber) { // Known petnumber entry stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY); - stmt->setUInt32(0, ownerid); + stmt->setUInt32(0, ownerGuid); stmt->setUInt32(1, petnumber); } else if (current) { // Current pet (slot 0) stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT); - stmt->setUInt32(0, ownerid); + stmt->setUInt32(0, ownerGuid); stmt->setUInt8(1, uint8(PET_SAVE_AS_CURRENT)); } else if (petentry) { // known petentry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets) stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT_2); - stmt->setUInt32(0, ownerid); + stmt->setUInt32(0, ownerGuid); stmt->setUInt32(1, petentry); stmt->setUInt8(2, uint8(PET_SAVE_AS_CURRENT)); stmt->setUInt8(3, uint8(PET_SAVE_LAST_STABLE_SLOT)); @@ -187,13 +187,14 @@ bool Pet::LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry, ui { // Any current or other non-stabled pet (for hunter "call pet") stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_SLOT); - stmt->setUInt32(0, ownerid); + stmt->setUInt32(0, ownerGuid); stmt->setUInt8(1, uint8(PET_SAVE_AS_CURRENT)); stmt->setUInt8(2, uint8(PET_SAVE_LAST_STABLE_SLOT)); } if (AsynchPetSummon* info = owner->GetSession()->_loadPetFromDBFirstCallback.GetSecondParam()) delete info; + owner->GetSession()->_loadPetFromDBFirstCallback.Reset(); owner->GetSession()->_loadPetFromDBFirstCallback.SetFirstParam(asynchLoadType); owner->GetSession()->_loadPetFromDBFirstCallback.SetSecondParam(info); @@ -204,7 +205,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry, ui void Pet::SavePetToDB(PetSaveMode mode, bool logout) { // not save not player pets - if (!IS_PLAYER_GUID(GetOwnerGUID())) + if (!GetOwnerGUID().IsPlayer()) return; // dont allow to save pet when it is loaded, possibly bugs action bar!, save only fully controlled creature @@ -242,7 +243,7 @@ void Pet::SavePetToDB(PetSaveMode mode, bool logout) // current/stable/not_in_slot if (mode >= PET_SAVE_AS_CURRENT) { - uint32 ownerLowGUID = GUID_LOPART(GetOwnerGUID()); + ObjectGuid::LowType ownerLowGUID = GetOwnerGUID().GetCounter(); trans = CharacterDatabase.BeginTransaction(); // remove current data @@ -306,7 +307,7 @@ void Pet::SavePetToDB(PetSaveMode mode, bool logout) } } -void Pet::DeleteFromDB(uint32 guidlow) +void Pet::DeleteFromDB(ObjectGuid::LowType guidlow) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -644,8 +645,8 @@ bool Pet::CreateBaseAtCreature(Creature* creature) if (!IsPositionValid()) { - LOG_ERROR("server", "Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)", - GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY()); + LOG_ERROR("server", "Pet %s not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)", + GetGUID().ToString().c_str(), GetPositionX(), GetPositionY()); return false; } @@ -684,7 +685,7 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phas #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("entities.pet", "Pet::CreateBaseForTamed"); #endif - uint32 guid = sObjectMgr->GenerateLowGuid(HIGHGUID_PET); + ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Pet>(); uint32 pet_number = sObjectMgr->GeneratePetNumber(); if (!Create(guid, map, phaseMask, cinfo->Entry, pet_number)) return false; @@ -1260,7 +1261,7 @@ void Pet::_SaveSpells(SQLTransaction& trans) void Pet::_LoadAuras(PreparedQueryResult result, uint32 timediff) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.pet", "Loading auras for pet %u", GetGUIDLow()); + LOG_DEBUG("entities.pet", "Loading auras for pet %s", GetGUID().ToString().c_str()); #endif if (result) @@ -1270,7 +1271,7 @@ void Pet::_LoadAuras(PreparedQueryResult result, uint32 timediff) int32 damage[3]; int32 baseDamage[3]; Field* fields = result->Fetch(); - uint64 caster_guid = fields[0].GetUInt64(); + ObjectGuid caster_guid = ObjectGuid(fields[0].GetUInt64()); // nullptr guid stored - pet is the caster of the spell - see Pet::_SaveAuras if (!caster_guid) caster_guid = GetGUID(); @@ -1397,13 +1398,13 @@ void Pet::_SaveAuras(SQLTransaction& trans, bool logout) } // don't save guid of caster in case we are caster of the spell - guid for pet is generated every pet load, so it won't match saved guid anyways - uint64 casterGUID = (itr->second->GetCasterGUID() == GetGUID()) ? 0 : itr->second->GetCasterGUID(); + ObjectGuid casterGUID = (itr->second->GetCasterGUID() == GetGUID()) ? ObjectGuid::Empty : itr->second->GetCasterGUID(); uint8 index = 0; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_AURA); stmt->setUInt32(index++, m_charmInfo->GetPetNumber()); - stmt->setUInt64(index++, casterGUID); + stmt->setUInt64(index++, casterGUID.GetRawValue()); stmt->setUInt32(index++, itr->second->GetId()); stmt->setUInt8(index++, effMask); stmt->setUInt8(index++, recalculateMask); @@ -1802,7 +1803,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= nullptr*/) // xinef: zomg! sync query PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET); - stmt->setUInt32(0, owner->GetGUIDLow()); + stmt->setUInt32(0, owner->GetGUID().GetCounter()); stmt->setUInt32(1, except_petnumber); PreparedQueryResult resultPets = CharacterDatabase.Query(stmt); @@ -1812,7 +1813,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= nullptr*/) // xinef: zomg! sync query stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SPELL_LIST); - stmt->setUInt32(0, owner->GetGUIDLow()); + stmt->setUInt32(0, owner->GetGUID().GetCounter()); stmt->setUInt32(1, except_petnumber); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -1968,15 +1969,16 @@ bool Pet::IsPermanentPetFor(Player* owner) const } } -bool Pet::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number) +bool Pet::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number) { ASSERT(map); SetMap(map); SetPhaseMask(phaseMask, false); - Object::_Create(guidlow, pet_number, HIGHGUID_PET); - m_DBTableGuid = guidlow; + Object::_Create(guidlow, pet_number, HighGuid::Pet); + + m_spawnId = guidlow; m_originalEntry = Entry; if (!InitEntry(Entry)) @@ -2184,7 +2186,7 @@ void Pet::HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 as Map* map = player->GetMap(); uint32 pet_number = sObjectMgr->GeneratePetNumber(); - if (!pet->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PET), map, player->GetPhaseMask(), info->m_entry, pet_number)) + if (!pet->Create(map->GenerateLowGuid<HighGuid::Pet>(), map, player->GetPhaseMask(), info->m_entry, pet_number)) { LOG_ERROR("server", "no such creature entry %u", info->m_entry); delete pet; @@ -2247,7 +2249,7 @@ void Pet::HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 as // we are almost at home... if (asynchLoadType == PET_LOAD_SUMMON_PET) { - Unit* caster = ObjectAccessor::GetObjectInMap(info->m_casterGUID, map, (Unit*)nullptr); + Unit* caster = ObjectAccessor::GetUnit(*player, info->m_casterGUID); if (!caster) caster = player; @@ -2282,7 +2284,7 @@ void Pet::HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 as pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); pet->setDeathState(ALIVE); pet->ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~(UNIT_STATE_POSSESSED))); // xinef: just in case - pet->SetHealth(pet->CountPctFromMaxHealth(uint32(info->m_casterGUID))); // damage for this effect is saved in caster guid, dont create next variable... + pet->SetHealth(pet->CountPctFromMaxHealth(uint32(info->m_casterGUID.GetRawValue()))); // damage for this effect is saved in caster guid, dont create next variable... //AIM_Initialize(); //owner->PetSpellInitialize(); @@ -2338,7 +2340,7 @@ void Pet::RemoveSpellCooldown(uint32 spell_id, bool update /* = false */) { WorldPacket data(SMSG_CLEAR_COOLDOWN, 4 + 8); data << uint32(spell_id); - data << uint64(GetGUID()); + data << GetGUID(); playerOwner->SendDirectMessage(&data); } } diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index 7baeef7b7a..62888fc175 100644 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -24,7 +24,7 @@ struct PetSpell class AsynchPetSummon { public: - AsynchPetSummon(uint32 entry, Position position, PetType petType, uint32 duration, uint32 createdBySpell, uint64 casterGUID) : + AsynchPetSummon(uint32 entry, Position position, PetType petType, uint32 duration, uint32 createdBySpell, ObjectGuid casterGUID) : m_entry(entry), pos(position), m_petType(petType), m_duration(duration), m_createdBySpell(createdBySpell), m_casterGUID(casterGUID) { } @@ -32,7 +32,7 @@ public: Position pos; PetType m_petType; uint32 m_duration, m_createdBySpell; - uint64 m_casterGUID; + ObjectGuid m_casterGUID; }; typedef std::unordered_map<uint32, PetSpell> PetSpellMap; @@ -58,7 +58,7 @@ public: bool IsPermanentPetFor(Player* owner) const; // pet have tab in character windows and set UNIT_FIELD_PETNUMBER - bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number); + bool Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number); bool CreateBaseAtCreature(Creature* creature); bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner); bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask); @@ -67,7 +67,7 @@ public: bool isBeingLoaded() const override { return m_loading;} void SavePetToDB(PetSaveMode mode, bool logout); void Remove(PetSaveMode mode, bool returnreagent = false); - static void DeleteFromDB(uint32 guidlow); + static void DeleteFromDB(ObjectGuid::LowType guidlow); void setDeathState(DeathState s, bool despawn = false) override; // overwrite virtual Creature::setDeathState and Unit::setDeathState void Update(uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 22effef14a..2f15e60c6d 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -334,7 +334,7 @@ Item* TradeData::GetItem(TradeSlots slot) const return m_items[slot] ? m_player->GetItemByGuid(m_items[slot]) : nullptr; } -bool TradeData::HasItem(uint64 itemGuid) const +bool TradeData::HasItem(ObjectGuid itemGuid) const { for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i) if (m_items[i] == itemGuid) @@ -343,7 +343,7 @@ bool TradeData::HasItem(uint64 itemGuid) const return false; } -TradeSlots TradeData::GetTradeSlotForItem(uint64 itemGuid) const +TradeSlots TradeData::GetTradeSlotForItem(ObjectGuid itemGuid) const { for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i) if (m_items[i] == itemGuid) @@ -359,7 +359,7 @@ Item* TradeData::GetSpellCastItem() const void TradeData::SetItem(TradeSlots slot, Item* item) { - uint64 itemGuid = item ? item->GetGUID() : 0; + ObjectGuid itemGuid = item ? item->GetGUID() : ObjectGuid::Empty; if (m_items[slot] == itemGuid) return; @@ -381,7 +381,7 @@ void TradeData::SetItem(TradeSlots slot, Item* item) void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= nullptr*/) { - uint64 itemGuid = castItem ? castItem->GetGUID() : 0; + ObjectGuid itemGuid = castItem ? castItem->GetGUID() : ObjectGuid::Empty; if (m_spell == spell_id && m_spellCastItem == itemGuid) return; @@ -486,7 +486,7 @@ KillRewarder::KillRewarder(Player* killer, Unit* victim, bool isBattleGround) : if (victim->GetTypeId() == TYPEID_PLAYER) _isPvP = true; // or if its owned by player and its not a vehicle - else if (IS_PLAYER_GUID(victim->GetCharmerOrOwnerGUID())) + else if (victim->GetCharmerOrOwnerGUID().IsPlayer()) _isPvP = !victim->IsVehicle(); _InitGroupData(); @@ -705,7 +705,6 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this) #pragma warning(default:4355) #endif - m_drwGUID = 0; m_speakTime = 0; m_speakCount = 0; @@ -716,7 +715,6 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this) m_session = session; - m_divider = 0; m_ingametime = 0; m_ExtraFlags = 0; @@ -728,9 +726,6 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this) if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity())) SetAcceptWhispers(true); - m_lootGuid = 0; - - m_comboTarget = 0; m_comboPoints = 0; m_usedTalentCount = 0; @@ -1033,14 +1028,14 @@ void Player::CleanupsBeforeDelete(bool finalCleanup) Unit::CleanupsBeforeDelete(finalCleanup); } -bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo) +bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo) { - //FIXME: outfitId not used in player creating + // FIXME: outfitId not used in player creating // TODO: need more checks against packet modifications // should check that skin, face, hair* are valid via DBC per race/class // also do it in Player::BuildEnumData, Player::LoadFromDB - Object::_Create(guidlow, 0, HIGHGUID_PLAYER); + Object::_Create(guidlow, 0, HighGuid::Player); m_name = createInfo->Name; @@ -1350,7 +1345,7 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) Unit::DealDamageMods(this, damage, &absorb); WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21)); - data << uint64(GetGUID()); + data << GetGUID(); data << uint8(type != DAMAGE_FALL_TO_VOID ? type : DAMAGE_FALL); data << uint32(damage); data << uint32(absorb); @@ -1577,7 +1572,7 @@ void Player::SetDrunkValue(uint8 newDrunkValue, uint32 itemId /*= 0*/) return; WorldPacket data(SMSG_CROSSED_INEBRIATION_THRESHOLD, (8 + 4 + 4)); - data << uint64(GetGUID()); + data << GetGUID(); data << uint32(newDrunkenState); data << uint32(itemId); SendMessageToSet(&data, true); @@ -1790,7 +1785,8 @@ void Player::Update(uint32 p_time) if (!IsPositionValid()) // pussywizard: will crash below at eg. GetZoneAndAreaId { - LOG_INFO("misc", "Player::Update - invalid position (%.1f, %.1f, %.1f)! Map: %u, MapId: %u, GUID: %u", GetPositionX(), GetPositionY(), GetPositionZ(), (FindMap() ? FindMap()->GetId() : 0), GetMapId(), GetGUIDLow()); + LOG_INFO("misc", "Player::Update - invalid position (%.1f, %.1f, %.1f)! Map: %u, MapId: %u, %s", + GetPositionX(), GetPositionY(), GetPositionZ(), (FindMap() ? FindMap()->GetId() : 0), GetMapId(), GetGUID().ToString().c_str()); GetSession()->KickPlayer("Invalid position"); return; } @@ -1963,7 +1959,7 @@ void Player::setDeathState(DeathState s, bool /*despawn = false*/) { if (!cur) { - LOG_ERROR("server", "setDeathState: attempt to kill a dead player %s(%d)", GetName().c_str(), GetGUIDLow()); + LOG_ERROR("server", "setDeathState: attempt to kill a dead player %s (%s)", GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -2038,24 +2034,26 @@ bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data) Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guidLow = fields[0].GetUInt32(); uint8 plrRace = fields[2].GetUInt8(); uint8 plrClass = fields[3].GetUInt8(); uint8 gender = fields[4].GetUInt8(); + ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(guidLow); + PlayerInfo const* info = sObjectMgr->GetPlayerInfo(plrRace, plrClass); if (!info) { - LOG_ERROR("server", "Player %u has incorrect race/class pair. Don't build enum.", guid); + LOG_ERROR("server", "Player %s has incorrect race/class pair. Don't build enum.", guid.ToString().c_str()); return false; } else if (!IsValidGender(gender)) { - LOG_ERROR("server", "Player (%u) has incorrect gender (%u), don't build enum.", guid, gender); + LOG_ERROR("server", "Player (%s) has incorrect gender (%u), don't build enum.", guid.ToString().c_str(), gender); return false; } - *data << uint64(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); + *data << guid; *data << fields[1].GetString(); // name *data << uint8(plrRace); // race *data << uint8(plrClass); // class @@ -2088,6 +2086,8 @@ bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data) *data << uint32(fields[16].GetUInt32()); // guild id + if (atLoginFlags & AT_LOGIN_RESURRECT) + playerFlags &= ~PLAYER_FLAGS_GHOST; if (playerFlags & PLAYER_FLAGS_HIDE_HELM) charFlags |= CHARACTER_FLAG_HIDE_HELM; if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK) @@ -2213,7 +2213,7 @@ uint8 Player::GetChatTag() const void Player::SendTeleportAckPacket() { WorldPacket data(MSG_MOVE_TELEPORT_ACK, 41); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(0); // this value increments every time BuildMovementPacket(&data); GetSession()->SendPacket(&data); @@ -2223,14 +2223,14 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati { if (!MapManager::IsValidMapCoord(mapid, x, y, z, orientation)) { - LOG_ERROR("server", "TeleportTo: invalid map (%d) or invalid coordinates (X: %f, Y: %f, Z: %f, O: %f) given when teleporting player (GUID: %u, name: %s, map: %d, X: %f, Y: %f, Z: %f, O: %f).", - mapid, x, y, z, orientation, GetGUIDLow(), GetName().c_str(), GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + LOG_ERROR("server", "TeleportTo: invalid map (%d) or invalid coordinates (X: %f, Y: %f, Z: %f, O: %f) given when teleporting player (%s, name: %s, map: %d, X: %f, Y: %f, Z: %f, O: %f).", + mapid, x, y, z, orientation, GetGUID().ToString().c_str(), GetName().c_str(), GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); return false; } if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()) && DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, mapid, this)) { - LOG_ERROR("server", "Player (GUID: %u, name: %s) tried to enter a forbidden map %u", GetGUIDLow(), GetName().c_str(), mapid); + LOG_ERROR("server", "Player (%s, name: %s) tried to enter a forbidden map %u", GetGUID().ToString().c_str(), GetName().c_str(), mapid); SendTransferAborted(mapid, TRANSFER_ABORT_MAP_NOT_ALLOWED); return false; } @@ -2315,7 +2315,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // The player was ported to another map and loses the duel immediately. // We have to perform this check before the teleport, otherwise the // ObjectAccessor won't find the flag. - if (duel && GetMapId() != mapid && GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER))) + if (duel && GetMapId() != mapid && GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER))) DuelComplete(DUEL_FLED); if (!sScriptMgr->OnBeforePlayerTeleport(this, mapid, x, y, z, orientation, options, target)) @@ -2401,7 +2401,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati return true; } - SetSelection(0); + SetSelection(ObjectGuid::Empty); CombatStop(); @@ -2599,17 +2599,13 @@ void Player::RemoveFromWorld() UnsummonPetTemporaryIfAny(); ClearComboPoints(); // pussywizard: crashfix ClearComboPointHolders(); // pussywizard: crashfix - if (uint64 lguid = GetLootGUID()) // pussywizard: crashfix + if (ObjectGuid lguid = GetLootGUID()) // pussywizard: crashfix m_session->DoLootRelease(lguid); sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId); sBattlefieldMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId); } - ///- Do not add/remove the player from the object storage - ///- It will crash when updating the ObjectAccessor - ///- The player should only be removed when logging out - Unit::RemoveFromWorld(); - + // Remove items from world before self - player must be found in Item::RemoveFromObjectUpdate for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) { if (m_items[i]) @@ -2619,6 +2615,11 @@ void Player::RemoveFromWorld() for (ItemMap::iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter) iter->second->RemoveFromWorld(); + ///- Do not add/remove the player from the object storage + ///- It will crash when updating the ObjectAccessor + ///- The player should only be removed when logging out + Unit::RemoveFromWorld(); + if (m_uint32Values) { if (WorldObject* viewpoint = GetViewpoint()) @@ -2936,7 +2937,7 @@ bool Player::CanInteractWithQuestGiver(Object* questGiver) return false; } -Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask) +Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask) { // unit checks if (!guid) @@ -2993,7 +2994,7 @@ Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask) return creature; } -GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const +GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, GameobjectTypes type) const { if (GameObject* go = GetMap()->GetGameObject(guid)) { @@ -3003,7 +3004,8 @@ GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes return go; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("maps", "IsGameObjectOfTypeInRange: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal 10 is allowed)", go->GetGOInfo()->name.c_str(), go->GetGUIDLow(), GetName().c_str(), GetGUIDLow(), go->GetDistance(this)); + LOG_DEBUG("maps", "IsGameObjectOfTypeInRange: GameObject '%s' [%s] is too far away from player %s [%s] to be used by him (distance=%f, maximal 10 is allowed)", + go->GetGOInfo()->name.c_str(), go->GetGUID().ToString().c_str(), GetName().c_str(), GetGUID().ToString().c_str(), go->GetDistance(this)); #endif } } @@ -3150,7 +3152,7 @@ void Player::SetGMVisible(bool on) if (on) { - if (HasAura(VISUAL_AURA, 0)) + if (HasAura(VISUAL_AURA)) RemoveAurasDueToSpell(VISUAL_AURA); m_ExtraFlags &= ~PLAYER_EXTRA_GM_INVISIBLE; //remove flag @@ -3215,7 +3217,7 @@ void Player::UninviteFromGroup() } } -void Player::RemoveFromGroup(Group* group, uint64 guid, RemoveMethod method /* = GROUP_REMOVEMETHOD_DEFAULT*/, uint64 kicker /* = 0 */, const char* reason /* = nullptr */) +void Player::RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method /* = GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /* = ObjectGuid::Empty */, const char* reason /* = nullptr */) { if (group) { @@ -3227,9 +3229,9 @@ void Player::RemoveFromGroup(Group* group, uint64 guid, RemoveMethod method /* = void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend, float /*group_rate*/) { WorldPacket data(SMSG_LOG_XPGAIN, 22); // guess size? - data << uint64(victim ? victim->GetGUID() : 0); // guid - data << uint32(GivenXP + BonusXP); // given experience - data << uint8(victim ? 0 : 1); // 00-kill_xp type, 01-non_kill_xp type + data << (victim ? victim->GetGUID() : ObjectGuid::Empty); // guid + data << uint32(GivenXP + BonusXP); // given experience + data << uint8(victim ? 0 : 1); // 00-kill_xp type, 01-non_kill_xp type if (victim) { @@ -3684,7 +3686,7 @@ void Player::RemoveMail(uint32 id) } } -void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, uint32 item_guid, uint32 item_count) +void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, ObjectGuid::LowType item_guid, uint32 item_count) { WorldPacket data(SMSG_SEND_MAIL_RESULT, (4 + 4 + 4 + (mailError == MAIL_ERR_EQUIP_ERROR ? 4 : (mailAction == MAIL_ITEM_TAKEN ? 4 + 4 : 0)))); data << (uint32) mailId; @@ -3714,7 +3716,7 @@ void Player::UpdateNextMailTimeAndUnreads() time_t cTime = time(nullptr); //Get the next delivery time PreparedStatement* stmtNextDeliveryTime = CharacterDatabase.GetPreparedStatement(CHAR_SEL_NEXT_MAIL_DELIVERYTIME); - stmtNextDeliveryTime->setUInt64(0, GetGUIDLow()); + stmtNextDeliveryTime->setUInt32(0, GetGUID().GetCounter()); stmtNextDeliveryTime->setUInt64(1, cTime); PreparedQueryResult resultNextDeliveryTime = CharacterDatabase.Query(stmtNextDeliveryTime); if (resultNextDeliveryTime) @@ -3725,7 +3727,7 @@ void Player::UpdateNextMailTimeAndUnreads() //Get unread mails count PreparedStatement* stmtUnreadAmount = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_MAILCOUNT_UNREAD_SYNCH); - stmtUnreadAmount->setUInt64(0, GetGUIDLow()); + stmtUnreadAmount->setUInt32(0, GetGUID().GetCounter()); stmtUnreadAmount->setUInt64(1, cTime); PreparedQueryResult resultUnreadAmount = CharacterDatabase.Query(stmtUnreadAmount); if (resultUnreadAmount) @@ -3737,7 +3739,7 @@ void Player::UpdateNextMailTimeAndUnreads() void Player::AddNewMailDeliverTime(time_t deliver_time) { - sWorld->UpdateGlobalPlayerMails(GetGUIDLow(), totalMailCount, false); + sWorld->UpdateGlobalPlayerMails(GetGUID().GetCounter(), totalMailCount, false); if (deliver_time <= time(nullptr)) // ready now { ++unReadMails; @@ -3970,7 +3972,7 @@ bool Player::_addSpell(uint32 spellId, uint8 addSpecMask, bool temporary, bool l { if (spellInfo->Effects[i].Effect != SPELL_EFFECT_LEARN_SPELL) { - LOG_INFO("server", "TRYING TO LEARN SPELL WITH EFFECT LEARN: %u, PLAYER: %u", spellId, GetGUIDLow()); + LOG_INFO("server", "TRYING TO LEARN SPELL WITH EFFECT LEARN: %u, PLAYER: %s", spellId, GetGUID().ToString().c_str()); return false; //ABORT(); } @@ -4022,7 +4024,7 @@ bool Player::_addSpell(uint32 spellId, uint8 addSpecMask, bool temporary, bool l // xinef: do not add spells with effect learn spell if (spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL)) { - LOG_INFO("server", "TRYING TO LEARN SPELL WITH EFFECT LEARN 2: %u, PLAYER: %u", spellId, GetGUIDLow()); + LOG_INFO("server", "TRYING TO LEARN SPELL WITH EFFECT LEARN 2: %u, PLAYER: %s", spellId, GetGUID().ToString().c_str()); m_spells.erase(spellInfo->Id); // mem leak, but should never happen return false; //ABORT(); @@ -4140,7 +4142,7 @@ void Player::learnSpell(uint32 spellId) // Xinef: don't allow to learn active spell once more if (HasActiveSpell(spellId)) { - LOG_ERROR("server", "Player (%u) tries to learn already active spell: %u", GetGUIDLow(), spellId); + LOG_ERROR("server", "Player (%s) tries to learn already active spell: %u", GetGUID().ToString().c_str(), spellId); return; } @@ -4428,7 +4430,7 @@ void Player::_LoadSpellCooldowns(PreparedQueryResult result) { // some cooldowns can be already set at aura loading... - //QueryResult* result = CharacterDatabase.PQuery("SELECT spell, item, time FROM character_spell_cooldown WHERE guid = '%u'", GetGUIDLow()); + //QueryResult* result = CharacterDatabase.PQuery("SELECT spell, item, time FROM character_spell_cooldown WHERE guid = '%u'", GetGUID().GetCounter()()); if (result) { @@ -4444,7 +4446,7 @@ void Player::_LoadSpellCooldowns(PreparedQueryResult result) if (!sSpellMgr->GetSpellInfo(spell_id)) { - LOG_ERROR("server", "Player %u has unknown spell %u in `character_spell_cooldown`, skipping.", GetGUIDLow(), spell_id); + LOG_ERROR("server", "Player %s has unknown spell %u in `character_spell_cooldown`, skipping.", GetGUID().ToString().c_str(), spell_id); continue; } @@ -4455,7 +4457,7 @@ void Player::_LoadSpellCooldowns(PreparedQueryResult result) AddSpellCooldown(spell_id, item_id, (db_time - curTime)*IN_MILLISECONDS, needSend); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Player (GUID: %u) spell %u, item %u cooldown loaded (%u secs).", GetGUIDLow(), spell_id, item_id, uint32(db_time - curTime)); + LOG_DEBUG("entities.player.loading", "Player (%s) spell %u, item %u cooldown loaded (%u secs).", GetGUID().ToString().c_str(), spell_id, item_id, uint32(db_time - curTime)); #endif } while (result->NextRow()); } @@ -4464,7 +4466,7 @@ void Player::_LoadSpellCooldowns(PreparedQueryResult result) void Player::_SaveSpellCooldowns(SQLTransaction& trans, bool logout) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_COOLDOWN); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); time_t curTime = time(nullptr); @@ -4498,7 +4500,7 @@ void Player::_SaveSpellCooldowns(SQLTransaction& trans, bool logout) ss << ','; uint64 cooldown = uint64(((itr->second.end - curMSTime) / IN_MILLISECONDS) + curTime); - ss << '(' << GetGUIDLow() << ',' << itr->first << ',' << itr->second.itemid << ',' << cooldown << ',' << (itr->second.needSendToClient ? '1' : '0') << ')'; + ss << '(' << GetGUID().GetCounter() << ',' << itr->first << ',' << itr->second.itemid << ',' << cooldown << ',' << (itr->second.needSendToClient ? '1' : '0') << ')'; ++itr; } else @@ -4813,45 +4815,41 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell * @param updateRealmChars when this flag is set, the amount of characters on that realm will be updated in the realmlist * @param deleteFinally if this flag is set, the config option will be ignored and the character will be permanently removed from the database */ -void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars, bool deleteFinally) +void Player::DeleteFromDB(ObjectGuid::LowType lowGuid, uint32 accountId, bool updateRealmChars, bool deleteFinally) { // for not existed account avoid update realm - if (accountId == 0) + if (!accountId) updateRealmChars = false; + ObjectGuid playerGuid = ObjectGuid::Create<HighGuid::Player>(lowGuid); + uint32 charDelete_method = sWorld->getIntConfig(CONFIG_CHARDELETE_METHOD); uint32 charDelete_minLvl = sWorld->getIntConfig(CONFIG_CHARDELETE_MIN_LEVEL); // if we want to finally delete the character or the character does not meet the level requirement, // we set it to mode CHAR_DELETE_REMOVE - if (deleteFinally || Player::GetLevelFromStorage(playerguid) < charDelete_minLvl) + if (deleteFinally || Player::GetLevelFromStorage(lowGuid) < charDelete_minLvl) charDelete_method = CHAR_DELETE_REMOVE; - uint32 guid = GUID_LOPART(playerguid); - - // convert corpse to bones if exist (to prevent exiting Corpse in World without DB entry) - // bones will be deleted by corpse/bones deleting thread shortly - sObjectAccessor->ConvertCorpseForPlayer(playerguid); - - if (uint32 guildId = GetGuildIdFromStorage(guid)) + if (uint32 guildId = GetGuildIdFromStorage(lowGuid)) if (Guild* guild = sGuildMgr->GetGuildById(guildId)) - guild->DeleteMember(guid, false, false, true); + guild->DeleteMember(playerGuid, false, false, true); // remove from arena teams - LeaveAllArenaTeams(playerguid); + LeaveAllArenaTeams(playerGuid); // close player ticket if any - GmTicket* ticket = sTicketMgr->GetTicketByPlayer(playerguid); + GmTicket* ticket = sTicketMgr->GetTicketByPlayer(playerGuid); if (ticket) - sTicketMgr->CloseTicket(ticket->GetId(), playerguid); + sTicketMgr->CloseTicket(ticket->GetId(), playerGuid); // remove from group - if (uint32 groupId = GetGroupIdFromStorage(guid)) + if (uint32 groupId = GetGroupIdFromStorage(lowGuid)) if (Group* group = sGroupMgr->GetGroupByGUID(groupId)) - RemoveFromGroup(group, playerguid); + RemoveFromGroup(group, playerGuid); // Remove signs from petitions (also remove petitions if owner); - RemovePetitionsAndSigns(playerguid, 10); + RemovePetitionsAndSigns(playerGuid, 10); PreparedStatement* stmt = nullptr; @@ -4863,7 +4861,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC SQLTransaction trans = CharacterDatabase.BeginTransaction(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_COD_ITEM_MAIL); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); PreparedQueryResult resultMail = CharacterDatabase.Query(stmt); if (resultMail) @@ -4914,7 +4912,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC do { Field* itemFields = resultItems->Fetch(); - uint32 item_guidlow = itemFields[11].GetUInt32(); + ObjectGuid::LowType item_guidlow = itemFields[11].GetUInt32(); uint32 item_template = itemFields[12].GetUInt32(); ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_template); @@ -4927,7 +4925,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC } Item* pItem = NewItemOrBag(itemProto); - if (!pItem->LoadFromDB(item_guidlow, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER), itemFields, item_template)) + if (!pItem->LoadFromDB(item_guidlow, playerGuid, itemFields, item_template)) { pItem->FSetState(ITEM_REMOVED); pItem->SaveToDB(trans); // it also deletes item object! @@ -4943,195 +4941,197 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC stmt->setUInt32(0, mail_id); trans->Append(stmt); - uint32 pl_account = sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); + uint32 pl_account = sObjectMgr->GetPlayerAccountIdByGUID(lowGuid); - draft.AddMoney(money).SendReturnToSender(pl_account, guid, sender, trans); + draft.AddMoney(money).SendReturnToSender(pl_account, lowGuid, sender, trans); } while (resultMail->NextRow()); } // Unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet. // NOW we can finally clear other DB data related to character stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PETS); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); PreparedQueryResult resultPets = CharacterDatabase.Query(stmt); if (resultPets) { do { - uint32 petguidlow = (*resultPets)[0].GetUInt32(); + ObjectGuid::LowType petguidlow = (*resultPets)[0].GetUInt32(); Pet::DeleteFromDB(petguidlow); } while (resultPets->NextRow()); } // Delete char from social list of online chars stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_SOCIAL); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); PreparedQueryResult resultFriends = CharacterDatabase.Query(stmt); if (resultFriends) { do { - if (Player* pFriend = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID((*resultFriends)[0].GetUInt32(), 0, HIGHGUID_PLAYER))) + if (Player* pFriend = ObjectAccessor::FindPlayerByLowGUID((*resultFriends)[0].GetUInt32())) { - pFriend->GetSocial()->RemoveFromSocialList(guid, SOCIAL_FLAG_ALL); - sSocialMgr->SendFriendStatus(pFriend, FRIEND_REMOVED, guid, false); + pFriend->GetSocial()->RemoveFromSocialList(playerGuid, SOCIAL_FLAG_ALL); + sSocialMgr->SendFriendStatus(pFriend, FRIEND_REMOVED, playerGuid, false); } } while (resultFriends->NextRow()); } stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_ACCOUNT_DATA); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_DECLINED_NAME); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACTION); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_GIFT); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_REWARDED); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REPUTATION); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_COOLDOWN); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); if (sWorld->getBoolConfig(CONFIG_DELETE_CHARACTER_TICKET_TRACE)) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PLAYER_GM_TICKETS_ON_CHAR_DELETION); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); } else { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_GM_TICKETS); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); } stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE_BY_OWNER); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEMS); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_BY_OWNER); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME_BY_OWNER); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENTS); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_EQUIPMENTSETS); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOG_BY_PLAYER); - stmt->setUInt32(0, guid); - stmt->setUInt32(1, guid); + stmt->setUInt32(0, lowGuid); + stmt->setUInt32(1, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOG_BY_PLAYER); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_ENTRY_POINT); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_GLYPHS); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_DAILY_CHAR); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_WEEKLY_CHAR); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_MONTHLY_CHAR); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_SEASONAL_CHAR); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_TALENT); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILLS); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); - sScriptMgr->OnDeleteFromDB(trans, guid); + Corpse::DeleteFromDB(playerGuid, trans); + + sScriptMgr->OnDeleteFromDB(trans, lowGuid); CharacterDatabase.CommitTransaction(trans); break; @@ -5141,7 +5141,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC { stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_DELETE_INFO); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowGuid); CharacterDatabase.Execute(stmt); break; @@ -5211,7 +5211,7 @@ void Player::SetMovement(PlayerMovementType pType) LOG_ERROR("server", "Player::SetMovement: Unsupported move type (%d), data not sent to client.", pType); return; } - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(0); GetSession()->SendPacket(&data); } @@ -5223,7 +5223,7 @@ void Player::SetMovement(PlayerMovementType pType) void Player::BuildPlayerRepop() { WorldPacket data(SMSG_PRE_RESURRECT, GetPackGUID().size()); - data.append(GetPackGUID()); + data << GetPackGUID(); GetSession()->SendPacket(&data); if (getRace(true) == RACE_NIGHTELF) { @@ -5233,18 +5233,20 @@ void Player::BuildPlayerRepop() // there must be SMSG.FORCE_RUN_SPEED_CHANGE, SMSG.FORCE_SWIM_SPEED_CHANGE, SMSG.MOVE_WATER_WALK // there must be SMSG.STOP_MIRROR_TIMER - // there we must send 888 opcode - if (GetCorpse()) // the player cannot have a corpse already, only bones which are not returned by GetCorpse + // the player cannot have a corpse already on current map, only bones which are not returned by GetCorpse + WorldLocation corpseLocation = GetCorpseLocation(); + if (corpseLocation.GetMapId() == GetMapId()) { - LOG_ERROR("server", "BuildPlayerRepop: player %s(%d) already has a corpse", GetName().c_str(), GetGUIDLow()); + LOG_ERROR("server", "BuildPlayerRepop: player %s (%s) already has a corpse", GetName().c_str(), GetGUID().ToString().c_str()); return; } - CreateCorpse(); // create a corpse and place it at the player's location - Corpse* corpse = GetCorpse(); + + // create a corpse and place it at the player's location + Corpse* corpse = CreateCorpse(); if (!corpse) { - LOG_ERROR("server", "Error creating corpse for Player %s [%u]", GetName().c_str(), GetGUIDLow()); + LOG_ERROR("server", "Error creating corpse for Player %s [%s]", GetName().c_str(), GetGUID().ToString().c_str()); return; } GetMap()->AddToMap(corpse); @@ -5375,7 +5377,16 @@ void Player::KillPlayer() //UpdateObjectVisibility(); // pussywizard: not needed } -void Player::CreateCorpse() +void Player::OfflineResurrect(ObjectGuid const guid, SQLTransaction& trans) +{ + Corpse::DeleteFromDB(guid, trans); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); + stmt->setUInt16(0, uint16(AT_LOGIN_RESURRECT)); + stmt->setUInt64(1, guid.GetCounter()); + CharacterDatabase.ExecuteOrAppend(trans, stmt); +} + +Corpse* Player::CreateCorpse() { // prevent existence 2 corpse for player SpawnCorpseBones(); @@ -5385,12 +5396,14 @@ void Player::CreateCorpse() Corpse* corpse = new Corpse((m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE); SetPvPDeath(false); - if (!corpse->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_CORPSE), this)) + if (!corpse->Create(GetMap()->GenerateLowGuid<HighGuid::Corpse>(), this)) { delete corpse; - return; + return nullptr; } + _corpseLocation.WorldRelocate(*this); + _uf = getRace(); _pb = GetUInt32Value(PLAYER_BYTES); _pb2 = GetUInt32Value(PLAYER_BYTES_2); @@ -5442,25 +5455,28 @@ void Player::CreateCorpse() } } + // register for player, but not show + GetMap()->AddCorpse(corpse); + // we do not need to save corpses for BG/arenas if (!GetMap()->IsBattlegroundOrArena()) corpse->SaveToDB(); - // register for player, but not show - sObjectAccessor->AddCorpse(corpse); + return corpse; } -void Player::SpawnCorpseBones() +void Player::SpawnCorpseBones(bool triggerSave /*= true*/) { - if (sObjectAccessor->ConvertCorpseForPlayer(GetGUID())) - if (!GetSession()->PlayerLogoutWithSave()) // at logout we will already store the player + _corpseLocation.WorldRelocate(); + if (GetMap()->ConvertCorpseToBones(GetGUID())) + if (triggerSave && !GetSession()->PlayerLogoutWithSave()) // at logout we will already store the player { // prevent loading as ghost without corpse SQLTransaction trans = CharacterDatabase.BeginTransaction(); // pussywizard: update only ghost flag instead of whole character table entry! data integrity is crucial PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REMOVE_GHOST); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); _SaveAuras(trans, false); @@ -5471,7 +5487,7 @@ void Player::SpawnCorpseBones() Corpse* Player::GetCorpse() const { - return sObjectAccessor->GetCorpseForPlayerGUID(GetGUID()); + return GetMap()->GetCorpseByPlayer(GetGUID()); } void Player::DurabilityLossAll(double percent, bool inventory) @@ -6857,7 +6873,7 @@ int16 Player::GetSkillTempBonusValue(uint32 skill) const void Player::SendActionButtons(uint32 state) const { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Sending Action Buttons for '%u' spec '%u'", GetGUIDLow(), m_activeSpec); + LOG_DEBUG("server", "Sending Action Buttons for %s spec %u", GetGUID().ToString().c_str(), m_activeSpec); #endif WorldPacket data(SMSG_ACTION_BUTTONS, 1 + (MAX_ACTION_BUTTONS * 4)); @@ -6882,7 +6898,7 @@ void Player::SendActionButtons(uint32 state) const GetSession()->SendPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Action Buttons for '%u' spec '%u' Sent", GetGUIDLow(), m_activeSpec); + LOG_DEBUG("server", "Action Buttons for %s spec %u Sent", GetGUID().ToString().c_str(), m_activeSpec); #endif } @@ -6943,7 +6959,7 @@ ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type) ab.SetActionAndType(action, ActionButtonType(type)); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player '%u' Added Action '%u' (type %u) to Button '%u'", GetGUIDLow(), action, type, button); + LOG_DEBUG("server", "Player %s Added Action %u (type %u) to Button %u", GetGUID().ToString().c_str(), action, type, button); #endif return &ab; } @@ -6960,7 +6976,7 @@ void Player::removeActionButton(uint8 button) buttonItr->second.uState = ACTIONBUTTON_DELETED; // saved, will deleted at next save #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Action Button '%u' Removed from Player '%u'", button, GetGUIDLow()); + LOG_DEBUG("server", "Action Button %u Removed from Player %s", button, GetGUID().ToString().c_str()); #endif } @@ -7067,8 +7083,8 @@ void Player::CheckAreaExploreAndOutdoor() if (!areaEntry) { - LOG_ERROR("server", "Player '%s' (%u) discovered unknown area (x: %f y: %f z: %f map: %u)", - GetName().c_str(), GetGUIDLow(), GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId()); + LOG_ERROR("server", "Player '%s' (%s) discovered unknown area (x: %f y: %f z: %f map: %u)", + GetName().c_str(), GetGUID().ToString().c_str(), GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId()); return; } @@ -7124,7 +7140,7 @@ void Player::CheckAreaExploreAndOutdoor() SendExplorationExperience(areaId, XP); } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player %u discovered a new area: %u", GetGUIDLow(), areaId); + LOG_DEBUG("server", "Player %s discovered a new area: %u", GetGUID().ToString().c_str(), areaId); #endif } } @@ -7412,7 +7428,7 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awar } */ - uint64 victim_guid = 0; + ObjectGuid victim_guid; uint32 victim_rank = 0; // need call before fields update to have chance move yesterday data to appropriate fields before today data change. @@ -7461,13 +7477,13 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awar // title[15..28] -> rank[5..18] // title[other] -> 0 if (victim_title == 0) - victim_guid = 0; // Don't show HK: <rank> message, only log. + victim_guid.Clear(); // Don't show HK: <rank> message, only log. else if (victim_title < 15) victim_rank = victim_title + 4; else if (victim_title < 29) victim_rank = victim_title - 14 + 4; else - victim_guid = 0; // Don't show HK: <rank> message, only log. + victim_guid.Clear(); // Don't show HK: <rank> message, only log. honor_f = ceil(acore::Honor::hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey)); @@ -7588,7 +7604,7 @@ void Player::ModifyHonorPoints(int32 value, SQLTransaction* trans /*=nullptr*/) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_HONOR_POINTS); stmt->setUInt32(0, newValue); - stmt->setUInt32(1, GetGUIDLow()); + stmt->setUInt32(1, GetGUID().GetCounter()); (*trans)->Append(stmt); } } @@ -7604,26 +7620,26 @@ void Player::ModifyArenaPoints(int32 value, SQLTransaction* trans /*=nullptr*/) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_ARENA_POINTS); stmt->setUInt32(0, newValue); - stmt->setUInt32(1, GetGUIDLow()); + stmt->setUInt32(1, GetGUID().GetCounter()); (*trans)->Append(stmt); } } -uint32 Player::GetGuildIdFromStorage(uint32 guid) +uint32 Player::GetGuildIdFromStorage(ObjectGuid::LowType guid) { if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid)) return playerData->guildId; return 0; } -uint32 Player::GetGroupIdFromStorage(uint32 guid) +uint32 Player::GetGroupIdFromStorage(ObjectGuid::LowType guid) { if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid)) return playerData->groupId; return 0; } -uint32 Player::GetArenaTeamIdFromStorage(uint32 guid, uint8 slot) +uint32 Player::GetArenaTeamIdFromStorage(ObjectGuid::LowType guid, uint8 slot) { if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid)) { @@ -7636,10 +7652,10 @@ uint32 Player::GetArenaTeamIdFromStorage(uint32 guid, uint8 slot) return 0; } -uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type) +uint32 Player::GetArenaTeamIdFromDB(ObjectGuid guid, uint8 type) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ARENA_TEAM_ID_BY_PLAYER_GUID); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt8(1, type); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -7650,15 +7666,17 @@ uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type) return id; } -uint32 Player::GetZoneIdFromDB(uint64 guid) +uint32 Player::GetZoneIdFromDB(ObjectGuid guid) { - uint32 guidLow = GUID_LOPART(guid); + ObjectGuid::LowType guidLow = guid.GetCounter(); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_ZONE); stmt->setUInt32(0, guidLow); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) return 0; + Field* fields = result->Fetch(); uint32 zone = fields[0].GetUInt16(); @@ -7671,6 +7689,7 @@ uint32 Player::GetZoneIdFromDB(uint64 guid) if (!result) return 0; + fields = result->Fetch(); uint32 map = fields[0].GetUInt16(); float posx = fields[1].GetFloat(); @@ -7696,10 +7715,10 @@ uint32 Player::GetZoneIdFromDB(uint64 guid) return zone; } -uint32 Player::GetLevelFromStorage(uint64 guid) +uint32 Player::GetLevelFromStorage(ObjectGuid::LowType guid) { // xinef: Get data from global storage - if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid))) + if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid)) return playerData->level; return 0; @@ -7862,7 +7881,7 @@ void Player::CheckDuelDistance(time_t currTime) if (!duel) return; - uint64 duelFlagGUID = GetUInt64Value(PLAYER_DUEL_ARBITER); + ObjectGuid duelFlagGUID = GetGuidValue(PLAYER_DUEL_ARBITER); GameObject* obj = GetMap()->GetGameObject(duelFlagGUID); if (!obj) return; @@ -7963,7 +7982,7 @@ void Player::DuelComplete(DuelCompleteType type) duel->opponent->CastSpell(duel->opponent, 52852, true); //Remove Duel Flag object - GameObject* obj = GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER)); + GameObject* obj = GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER)); if (obj) duel->initiator->RemoveGameObject(obj, true); @@ -8000,9 +8019,9 @@ void Player::DuelComplete(DuelCompleteType type) duel->opponent->ClearComboPoints(); //cleanups - SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid::Empty); SetUInt32Value(PLAYER_DUEL_TEAM, 0); - duel->opponent->SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + duel->opponent->SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid::Empty); duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0); delete duel->opponent->duel; @@ -8028,7 +8047,7 @@ void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply) return; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "applying mods for item %u ", item->GetGUIDLow()); + LOG_DEBUG("server", "applying mods for item %s ", item->GetGUID().ToString().c_str()); #endif uint8 attacktype = Player::GetAttackBySlot(slot); @@ -8782,8 +8801,8 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(pEnchant->spellid[s]); if (!spellInfo) { - LOG_ERROR("server", "Player::CastItemCombatSpell(GUID: %u, name: %s, enchant: %i): unknown spell %i is casted, ignoring...", - GetGUIDLow(), GetName().c_str(), pEnchant->ID, pEnchant->spellid[s]); + LOG_ERROR("server", "Player::CastItemCombatSpell(%s, name: %s, enchant: %i): unknown spell %i is casted, ignoring...", + GetGUID().ToString().c_str(), GetName().c_str(), pEnchant->ID, pEnchant->spellid[s]); continue; } @@ -9154,9 +9173,11 @@ void Player::RemovedInsignia(Player* looterPlr) RepopAtGraveyard(); } + _corpseLocation.WorldRelocate(); + // We have to convert player corpse to bones, not to be able to resurrect there // SpawnCorpseBones isn't handy, 'cos it saves player while he in BG - Corpse* bones = sObjectAccessor->ConvertCorpseForPlayer(GetGUID(), true); + Corpse* bones = GetMap()->ConvertCorpseToBones(GetGUID(), true); if (!bones) return; @@ -9170,16 +9191,16 @@ void Player::RemovedInsignia(Player* looterPlr) looterPlr->SendLoot(bones->GetGUID(), LOOT_INSIGNIA); } -void Player::SendLootRelease(uint64 guid) +void Player::SendLootRelease(ObjectGuid guid) { WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, (8 + 1)); - data << uint64(guid) << uint8(1); + data << guid << uint8(1); SendDirectMessage(&data); } -void Player::SendLoot(uint64 guid, LootType loot_type) +void Player::SendLoot(ObjectGuid guid, LootType loot_type) { - if (uint64 lguid = GetLootGUID()) + if (ObjectGuid lguid = GetLootGUID()) m_session->DoLootRelease(lguid); Loot* loot = 0; @@ -9188,10 +9209,10 @@ void Player::SendLoot(uint64 guid, LootType loot_type) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("loot", "Player::SendLoot"); #endif - if (IS_GAMEOBJECT_GUID(guid)) + if (guid.IsGameObject()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("loot", "IS_GAMEOBJECT_GUID(guid)"); + LOG_DEBUG("loot", "guid.IsGameObject"); #endif GameObject* go = GetMap()->GetGameObject(guid); @@ -9301,7 +9322,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) permission = ALL_PERMISSION; } } - else if (IS_ITEM_GUID(guid)) + else if (guid.IsItem()) { Item* item = GetItemByGuid(guid); @@ -9316,7 +9337,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) loot = &item->loot; // Xinef: Store container id - loot->containerId = item->GetGUIDLow(); + loot->containerGUID = item->GetGUID(); if (!item->m_lootGenerated && !sLootItemStorage->LoadStoredLoot(item)) { @@ -9346,7 +9367,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) } } } - else if (IS_CORPSE_GUID(guid)) // remove insignia + else if (guid.IsCorpse()) // remove insignia { Corpse* bones = ObjectAccessor::GetCorpse(*this, guid); @@ -9545,7 +9566,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) SetLootGUID(guid); WorldPacket data(SMSG_LOOT_RESPONSE, (9 + 50)); // we guess size - data << uint64(guid); + data << guid; data << uint8(loot_type); data << LootView(*loot, this, permission); @@ -9554,17 +9575,17 @@ void Player::SendLoot(uint64 guid, LootType loot_type) // add 'this' player as one of the players that are looting 'loot' loot->AddLooter(GetGUID()); - if (loot_type == LOOT_CORPSE && !IS_ITEM_GUID(guid)) + if (loot_type == LOOT_CORPSE && !guid.IsItem()) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); } else SendLootError(guid, LOOT_ERROR_DIDNT_KILL); } -void Player::SendLootError(uint64 guid, LootError error) +void Player::SendLootError(ObjectGuid guid, LootError error) { WorldPacket data(SMSG_LOOT_RESPONSE, 10); - data << uint64(guid); + data << guid; data << uint8(LOOT_NONE); data << uint8(error); SendDirectMessage(&data); @@ -10194,7 +10215,7 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) // Scarlet Enclave (DK starting zone) case 4298: // Get Mograine, GUID and ENTRY should NEVER change - if (Creature* mograine = ObjectAccessor::GetCreature(*this, MAKE_NEW_GUID(130956, 29173, HIGHGUID_UNIT))) + if (Creature* mograine = ObjectAccessor::GetCreature(*this, ObjectGuid::Create<HighGuid::Unit>(29173, 130956))) { if (CreatureAI* mograineAI = mograine->AI()) { @@ -10280,17 +10301,17 @@ uint32 Player::GetXPRestBonus(uint32 xp) return rested_bonus; } -void Player::SetBindPoint(uint64 guid) +void Player::SetBindPoint(ObjectGuid guid) { WorldPacket data(SMSG_BINDER_CONFIRM, 8); - data << uint64(guid); + data << guid; GetSession()->SendPacket(&data); } -void Player::SendTalentWipeConfirm(uint64 guid) +void Player::SendTalentWipeConfirm(ObjectGuid guid) { WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8 + 4)); - data << uint64(guid); + data << guid; uint32 cost = sWorld->getBoolConfig(CONFIG_NO_RESET_TALENT_COST) ? 0 : resetTalentsCost(); data << cost; GetSession()->SendPacket(&data); @@ -10308,7 +10329,7 @@ void Player::ResetPetTalents() CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) { - LOG_ERROR("server", "Object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); + LOG_ERROR("server", "Object (%s) is considered pet-like but doesn't have a charminfo!", pet->GetGUID().ToString().c_str()); return; } pet->resetTalents(); @@ -10668,7 +10689,7 @@ uint32 Player::GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipIte return count; } -Item* Player::GetItemByGuid(uint64 guid) const +Item* Player::GetItemByGuid(ObjectGuid guid) const { for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) @@ -12324,8 +12345,8 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest uint8 pItemslot = pItem->GetSlot(); if (pItemslot >= CURRENCYTOKEN_SLOT_START && pItemslot < CURRENCYTOKEN_SLOT_END) { - LOG_ERROR("server", "Possible hacking attempt: Player %s [guid: %u] tried to move token [guid: %u, entry: %u] out of the currency bag!", - GetName().c_str(), GetGUIDLow(), pItem->GetGUIDLow(), pProto->ItemId); + LOG_ERROR("server", "Possible hacking attempt: Player %s [%s] tried to move token [%s, entry: %u] out of the currency bag!", + GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetGUID().ToString().c_str(), pProto->ItemId); return EQUIP_ERR_ITEMS_CANT_BE_SWAPPED; } @@ -12773,12 +12794,12 @@ Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update // save data std::ostringstream ss; AllowedLooterSet::const_iterator itr = allowedLooters.begin(); - ss << *itr; + ss << (*itr).GetCounter(); for (++itr; itr != allowedLooters.end(); ++itr) - ss << ' ' << *itr; + ss << ' ' << (*itr).GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_BOP_TRADE); - stmt->setUInt32(0, pItem->GetGUIDLow()); + stmt->setUInt32(0, pItem->GetGUID().GetCounter()); stmt->setString(1, ss.str()); CharacterDatabase.Execute(stmt); } @@ -12830,7 +12851,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool uint8 slot = pos & 255; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.items", "STORAGE: StoreItem bag = %u, slot = %u, item = %u, count = %u, guid = %u", bag, slot, pItem->GetEntry(), count, pItem->GetGUIDLow()); + LOG_DEBUG("entities.player.items", "STORAGE: StoreItem bag = %u, slot = %u, item = %u, count = %u, %s", bag, slot, pItem->GetEntry(), count, pItem->GetGUID().ToString().c_str()); #endif Item* pItem2 = GetItemByPos(bag, slot); @@ -12854,9 +12875,9 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool if (!pBag) { m_items[slot] = pItem; - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID()); - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, GetGUID()); - pItem->SetUInt64Value(ITEM_FIELD_OWNER, GetGUID()); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID()); + pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID()); + pItem->SetGuidValue(ITEM_FIELD_OWNER, GetGUID()); pItem->SetSlot(slot); pItem->SetContainer(nullptr); @@ -13111,9 +13132,9 @@ void Player::VisualizeItem(uint8 slot, Item* pItem) #endif m_items[slot] = pItem; - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID()); - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, GetGUID()); - pItem->SetUInt64Value(ITEM_FIELD_OWNER, GetGUID()); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID()); + pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID()); + pItem->SetGuidValue(ITEM_FIELD_OWNER, GetGUID()); pItem->SetSlot(slot); pItem->SetContainer(nullptr); @@ -13179,7 +13200,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update, bool swap) } m_items[slot] = nullptr; - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty); if (slot < EQUIPMENT_SLOT_END) SetVisibleItemSlot(slot, nullptr); @@ -13187,8 +13208,8 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update, bool swap) else if (Bag* pBag = GetBagByPos(bag)) pBag->RemoveItem(slot, update); - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0); - // pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0); not clear owner at remove (it will be set at store). This used in mail and auction code + pItem->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid::Empty); + // pItem->SetGuidValue(ITEM_FIELD_OWNER, ObjectGuid::Empty); not clear owner at remove (it will be set at store). This used in mail and auction code pItem->SetSlot(NULL_SLOT); if (IsInWorld() && update) pItem->SendUpdateToPlayer(this); @@ -13258,9 +13279,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT); - - stmt->setUInt32(0, pItem->GetGUIDLow()); - + stmt->setUInt32(0, pItem->GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -13282,7 +13301,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) if (bag == INVENTORY_SLOT_BAG_0) { - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty); // equipment and equipped bags can have applied bonuses if (slot < INVENTORY_SLOT_BAG_END) @@ -13328,7 +13347,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) // Xinef: item is removed, remove loot from storage if any if (proto->Flags & ITEM_FLAG_HAS_LOOT) - sLootItemStorage->RemoveStoredLoot(pItem->GetGUIDLow()); + sLootItemStorage->RemoveStoredLoot(pItem->GetGUID()); if (IsInWorld() && update) { @@ -13337,7 +13356,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) } //pItem->SetOwnerGUID(0); - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0); + pItem->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid::Empty); pItem->SetSlot(NULL_SLOT); pItem->SetState(ITEM_REMOVED, this); } @@ -13631,7 +13650,7 @@ void Player::DestroyItemCount(Item* pItem, uint32& count, bool update) return; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.items", "STORAGE: DestroyItemCount item (GUID: %u, Entry: %u) count = %u", pItem->GetGUIDLow(), pItem->GetEntry(), count); + LOG_DEBUG("entities.player.items", "STORAGE: DestroyItemCount item (%s, Entry: %u) count = %u", pItem->GetGUID().ToString().c_str(), pItem->GetEntry(), count); #endif if (pItem->GetCount() <= count) @@ -14184,7 +14203,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem) uint32 etime = uint32(base - m_logintime + (30 * 3600)); uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetGUID()); + SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetGUID()); if (ItemTemplate const* proto = pItem->GetTemplate()) SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, proto->SellPrice * pItem->GetCount()); else @@ -14225,7 +14244,7 @@ void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del) m_items[slot] = nullptr; uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0); + SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), ObjectGuid::Empty); SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0); SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0); @@ -14245,8 +14264,8 @@ void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint if (msg != EQUIP_ERR_OK) { - data << uint64(pItem ? pItem->GetGUID() : 0); - data << uint64(pItem2 ? pItem2->GetGUID() : 0); + data << (pItem ? pItem->GetGUID() : ObjectGuid::Empty); + data << (pItem2 ? pItem2->GetGUID() : ObjectGuid::Empty); data << uint8(0); // bag type subclass, used with EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM and EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2 switch (msg) @@ -14260,9 +14279,9 @@ void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint } case EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM: // no idea about this one... { - data << uint64(0); // item guid - data << uint32(0); // slot - data << uint64(0); // container + data << ObjectGuid::Empty; // item guid + data << uint32(0); // slot + data << ObjectGuid::Empty; // container break; } case EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_COUNT_EXCEEDED: @@ -14286,7 +14305,7 @@ void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 LOG_DEBUG("network", "WORLD: Sent SMSG_BUY_FAILED"); #endif WorldPacket data(SMSG_BUY_FAILED, (8 + 4 + 4 + 1)); - data << uint64(creature ? creature->GetGUID() : 0); + data << (creature ? creature->GetGUID() : ObjectGuid::Empty); data << uint32(item); if (param > 0) data << uint32(param); @@ -14294,14 +14313,14 @@ void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 GetSession()->SendPacket(&data); } -void Player::SendSellError(SellResult msg, Creature* creature, uint64 guid, uint32 param) +void Player::SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Sent SMSG_SELL_ITEM"); #endif WorldPacket data(SMSG_SELL_ITEM, (8 + 8 + (param ? 4 : 0) + 1)); // last check 2.0.10 - data << uint64(creature ? creature->GetGUID() : 0); - data << uint64(guid); + data << (creature ? creature->GetGUID() : ObjectGuid::Empty); + data << guid; if (param > 0) data << uint32(param); data << uint8(msg); @@ -15033,7 +15052,7 @@ void Player::SendNewItem(Item* item, uint32 count, bool received, bool created, // last check 2.0.10 WorldPacket data(SMSG_ITEM_PUSH_RESULT, (8 + 4 + 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4)); - data << uint64(GetGUID()); // player GUID + data << GetGUID(); // player GUID data << uint32(received); // 0=looted, 1=from npc data << uint32(created); // 0=received, 1=created data << uint32(sendChatMessage); // bool print message to chat @@ -15106,7 +15125,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool VendorItemData const* vendorItems = itr->second.ActionMenuID ? sObjectMgr->GetNpcVendorItemList(itr->second.ActionMenuID) : creature->GetVendorItems(); if (!vendorItems || vendorItems->Empty()) { - LOG_ERROR("sql.sql", "Creature %u (Entry: %u) have UNIT_NPC_FLAG_VENDOR but have empty trading item list.", creature->GetGUIDLow(), creature->GetEntry()); + LOG_ERROR("sql.sql", "Creature %s have UNIT_NPC_FLAG_VENDOR but have empty trading item list.", creature->GetGUID().ToString().c_str()); canTalk = false; } break; @@ -15268,7 +15287,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men return; uint32 gossipOptionId = item->OptionType; - uint64 guid = source->GetGUID(); + ObjectGuid guid = source->GetGUID(); if (sWorld->getIntConfig(CONFIG_INSTANT_TAXI) == 2 && source->GetTypeId() == TYPEID_UNIT) { @@ -15290,7 +15309,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men { if (gossipOptionId > GOSSIP_OPTION_QUESTGIVER) { - LOG_ERROR("server", "Player guid %u request invalid gossip option for GameObject entry %u", GetGUIDLow(), source->GetEntry()); + LOG_ERROR("server", "Player guid %s request invalid gossip option for GameObject entry %u", GetGUID().ToString().c_str(), source->GetEntry()); return; } } @@ -15324,7 +15343,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men break; } case GOSSIP_OPTION_OUTDOORPVP: - sOutdoorPvPMgr->HandleGossipOption(this, source->GetGUID(), gossipListId); + sOutdoorPvPMgr->HandleGossipOption(this, source->ToCreature(), gossipListId); break; case GOSSIP_OPTION_SPIRITHEALER: if (isDead()) @@ -15395,7 +15414,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men if (bgTypeId == BATTLEGROUND_TYPE_NONE) { - LOG_ERROR("server", "a user (guid %u) requested battlegroundlist from a npc who is no battlemaster", GetGUIDLow()); + LOG_ERROR("server", "A user (%s) requested battlegroundlist from a npc who is no battlemaster", GetGUID().ToString().c_str()); return; } @@ -15457,7 +15476,7 @@ void Player::ToggleInstantFlight() /*** QUEST SYSTEM ***/ /*********************************************************/ -void Player::PrepareQuestMenu(uint64 guid) +void Player::PrepareQuestMenu(ObjectGuid guid) { QuestRelationBounds objectQR; QuestRelationBounds objectQIR; @@ -15517,7 +15536,7 @@ void Player::PrepareQuestMenu(uint64 guid) } } -void Player::SendPreparedQuest(uint64 guid) +void Player::SendPreparedQuest(ObjectGuid guid) { QuestMenu& questMenu = PlayerTalkClass->GetQuestMenu(); if (questMenu.Empty()) @@ -15608,7 +15627,7 @@ bool Player::IsActiveQuest(uint32 quest_id) const return m_QuestStatus.find(quest_id) != m_QuestStatus.end(); } -Quest const* Player::GetNextQuest(uint64 guid, Quest const* quest) +Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* quest) { QuestRelationBounds objectQR; @@ -15991,7 +16010,7 @@ void Player::AddQuest(Quest const* quest, Object* questGiver) // prepare Quest Tracker datas auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_QUEST_TRACK); stmt->setUInt32(0, quest_id); - stmt->setUInt32(1, GetGUIDLow()); + stmt->setUInt32(1, GetGUID().GetCounter()); stmt->setString(2, _HASH); stmt->setString(3, _DATE); @@ -16036,7 +16055,7 @@ void Player::CompleteQuest(uint32 quest_id) // prepare Quest Tracker datas auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_COMPLETE_TIME); stmt->setUInt32(0, quest_id); - stmt->setUInt32(1, GetGUIDLow()); + stmt->setUInt32(1, GetGUID().GetCounter()); // add to Quest Tracker CharacterDatabase.Execute(stmt); @@ -16140,7 +16159,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, } } - draft.SendMailTo(trans, MailReceiver(this, this->GetGUIDLow()), sender); + draft.SendMailTo(trans, MailReceiver(this, GetGUID().GetCounter()), sender); CharacterDatabase.CommitTransaction(trans); } @@ -17268,7 +17287,7 @@ void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count) UpdateForQuestWorldObjects(); } -void Player::KilledMonster(CreatureTemplate const* cInfo, uint64 guid) +void Player::KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid) { ASSERT(cInfo); @@ -17277,10 +17296,10 @@ void Player::KilledMonster(CreatureTemplate const* cInfo, uint64 guid) for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i) if (cInfo->KillCredit[i]) - KilledMonsterCredit(cInfo->KillCredit[i], 0); + KilledMonsterCredit(cInfo->KillCredit[i]); } -void Player::KilledMonsterCredit(uint32 entry, uint64 guid) +void Player::KilledMonsterCredit(uint32 entry, ObjectGuid guid) { uint16 addkillcount = 1; uint32 real_entry = entry; @@ -17389,7 +17408,7 @@ void Player::KilledPlayerCredit() } } -void Player::KillCreditGO(uint32 entry, uint64 guid) +void Player::KillCreditGO(uint32 entry, ObjectGuid guid) { uint16 addCastCount = 1; for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i) @@ -17445,7 +17464,7 @@ void Player::KillCreditGO(uint32 entry, uint64 guid) } } -void Player::TalkedToCreature(uint32 entry, uint64 guid) +void Player::TalkedToCreature(uint32 entry, ObjectGuid guid) { uint16 addTalkCount = 1; for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i) @@ -17741,7 +17760,7 @@ void Player::SendQuestConfirmAccept(const Quest* quest, Player* pReceiver) WorldPacket data(SMSG_QUEST_CONFIRM_ACCEPT, (4 + quest->GetTitle().size() + 8)); data << uint32(quest->GetQuestId()); data << quest->GetTitle(); - data << uint64(GetGUID()); + data << GetGUID(); pReceiver->GetSession()->SendPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) @@ -17755,7 +17774,7 @@ void Player::SendPushToPartyResponse(Player const* player, uint8 msg) const if (player) { WorldPacket data(MSG_QUEST_PUSH_RESULT, (8 + 1)); - data << uint64(player->GetGUID()); + data << player->GetGUID(); data << uint8(msg); // valid values: 0-8 GetSession()->SendPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) @@ -17775,7 +17794,7 @@ void Player::SendQuestUpdateAddItem(Quest const* /*quest*/, uint32 /*item_idx*/, GetSession()->SendPacket(&data); } -void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uint32 creatureOrGO_idx, uint16 old_count, uint16 add_count) +void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, ObjectGuid guid, uint32 creatureOrGO_idx, uint16 old_count, uint16 add_count) { ASSERT(old_count + add_count < 65536 && "mob/GO count store in 16 bits 2^16 = 65536 (0..65536)"); @@ -17792,7 +17811,7 @@ void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uin data << uint32(entry); data << uint32(old_count + add_count); data << uint32(quest->RequiredNpcOrGoCount[ creatureOrGO_idx ]); - data << uint64(guid); + data << guid; GetSession()->SendPacket(&data); uint16 log_slot = FindQuestSlot(quest->GetQuestId()); @@ -17841,9 +17860,9 @@ bool Player::HasPvPForcingQuest() const /*** LOAD SYSTEM ***/ /*********************************************************/ -void Player::Initialize(uint32 guid) +void Player::Initialize(ObjectGuid::LowType guid) { - Object::_Create(guid, 0, HIGHGUID_PLAYER); + Object::_Create(guid, 0, HighGuid::Player); } void Player::_LoadDeclinedNames(PreparedQueryResult result) @@ -17862,7 +17881,7 @@ void Player::_LoadArenaTeamInfo() memset((void*)&m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1], 0, sizeof(uint32) * MAX_ARENA_SLOT * ARENA_TEAM_END); for (auto const& itr : ArenaTeam::ArenaSlotByType) - if (uint32 arenaTeamId = Player::GetArenaTeamIdFromStorage(GetGUIDLow(), itr.second)) + if (uint32 arenaTeamId = Player::GetArenaTeamIdFromStorage(GetGUID().GetCounter(), itr.second)) { ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId); if (!arenaTeam) // some shit, should be assert, but just ignore @@ -17885,7 +17904,7 @@ void Player::_LoadArenaTeamInfo() void Player::_LoadEquipmentSets(PreparedQueryResult result) { - // SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", GUID_LOPART(m_guid)); + // SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", m_guid.GetCounter()); if (!result) return; @@ -17903,7 +17922,7 @@ void Player::_LoadEquipmentSets(PreparedQueryResult result) eqSet.state = EQUIPMENT_SET_UNCHANGED; for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) - eqSet.Items[i] = fields[5 + i].GetUInt32(); + eqSet.Items[i] = ObjectGuid::Create<HighGuid::Item>(fields[5 + i].GetUInt32()); m_EquipmentSets[index] = eqSet; @@ -17944,10 +17963,10 @@ void Player::_LoadEntryPointData(PreparedQueryResult result) m_entryPointData.mountSpell = fields[6].GetUInt32(); } -bool Player::LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, uint64 guid) +bool Player::LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid::LowType guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_POSITION); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -17978,7 +17997,7 @@ void Player::SetHomebind(WorldLocation const& loc, uint32 areaId) stmt->setFloat (2, m_homebindX); stmt->setFloat (3, m_homebindY); stmt->setFloat (4, m_homebindZ); - stmt->setUInt32(5, GetGUIDLow()); + stmt->setUInt32(5, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -18004,7 +18023,7 @@ bool Player::isBeingLoaded() const return GetSession()->PlayerLoading(); } -bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) +bool Player::LoadFromDB(ObjectGuid playerGuid, SQLQueryHolder* holder) { //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 //QueryResult* result = CharacterDatabase.PQuery("SELECT guid, account, name, race, class, gender, level, xp, money, skin, face, hairStyle, hairColor, facialStyle, bankSlots, restState, playerFlags, " @@ -18020,7 +18039,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) if (!result) { - LOG_ERROR("server", "Player (GUID: %u) not found in table `characters`, can't load. ", guid); + LOG_ERROR("server", "Player (%s) not found in table `characters`, can't load. ", playerGuid.ToString().c_str()); return false; } @@ -18032,17 +18051,19 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) // player should be able to load/delete character only with correct account! if (dbAccountId != GetSession()->GetAccountId()) { - LOG_ERROR("server", "Player (GUID: %u) loading from wrong account (is: %u, should be: %u)", guid, GetSession()->GetAccountId(), dbAccountId); + LOG_ERROR("server", "Player (%s) loading from wrong account (is: %u, should be: %u)", playerGuid.ToString().c_str(), GetSession()->GetAccountId(), dbAccountId); return false; } if (holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_BANNED)) { - LOG_ERROR("server", "Player (GUID: %u) is banned, can't load.", guid); + LOG_ERROR("server", "Player (%s) is banned, can't load.", playerGuid.ToString().c_str()); return false; } - Object::_Create(guid, 0, HIGHGUID_PLAYER); + ObjectGuid::LowType guid = playerGuid.GetCounter(); + + Object::_Create(guid, 0, HighGuid::Player); m_name = fields[2].GetString(); @@ -18057,9 +18078,6 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) return false; } - // overwrite possible wrong/corrupted guid - SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); - uint8 Gender = fields[5].GetUInt8(); if (!IsValidGender(Gender)) { @@ -18118,7 +18136,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty); SetVisibleItemSlot(slot, nullptr); delete m_items[slot]; @@ -18135,7 +18153,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) setFactionForRace(getRace(true)); // pussywizard: create empty instance bind containers if necessary - sInstanceSaveMgr->PlayerCreateBoundInstancesMaps(guid); + sInstanceSaveMgr->PlayerCreateBoundInstancesMaps(playerGuid); // load home bind and check in same time class/race pair, it used later for restore broken positions if (!_LoadHomeBind(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_HOME_BIND))) @@ -18144,7 +18162,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) InitPrimaryProfessions(); // to max set before any spell loaded // init saved position, and fix it later if problematic - uint32 transLowGUID = fields[35].GetUInt32(); + int32 transLowGUID = fields[35].GetInt32(); Relocate(fields[17].GetFloat(), fields[18].GetFloat(), fields[19].GetFloat(), fields[21].GetFloat()); uint32 mapId = fields[20].GetUInt16(); uint32 instanceId = fields[63].GetUInt32(); @@ -18181,6 +18199,8 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) GetSession()->SetPlayer(this); MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); + Map* map = nullptr; + // pussywizard: group changed difficulty when player was offline, teleport to the enterance of new difficulty if (mapEntry && ((mapEntry->IsNonRaidDungeon() && dungeonDiff != GetDungeonDifficulty()) || (mapEntry->IsRaid() && raidDiff != GetRaidDifficulty()))) { @@ -18241,23 +18261,35 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) } } // currently we do not support transport in bg - else if (transLowGUID) + else if (transLowGUID != 0) { - uint64 transGUID = MAKE_NEW_GUID(transLowGUID, 0, HIGHGUID_MO_TRANSPORT); - GameObject* transGO = HashMapHolder<GameObject>::Find(transGUID); - if (!transGO) // pussywizard: if not MotionTransport, look for StaticTransport + // transLowGUID > 0 ---> motion transport guid + // transLowGUID < 0 ---> static transport spawn id + Transport* transGO = nullptr; + if (transLowGUID > 0) { - transGUID = MAKE_NEW_GUID(transLowGUID, 0, HIGHGUID_TRANSPORT); - transGO = HashMapHolder<GameObject>::Find(transGUID); + ObjectGuid transGUID = ObjectGuid::Create<HighGuid::Mo_Transport>(transLowGUID); + transGO = HashMapHolder<MotionTransport>::Find(transGUID); + } + else + { + map = sMapMgr->CreateMap(mapId, this); + if (map) + { + auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(abs(transLowGUID)); + if (bounds.first != bounds.second) + transGO = bounds.first->second->ToTransport(); + } } - if (transGO) - if (transGO->IsInWorld() && transGO->FindMap()) // pussywizard: must be on map, for one world tick transport is not in map and has old GetMapId(), player would be added to old map and to the transport, multithreading crashfix - m_transport = transGO->ToTransport(); + + // pussywizard: must be on map, for one world tick transport is not in map and has old GetMapId(), player would be added to old map and to the transport, multithreading crashfix + if (transGO && transGO->IsInWorld() && transGO->FindMap()) + m_transport = transGO; if (m_transport) { float x = fields[31].GetFloat(), y = fields[32].GetFloat(), z = fields[33].GetFloat(), o = fields[34].GetFloat(); - m_movementInfo.transport.guid = transGUID; + m_movementInfo.transport.guid = m_transport->GetGUID(); m_movementInfo.transport.pos.Relocate(x, y, z, o); m_transport->CalculatePassengerPosition(x, y, z, &o); @@ -18317,7 +18349,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) // check whether player was unbound or is bound to another instance if (instanceId) { - InstanceSave* save = sInstanceSaveMgr->PlayerGetInstanceSave(GetGUIDLow(), mapId, GetDifficulty(mapEntry->IsRaid())); + InstanceSave* save = sInstanceSaveMgr->PlayerGetInstanceSave(GetGUID(), mapId, GetDifficulty(mapEntry->IsRaid())); if (!save || save->GetInstanceId() != instanceId) instanceId = 0; } @@ -18335,7 +18367,8 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) // NOW player must have valid map // load the player's map here if it's not already loaded - Map* map = sMapMgr->CreateMap(mapId, this); + if (!map) + map = sMapMgr->CreateMap(mapId, this); if (!map) { @@ -18414,7 +18447,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) if (HasAtLoginFlag(AT_LOGIN_RENAME)) { - LOG_ERROR("server", "Player (GUID: %u) tried to login while forced to rename, can't load.'", GetGUIDLow()); + LOG_ERROR("server", "Player %s tried to login while forced to rename, can't load.'", GetGUID().ToString().c_str()); return false; } @@ -18429,16 +18462,16 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) m_deathExpireTime = now + MAX_DEATH_COUNT * DEATH_EXPIRE_STEP - 1; // clear channel spell data (if saved at channel spell casting) - SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0); + SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, ObjectGuid::Empty); SetUInt32Value(UNIT_CHANNEL_SPELL, 0); // clear charm/summon related fields - SetOwnerGUID(0); - SetUInt64Value(UNIT_FIELD_CHARMEDBY, 0); - SetUInt64Value(UNIT_FIELD_CHARM, 0); - SetUInt64Value(UNIT_FIELD_SUMMON, 0); - SetUInt64Value(PLAYER_FARSIGHT, 0); - SetCreatorGUID(0); + SetOwnerGUID(ObjectGuid::Empty); + SetGuidValue(UNIT_FIELD_CHARMEDBY, ObjectGuid::Empty); + SetGuidValue(UNIT_FIELD_CHARM, ObjectGuid::Empty); + SetGuidValue(UNIT_FIELD_SUMMON, ObjectGuid::Empty); + SetGuidValue(PLAYER_FARSIGHT, ObjectGuid::Empty); + SetCreatorGUID(ObjectGuid::Empty); RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVEMENT); @@ -18447,7 +18480,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) SetUInt32Value(PLAYER_TRACK_RESOURCES, 0); // make sure the unit is considered not in duel for proper loading - SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid::Empty); SetUInt32Value(PLAYER_DUEL_TEAM, 0); // reset stats before loading any modifiers @@ -18532,7 +18565,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder* holder) _LoadActions(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_ACTIONS)); - m_social = sSocialMgr->LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_SOCIAL_LIST), GetGUIDLow()); + m_social = sSocialMgr->LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_SOCIAL_LIST), GetGUID()); // check PLAYER_CHOSEN_TITLE compatibility with PLAYER__FIELD_KNOWN_TITLES // note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded @@ -18711,7 +18744,7 @@ bool Player::isAllowedToLoot(const Creature* creature) case ROUND_ROBIN: // may only loot if the player is the loot roundrobin player // or if there are free/quest/conditional item for the player - if (loot->roundRobinPlayer == 0 || loot->roundRobinPlayer == GetGUID()) + if (!loot->roundRobinPlayer || loot->roundRobinPlayer == GetGUID()) return true; return loot->hasItemFor(this); @@ -18720,7 +18753,7 @@ bool Player::isAllowedToLoot(const Creature* creature) // may only loot if the player is the loot roundrobin player // or item over threshold (so roll(s) can be launched) // or if there are free/quest/conditional item for the player - if (loot->roundRobinPlayer == 0 || loot->roundRobinPlayer == GetGUID()) + if (!loot->roundRobinPlayer || loot->roundRobinPlayer == GetGUID()) return true; if (loot->hasOverThresholdItem()) @@ -18763,13 +18796,13 @@ void Player::_LoadActions(PreparedQueryResult result) void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Loading auras for player %u", GetGUIDLow()); + LOG_DEBUG("entities.player.loading", "Loading auras for player %s", GetGUID().ToString().c_str()); #endif /* 0 1 2 3 4 5 6 7 8 9 10 QueryResult* result = CharacterDatabase.PQuery("SELECT casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, 11 12 13 - maxDuration, remainTime, remainCharges FROM character_aura WHERE guid = '%u'", GetGUIDLow()); + maxDuration, remainTime, remainCharges FROM character_aura WHERE guid = '%u'", GetGUID().GetCounter()); */ if (result) @@ -18779,7 +18812,7 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff) Field* fields = result->Fetch(); int32 damage[3]; int32 baseDamage[3]; - uint64 caster_guid = fields[0].GetUInt64(); + ObjectGuid caster_guid = ObjectGuid(fields[0].GetUInt64()); uint32 spellid = fields[1].GetUInt32(); uint8 effmask = fields[2].GetUInt8(); uint8 recalculatemask = fields[3].GetUInt8(); @@ -18878,23 +18911,29 @@ void Player::_LoadGlyphAuras() } } -void Player::LoadCorpse() +void Player::LoadCorpse(PreparedQueryResult result) { - if (IsAlive()) - sObjectAccessor->ConvertCorpseForPlayer(GetGUID()); - else + if (IsAlive() || HasAtLoginFlag(AT_LOGIN_RESURRECT)) + SpawnCorpseBones(false); + + if (!IsAlive()) { - if (Corpse* corpse = GetCorpse()) - ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, corpse && !sMapStore.LookupEntry(corpse->GetMapId())->Instanceable()); + if (result && !HasAtLoginFlag(AT_LOGIN_RESURRECT)) + { + Field* fields = result->Fetch(); + _corpseLocation.WorldRelocate(fields[0].GetUInt16(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat()); + ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(_corpseLocation.GetMapId())->Instanceable()); + } else - //Prevent Dead Player login without corpse ResurrectPlayer(0.5f); } + + RemoveAtLoginFlag(AT_LOGIN_RESURRECT); } void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) { - //QueryResult* result = CharacterDatabase.PQuery("SELECT data, text, bag, slot, item, item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag, slot", GetGUIDLow()); + //QueryResult* result = CharacterDatabase.PQuery("SELECT data, text, bag, slot, item, item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag, slot", GetGUID().GetCounter()); //NOTE: the "order by `bag`" is important because it makes sure //the bagMap is filled before items in the bags are loaded //NOTE2: the "order by `slot`" is needed because mainhand weapons are (wrongly?) @@ -18904,8 +18943,8 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) { uint32 zoneId = GetZoneId(true); - std::map<uint32, Bag*> bagMap; // fast guid lookup for bags - std::map<uint32, Item*> invalidBagMap; // fast guid lookup for bags + std::map<ObjectGuid::LowType, Bag*> bagMap; // fast guid lookup for bags + std::map<ObjectGuid::LowType, Item*> invalidBagMap; // fast guid lookup for bags std::list<Item*> problematicItems; SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -18916,7 +18955,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) Field* fields = result->Fetch(); if (Item* item = _LoadItem(trans, zoneId, timeDiff, fields)) { - uint32 bagGuid = fields[11].GetUInt32(); + ObjectGuid::LowType bagGuid = fields[11].GetUInt32(); uint8 slot = fields[12].GetUInt8(); uint8 err = EQUIP_ERR_OK; @@ -18954,17 +18993,17 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) { if (IsBagPos(item->GetPos())) if (Bag* pBag = item->ToBag()) - bagMap[item->GetGUIDLow()] = pBag; + bagMap[item->GetGUID().GetCounter()] = pBag; } else if (IsBagPos(item->GetPos())) if (item->IsBag()) - invalidBagMap[item->GetGUIDLow()] = item; + invalidBagMap[item->GetGUID().GetCounter()] = item; } else { item->SetSlot(NULL_SLOT); // Item is in the bag, find the bag - std::map<uint32, Bag*>::iterator itr = bagMap.find(bagGuid); + std::map<ObjectGuid::LowType, Bag*>::iterator itr = bagMap.find(bagGuid); if (itr != bagMap.end()) { ItemPosCountVec dest; @@ -18974,14 +19013,14 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) } else if (invalidBagMap.find(bagGuid) != invalidBagMap.end()) { - std::map<uint32, Item*>::iterator itr = invalidBagMap.find(bagGuid); + std::map<ObjectGuid::LowType, Item*>::iterator itr = invalidBagMap.find(bagGuid); if (std::find(problematicItems.begin(), problematicItems.end(), itr->second) != problematicItems.end()) err = EQUIP_ERR_INT_BAG_ERROR; } else { - LOG_ERROR("server", "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) which doesnt have a valid bag (Bag GUID: %u, slot: %u). Possible cheat?", - GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry(), bagGuid, slot); + LOG_ERROR("server", "Player::_LoadInventory: player (%s, name: '%s') has item (%s, entry: %u) which doesnt have a valid bag (Bag GUID: %u, slot: %u). Possible cheat?", + GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), bagGuid, slot); item->DeleteFromInventoryDB(trans); delete item; continue; @@ -18993,8 +19032,8 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) item->SetState(ITEM_UNCHANGED, this); else { - LOG_ERROR("server", "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) which can't be loaded into inventory (Bag GUID: %u, slot: %u) by reason %u. Item will be sent by mail.", - GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry(), bagGuid, slot, err); + LOG_ERROR("server", "Player::_LoadInventory: player (%s, name: '%s') has item (%s, entry: %u) which can't be loaded into inventory (Bag GUID: %u, slot: %u) by reason %u. Item will be sent by mail.", + GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), bagGuid, slot, err); item->DeleteFromInventoryDB(trans); problematicItems.push_back(item); } @@ -19025,7 +19064,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, Field* fields) { Item* item = nullptr; - uint32 itemGuid = fields[13].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[13].GetUInt32(); uint32 itemEntry = fields[14].GetUInt32(); if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry)) { @@ -19039,8 +19078,8 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F if (IsAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(), zoneId)) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (GUID: %u, name: '%s', map: %u) has item (GUID: %u, entry: %u) limited to another map (%u). Deleting item.", - GetGUIDLow(), GetName().c_str(), GetMapId(), item->GetGUIDLow(), item->GetEntry(), zoneId); + LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (%s, name: '%s', map: %u) has item (%s, entry: %u) limited to another map (%u). Deleting item.", + GetGUID().ToString().c_str(), GetName().c_str(), GetMapId(), item->GetGUID().ToString().c_str(), item->GetEntry(), zoneId); #endif remove = true; } @@ -19048,8 +19087,8 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else if (timeDiff > 15 * MINUTE && proto->Flags & ITEM_FLAG_CONJURED) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (GUID: %u, name: '%s', diff: %u) has conjured item (GUID: %u, entry: %u) with expired lifetime (15 minutes). Deleting item.", - GetGUIDLow(), GetName().c_str(), timeDiff, item->GetGUIDLow(), item->GetEntry()); + LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (%s, name: '%s', diff: %u) has conjured item (%s, entry: %u) with expired lifetime (15 minutes). Deleting item.", + GetGUID().ToString().c_str(), GetName().c_str(), timeDiff, item->GetGUID().ToString().c_str(), item->GetEntry()); #endif remove = true; } @@ -19058,11 +19097,11 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F if (item->GetPlayedTime() > (2 * HOUR)) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with expired refund time (%u). Deleting refund data and removing refundable flag.", - GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry(), item->GetPlayedTime()); + LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (%s, name: '%s') has item (%s, entry: %u) with expired refund time (%u). Deleting refund data and removing refundable flag.", + GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), item->GetPlayedTime()); #endif stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE); - stmt->setUInt32(0, item->GetGUIDLow()); + stmt->setUInt32(0, item->GetGUID().GetCounter()); trans->Append(stmt); item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE); @@ -19071,20 +19110,20 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F { // xinef: zomg! sync query stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEM_REFUNDS); - stmt->setUInt32(0, item->GetGUIDLow()); - stmt->setUInt32(1, GetGUIDLow()); + stmt->setUInt32(0, item->GetGUID().GetCounter()); + stmt->setUInt32(1, GetGUID().GetCounter()); if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) { item->SetRefundRecipient((*result)[0].GetUInt32()); item->SetPaidMoney((*result)[1].GetUInt32()); item->SetPaidExtendedCost((*result)[2].GetUInt16()); - AddRefundReference(item->GetGUIDLow()); + AddRefundReference(item->GetGUID()); } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with refundable flags, but without data in item_refund_instance. Removing flag.", - GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry()); + LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (%s, name: '%s') has item (%s, entry: %u) with refundable flags, but without data in item_refund_instance. Removing flag.", + GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry()); #endif item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE); } @@ -19093,14 +19132,14 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE)) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEM_BOP_TRADE); - stmt->setUInt32(0, item->GetGUIDLow()); + stmt->setUInt32(0, item->GetGUID().GetCounter()); if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) { std::string strGUID = (*result)[0].GetString(); Tokenizer GUIDlist(strGUID, ' '); AllowedLooterSet looters; for (Tokenizer::const_iterator itr = GUIDlist.begin(); itr != GUIDlist.end(); ++itr) - looters.insert(atol(*itr)); + looters.insert(ObjectGuid::Create<HighGuid::Player>(atol(*itr))); if (looters.size() > 1 && item->GetTemplate()->GetMaxStackSize() == 1 && item->IsSoulBound()) { @@ -19113,8 +19152,8 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with ITEM_FIELD_FLAG_BOP_TRADEABLE flag, but without data in item_soulbound_trade_data. Removing flag.", - GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry()); + LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (%s, name: '%s') has item (%s, entry: %u) with ITEM_FIELD_FLAG_BOP_TRADEABLE flag, but without data in item_soulbound_trade_data. Removing flag.", + GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry()); #endif item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE); } @@ -19136,8 +19175,8 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F } else { - LOG_ERROR("server", "Player::_LoadInventory: player (GUID: %u, name: '%s') has broken item (GUID: %u, entry: %u) in inventory. Deleting item.", - GetGUIDLow(), GetName().c_str(), itemGuid, itemEntry); + LOG_ERROR("server", "Player::_LoadInventory: player (%s, name: '%s') has broken item (GUID: %u, entry: %u) in inventory. Deleting item.", + GetGUID().ToString().c_str(), GetName().c_str(), itemGuid, itemEntry); remove = true; } // Remove item from inventory if necessary @@ -19151,8 +19190,8 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F } else { - LOG_ERROR("server", "Player::_LoadInventory: player (GUID: %u, name: '%s') has unknown item (entry: %u) in inventory. Deleting item.", - GetGUIDLow(), GetName().c_str(), itemEntry); + LOG_ERROR("server", "Player::_LoadInventory: player (%s, name: '%s') has unknown item (entry: %u) in inventory. Deleting item.", + GetGUID().ToString().c_str(), GetName().c_str(), itemEntry); Item::DeleteFromInventoryDB(trans, itemGuid); Item::DeleteFromDB(trans, itemGuid); } @@ -19173,7 +19212,7 @@ void Player::_LoadMailedItems(Mail* mail) { Field* fields = result->Fetch(); - uint32 itemGuid = fields[11].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[11].GetUInt32(); uint32 itemTemplate = fields[12].GetUInt32(); mail->AddItem(itemGuid, itemTemplate); @@ -19182,7 +19221,8 @@ void Player::_LoadMailedItems(Mail* mail) if (!proto) { - LOG_ERROR("server", "Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), itemGuid, itemTemplate, mail->messageID); + LOG_ERROR("server", "Player %s has unknown item_template (ProtoType) in mailed items (GUID: %u, template: %u) in mail (%u), deleted.", + GetGUID().ToString().c_str(), itemGuid, itemTemplate, mail->messageID); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INVALID_MAIL_ITEM); stmt->setUInt32(0, itemGuid); @@ -19196,7 +19236,7 @@ void Player::_LoadMailedItems(Mail* mail) Item* item = NewItemOrBag(proto); - if (!item->LoadFromDB(itemGuid, MAKE_NEW_GUID(fields[13].GetUInt32(), 0, HIGHGUID_PLAYER), fields, itemTemplate)) + if (!item->LoadFromDB(itemGuid, ObjectGuid::Create<HighGuid::Player>(fields[13].GetUInt32()), fields, itemTemplate)) { LOG_ERROR("server", "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, itemGuid); @@ -19221,16 +19261,16 @@ void Player::_LoadMailInit(PreparedQueryResult resultMailCount, PreparedQueryRes if (resultMailCount) { totalMailCount = uint32((*resultMailCount)[0].GetUInt32()); - sWorld->UpdateGlobalPlayerMails(GetGUIDLow(), totalMailCount, false); + sWorld->UpdateGlobalPlayerMails(GetGUID().GetCounter(), totalMailCount, false); } //set a count of unread mails - //QueryResult* resultMails = CharacterDatabase.PQuery("SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" UI64FMTD "'", GUID_LOPART(playerGuid), (uint64)cTime); + //QueryResult* resultMails = CharacterDatabase.PQuery("SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" UI64FMTD "'", playerGuid.GetCounter(), (uint64)cTime); if (resultUnread) unReadMails = uint8((*resultUnread)[0].GetUInt64()); // store nearest delivery time (it > 0 and if it < current then at next player update SendNewMaill will be called) - //resultMails = CharacterDatabase.PQuery("SELECT MIN(deliver_time) FROM mail WHERE receiver = '%u' AND (checked & 1)=0", GUID_LOPART(playerGuid)); + //resultMails = CharacterDatabase.PQuery("SELECT MIN(deliver_time) FROM mail WHERE receiver = '%u' AND (checked & 1)=0", playerGuid.GetCounter()); if (resultDelivery) m_nextMailDelivereTime = time_t((*resultDelivery)[0].GetUInt32()); } @@ -19264,7 +19304,7 @@ void Player::_LoadMail() //Now load the new ones m_mailCache.clear(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt64(1, time(nullptr)); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) @@ -19324,7 +19364,7 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) //// 0 1 2 3 4 5 6 7 8 9 10 //QueryResult* result = CharacterDatabase.PQuery("SELECT quest, status, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, // 11 12 13 14 - // itemcount4, itemcount5, itemcount6, playercount FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); + // itemcount4, itemcount5, itemcount6, playercount FROM character_queststatus WHERE guid = '%u'", GetGUID().GetCounter()); if (result) { @@ -19346,8 +19386,8 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) else { questStatusData.Status = QUEST_STATUS_INCOMPLETE; - LOG_ERROR("server", "Player %s (GUID: %u) has invalid quest %d status (%u), replaced by QUEST_STATUS_INCOMPLETE(3).", - GetName().c_str(), GetGUIDLow(), quest_id, qstatus); + LOG_ERROR("server", "Player %s (%s) has invalid quest %d status (%u), replaced by QUEST_STATUS_INCOMPLETE(3).", + GetName().c_str(), GetGUID().ToString().c_str(), quest_id, qstatus); } questStatusData.Explored = (fields[2].GetUInt8() > 0); @@ -19395,7 +19435,7 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Quest status is {%u} for quest {%u} for player (GUID: %u)", questStatusData.Status, quest_id, GetGUIDLow()); + LOG_DEBUG("entities.player.loading", "Quest status is {%u} for quest {%u} for player (%s)", questStatusData.Status, quest_id, GetGUID().ToString().c_str()); #endif } } while (result->NextRow()); @@ -19448,7 +19488,7 @@ void Player::_LoadDailyQuestStatus(PreparedQueryResult result) m_DFQuests.clear(); - //QueryResult* result = CharacterDatabase.PQuery("SELECT quest, time FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow()); + //QueryResult* result = CharacterDatabase.PQuery("SELECT quest, time FROM character_queststatus_daily WHERE guid = '%u'", GetGUID().GetCounter()); if (result) { @@ -19469,7 +19509,7 @@ void Player::_LoadDailyQuestStatus(PreparedQueryResult result) if (quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query { - LOG_ERROR("server", "Player (GUID: %u) have more 25 daily quest records in `charcter_queststatus_daily`", GetGUIDLow()); + LOG_ERROR("server", "Player (%s) have more 25 daily quest records in `charcter_queststatus_daily`", GetGUID().ToString().c_str()); break; } @@ -19486,7 +19526,7 @@ void Player::_LoadDailyQuestStatus(PreparedQueryResult result) ++quest_daily_idx; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Daily quest (%u) cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); + LOG_DEBUG("entities.player.loading", "Daily quest (%u) cooldown for player (%s)", quest_id, GetGUID().ToString().c_str()); #endif } while (result->NextRow()); } @@ -19510,7 +19550,7 @@ void Player::_LoadWeeklyQuestStatus(PreparedQueryResult result) m_weeklyquests.insert(quest_id); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Weekly quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); + LOG_DEBUG("entities.player.loading", "Weekly quest {%u} cooldown for player (%s)", quest_id, GetGUID().ToString().c_str()); #endif } while (result->NextRow()); } @@ -19535,7 +19575,7 @@ void Player::_LoadSeasonalQuestStatus(PreparedQueryResult result) m_seasonalquests[event_id].insert(quest_id); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.loading", "Seasonal quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); + LOG_DEBUG("entities.player.loading", "Seasonal quest {%u} cooldown for player (%s)", quest_id, GetGUID().ToString().c_str()); #endif } while (result->NextRow()); } @@ -19558,7 +19598,7 @@ void Player::_LoadMonthlyQuestStatus(PreparedQueryResult result) continue; m_monthlyquests.insert(quest_id); - LOG_DEBUG("entities.player.loading", "Monthly quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); + LOG_DEBUG("entities.player.loading", "Monthly quest {%u} cooldown for player (%s)", quest_id, GetGUID().ToString().c_str()); } while (result->NextRow()); } @@ -19567,7 +19607,7 @@ void Player::_LoadMonthlyQuestStatus(PreparedQueryResult result) void Player::_LoadSpells(PreparedQueryResult result) { - //QueryResult* result = CharacterDatabase.PQuery("SELECT spell, specMask FROM character_spell WHERE guid = '%u'", GetGUIDLow()); + //QueryResult* result = CharacterDatabase.PQuery("SELECT spell, specMask FROM character_spell WHERE guid = '%u'", GetGUID().GetCounter()); if (result) { @@ -19580,7 +19620,7 @@ void Player::_LoadSpells(PreparedQueryResult result) void Player::_LoadGroup() { - if (uint32 groupId = GetGroupIdFromStorage(GetGUIDLow())) + if (uint32 groupId = GetGroupIdFromStorage(GetGUID().GetCounter())) if (Group* group = sGroupMgr->GetGroupByGUID(groupId)) if (group->GetMemberGroup(GetGUID()) <= MAX_RAID_SUBGROUPS) { @@ -19608,7 +19648,7 @@ void Player::BindToInstance() WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); data << uint32(0); GetSession()->SendPacket(&data); - sInstanceSaveMgr->PlayerBindToInstance(this->GetGUIDLow(), mapSave, true, this); + sInstanceSaveMgr->PlayerBindToInstance(this->GetGUID(), mapSave, true, this); } void Player::SendRaidInfo() @@ -19624,7 +19664,7 @@ void Player::SendRaidInfo() for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(GetGUIDLow(), Difficulty(i)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(GetGUID(), Difficulty(i)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { if (itr->second.perm) @@ -19633,7 +19673,7 @@ void Player::SendRaidInfo() time_t resetTime = itr->second.extended ? save->GetExtendedResetTime() : save->GetResetTime(); data << uint32(save->GetMapId()); // map id data << uint32(save->GetDifficulty()); // difficulty - data << uint64(MAKE_NEW_GUID(save->GetInstanceId(), 0, HIGHGUID_INSTANCE)); // instance id + data << ObjectGuid::Create<HighGuid::Instance>(save->GetInstanceId()); // instance id data << uint8(1); // expired = 0 data << uint8(itr->second.extended ? 1 : 0);// extended = 1 data << uint32(resetTime >= now ? resetTime - now : 0); // reset time @@ -19655,7 +19695,7 @@ void Player::SendSavedInstances() for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(GetGUIDLow(), Difficulty(i)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(GetGUID(), Difficulty(i)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { if (itr->second.perm) // only permanent binds are sent @@ -19676,7 +19716,7 @@ void Player::SendSavedInstances() for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(GetGUIDLow(), Difficulty(i)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(GetGUID(), Difficulty(i)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { if (itr->second.perm) @@ -19743,7 +19783,7 @@ void Player::PrettyPrintRequirementsAchievementsList(const std::vector<const Pro stream << "|cffff7c0a|Hachievement:"; stream << missingReq->id; stream << ":"; - stream << std::hex << GetGUID() << std::dec; + stream << GetGUID().ToString(); stream << ":0:0:0:0:0:0:0:0|h["; stream << name; stream << "]|h|r"; @@ -19825,9 +19865,8 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map Player* partyLeader = this; std::string leaderName = m_session->GetAcoreString(LANG_YOU); { - const uint64 leaderGuid = GetGroup() ? GetGroup()->GetLeaderGUID() : GetGUID(); + ObjectGuid leaderGuid = GetGroup() ? GetGroup()->GetLeaderGUID() : GetGUID(); Player* tempLeader = HashMapHolder<Player>::Find(leaderGuid); - if (leaderGuid != GetGUID()) { if (tempLeader != nullptr) @@ -20099,7 +20138,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) else { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } } @@ -20113,7 +20152,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) m_homebindZ = info->positionZ; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt16(1, m_homebindMapId); stmt->setUInt16(2, m_homebindAreaId); stmt->setFloat (3, m_homebindX); @@ -20220,7 +20259,7 @@ void Player::SaveGoldToDB(SQLTransaction& trans) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_MONEY); stmt->setUInt32(0, GetMoney()); - stmt->setUInt32(1, GetGUIDLow()); + stmt->setUInt32(1, GetGUID().GetCounter()); trans->Append(stmt); } @@ -20234,7 +20273,7 @@ void Player::_SaveActions(SQLTransaction& trans) { case ACTIONBUTTON_NEW: stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACTION); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt8(1, m_activeSpec); stmt->setUInt8(2, itr->first); stmt->setUInt32(3, itr->second.GetAction()); @@ -20248,7 +20287,7 @@ void Player::_SaveActions(SQLTransaction& trans) stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACTION); stmt->setUInt32(0, itr->second.GetAction()); stmt->setUInt8(1, uint8(itr->second.GetType())); - stmt->setUInt32(2, GetGUIDLow()); + stmt->setUInt32(2, GetGUID().GetCounter()); stmt->setUInt8(3, itr->first); stmt->setUInt8(4, m_activeSpec); trans->Append(stmt); @@ -20258,7 +20297,7 @@ void Player::_SaveActions(SQLTransaction& trans) break; case ACTIONBUTTON_DELETED: stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACTION_BY_BUTTON_SPEC); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt8(1, itr->first); stmt->setUInt8(2, m_activeSpec); trans->Append(stmt); @@ -20275,7 +20314,7 @@ void Player::_SaveActions(SQLTransaction& trans) void Player::_SaveAuras(SQLTransaction& trans, bool logout) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); for (AuraMap::const_iterator itr = m_ownedAuras.begin(); itr != m_ownedAuras.end(); ++itr) @@ -20310,9 +20349,9 @@ void Player::_SaveAuras(SQLTransaction& trans, bool logout) uint8 index = 0; stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AURA); - stmt->setUInt32(index++, GetGUIDLow()); - stmt->setUInt64(index++, itr->second->GetCasterGUID()); - stmt->setUInt64(index++, itr->second->GetCastItemGUID()); + stmt->setUInt32(index++, GetGUID().GetCounter()); + stmt->setUInt64(index++, itr->second->GetCasterGUID().GetRawValue()); + stmt->setUInt64(index++, itr->second->GetCastItemGUID().GetRawValue()); stmt->setUInt32(index++, itr->second->GetId()); stmt->setUInt8(index++, effMask); stmt->setUInt8(index++, recalculateMask); @@ -20345,22 +20384,22 @@ void Player::_SaveInventory(SQLTransaction& trans) { // Xinef: item is removed, remove loot from storage if any if (item->GetTemplate()->Flags & ITEM_FLAG_HAS_LOOT) - sLootItemStorage->RemoveStoredLoot(item->GetGUIDLow()); + sLootItemStorage->RemoveStoredLoot(item->GetGUID()); continue; } stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); - stmt->setUInt32(0, item->GetGUIDLow()); + stmt->setUInt32(0, item->GetGUID().GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); - stmt->setUInt32(0, item->GetGUIDLow()); + stmt->setUInt32(0, item->GetGUID().GetCounter()); trans->Append(stmt); m_items[i]->FSetState(ITEM_NEW); // Xinef: item is removed, remove loot from storage if any if (item->GetTemplate()->Flags & ITEM_FLAG_HAS_LOOT) - sLootItemStorage->RemoveStoredLoot(item->GetGUIDLow()); + sLootItemStorage->RemoveStoredLoot(item->GetGUID()); } // Updated played time for refundable items. We don't do this in Player::Update because there's simply no need for it, @@ -20374,7 +20413,7 @@ void Player::_SaveInventory(SQLTransaction& trans) i_next = itr; ++i_next; - Item* iPtr = GetItemByGuid(MAKE_NEW_GUID(*itr, 0, HIGHGUID_ITEM)); + Item* iPtr = GetItemByGuid((*itr)); if (iPtr) { iPtr->UpdatePlayedTime(this); @@ -20382,7 +20421,7 @@ void Player::_SaveInventory(SQLTransaction& trans) } else { - LOG_ERROR("server", "Can't find item guid %u but is in refundable storage for player %u ! Removing.", *itr, GetGUIDLow()); + LOG_ERROR("server", "Can't find item %s but is in refundable storage for player %s ! Removing.", (*itr).ToString().c_str(), GetGUID().ToString().c_str()); m_refundableItems.erase(itr); } } @@ -20395,7 +20434,7 @@ void Player::_SaveInventory(SQLTransaction& trans) if (m_itemUpdateQueue.empty()) return; - uint32 lowGuid = GetGUIDLow(); + ObjectGuid::LowType lowGuid = GetGUID().GetCounter(); for (size_t i = 0; i < m_itemUpdateQueue.size(); ++i) { Item* item = m_itemUpdateQueue[i]; @@ -20403,17 +20442,18 @@ void Player::_SaveInventory(SQLTransaction& trans) continue; Bag* container = item->GetContainer(); - uint32 bag_guid = container ? container->GetGUIDLow() : 0; + ObjectGuid::LowType bag_guid = container ? container->GetGUID().GetCounter() : 0; if (item->GetState() != ITEM_REMOVED) { Item* test = GetItemByPos(item->GetBagSlot(), item->GetSlot()); if (test == nullptr) { - uint32 bagTestGUID = 0; + ObjectGuid::LowType bagTestGUID = 0; if (Item* test2 = GetItemByPos(INVENTORY_SLOT_BAG_0, item->GetBagSlot())) - bagTestGUID = test2->GetGUIDLow(); - LOG_ERROR("server", "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u (state %d) are incorrect, the player doesn't have an item at that position!", lowGuid, GetName().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), (int32)item->GetState()); + bagTestGUID = test2->GetGUID().GetCounter(); + LOG_ERROR("server", "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item %s (state %d) are incorrect, the player doesn't have an item at that position!", + lowGuid, GetName().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), (int32)item->GetState()); // according to the test that was just performed nothing should be in this slot, delete stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_BAG_SLOT); stmt->setUInt32(0, bagTestGUID); @@ -20427,13 +20467,14 @@ void Player::_SaveInventory(SQLTransaction& trans) // also THIS item should be somewhere else, cheat attempt item->FSetState(ITEM_REMOVED); // we are IN updateQueue right now, can't use SetState which modifies the queue - DeleteRefundReference(item->GetGUIDLow()); + DeleteRefundReference(item->GetGUID()); // don't skip, let the switch delete it continue; } else if (test != item) { - LOG_ERROR("server", "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u are incorrect, the item with guid %u is there instead!", lowGuid, GetName().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); + LOG_ERROR("server", "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item (%s) are incorrect, the item (%s) is there instead!", + lowGuid, GetName().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), test->GetGUID().ToString().c_str()); // save all changes to the item... if (item->GetState() != ITEM_NEW) // only for existing items, no dupes item->SaveToDB(trans); @@ -20450,12 +20491,12 @@ void Player::_SaveInventory(SQLTransaction& trans) stmt->setUInt32(0, lowGuid); stmt->setUInt32(1, bag_guid); stmt->setUInt8 (2, item->GetSlot()); - stmt->setUInt32(3, item->GetGUIDLow()); + stmt->setUInt32(3, item->GetGUID().GetCounter()); trans->Append(stmt); break; case ITEM_REMOVED: stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); - stmt->setUInt32(0, item->GetGUIDLow()); + stmt->setUInt32(0, item->GetGUID().GetCounter()); trans->Append(stmt); case ITEM_UNCHANGED: break; @@ -20565,7 +20606,7 @@ void Player::_SaveQuestStatus(SQLTransaction& trans) uint8 index = 0; stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_QUESTSTATUS); - stmt->setUInt32(index++, GetGUIDLow()); + stmt->setUInt32(index++, GetGUID().GetCounter()); stmt->setUInt32(index++, statusItr->first); stmt->setUInt8(index++, uint8(statusItr->second.Status)); stmt->setBool(index++, statusItr->second.Explored); @@ -20584,7 +20625,7 @@ void Player::_SaveQuestStatus(SQLTransaction& trans) else { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_BY_QUEST); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, saveItr->first); trans->Append(stmt); } @@ -20599,7 +20640,7 @@ void Player::_SaveQuestStatus(SQLTransaction& trans) else // xinef: what the fuck is this shit? quest can be removed by spelleffect if (!keepAbandoned) stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_REWARDED_BY_QUEST); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, saveItr->first); trans->Append(stmt); } @@ -20621,14 +20662,14 @@ void Player::_SaveDailyQuestStatus(SQLTransaction& trans) // we don't need transactions here. PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_DAILY_CHAR); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) { if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx)) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_DAILYQUESTSTATUS); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx)); stmt->setUInt64(2, uint64(m_lastDailyQuestTime)); trans->Append(stmt); @@ -20640,7 +20681,7 @@ void Player::_SaveDailyQuestStatus(SQLTransaction& trans) for (DFQuestsDoneList::iterator itr = m_DFQuests.begin(); itr != m_DFQuests.end(); ++itr) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_DAILYQUESTSTATUS); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, (*itr)); stmt->setUInt64(2, uint64(m_lastDailyQuestTime)); trans->Append(stmt); @@ -20655,7 +20696,7 @@ void Player::_SaveWeeklyQuestStatus(SQLTransaction& trans) // we don't need transactions here. PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_WEEKLY_CHAR); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); for (QuestSet::const_iterator iter = m_weeklyquests.begin(); iter != m_weeklyquests.end(); ++iter) @@ -20663,7 +20704,7 @@ void Player::_SaveWeeklyQuestStatus(SQLTransaction& trans) uint32 quest_id = *iter; stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_WEEKLYQUESTSTATUS); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, quest_id); trans->Append(stmt); } @@ -20678,7 +20719,7 @@ void Player::_SaveSeasonalQuestStatus(SQLTransaction& trans) // we don't need transactions here. PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_SEASONAL_CHAR); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); for (SeasonalEventQuestMap::const_iterator iter = m_seasonalquests.begin(); iter != m_seasonalquests.end(); ++iter) @@ -20689,7 +20730,7 @@ void Player::_SaveSeasonalQuestStatus(SQLTransaction& trans) uint32 quest_id = (*itr); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SEASONALQUESTSTATUS); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, quest_id); stmt->setUInt32(2, event_id); trans->Append(stmt); @@ -20706,14 +20747,14 @@ void Player::_SaveMonthlyQuestStatus(SQLTransaction& trans) // we don't need transactions here. PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_MONTHLY_CHAR); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); for (QuestSet::const_iterator iter = m_monthlyquests.begin(); iter != m_monthlyquests.end(); ++iter) { uint32 quest_id = *iter; stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_MONTHLYQUESTSTATUS); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, quest_id); trans->Append(stmt); } @@ -20736,7 +20777,7 @@ void Player::_SaveSkills(SQLTransaction& trans) if (itr->second.uState == SKILL_DELETED) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILL_BY_SKILL); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, itr->first); trans->Append(stmt); @@ -20752,7 +20793,7 @@ void Player::_SaveSkills(SQLTransaction& trans) { case SKILL_NEW: stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILLS); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt16(1, uint16(itr->first)); stmt->setUInt16(2, value); stmt->setUInt16(3, max); @@ -20763,7 +20804,7 @@ void Player::_SaveSkills(SQLTransaction& trans) stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_SKILLS); stmt->setUInt16(0, value); stmt->setUInt16(1, max); - stmt->setUInt32(2, GetGUIDLow()); + stmt->setUInt32(2, GetGUID().GetCounter()); stmt->setUInt16(3, uint16(itr->first)); trans->Append(stmt); @@ -20794,7 +20835,7 @@ void Player::_SaveSpells(SQLTransaction& trans) if (itr->second->State == PLAYERSPELL_REMOVED || itr->second->State == PLAYERSPELL_CHANGED) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_BY_SPELL); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, itr->first); trans->Append(stmt); } @@ -20803,7 +20844,7 @@ void Player::_SaveSpells(SQLTransaction& trans) if (itr->second->State == PLAYERSPELL_NEW || itr->second->State == PLAYERSPELL_CHANGED) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SPELL); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, itr->first); stmt->setUInt8(2, itr->second->specMask); trans->Append(stmt); @@ -20833,13 +20874,13 @@ void Player::_SaveStats(SQLTransaction& trans) PreparedStatement* stmt = nullptr; stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_STATS); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); uint8 index = 0; stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_STATS); - stmt->setUInt32(index++, GetGUIDLow()); + stmt->setUInt32(index++, GetGUID().GetCounter()); stmt->setUInt32(index++, GetMaxHealth()); for (uint8 i = 0; i < MAX_POWERS; ++i) @@ -20935,7 +20976,7 @@ void Player::SendAttackSwingNotInRange() GetSession()->SendPacket(&data); } -void Player::SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, uint64 guid) +void Player::SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, ObjectGuid guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_POSITION); @@ -20945,7 +20986,7 @@ void Player::SavePositionInDB(uint32 mapid, float x, float y, float z, float o, stmt->setFloat(3, o); stmt->setUInt16(4, uint16(mapid)); stmt->setUInt16(5, uint16(zone)); - stmt->setUInt32(6, GUID_LOPART(guid)); + stmt->setUInt32(6, guid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -20961,7 +21002,7 @@ void Player::SetUInt32ValueInArray(Tokenizer& tokens, uint16 index, uint32 value tokens[index] = buf; } -void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair) +void Player::Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair) { // xinef: zomg! sync query PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GENDER_AND_APPEARANCE); @@ -20972,7 +21013,7 @@ void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 stmt->setUInt8(3, hairStyle); stmt->setUInt8(4, hairColor); stmt->setUInt8(5, facialHair); - stmt->setUInt32(6, GUID_LOPART(guid)); + stmt->setUInt32(6, guid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -21004,7 +21045,7 @@ void Player::SendAttackSwingBadFacingAttack() void Player::SendAutoRepeatCancel(Unit* target) { WorldPacket data(SMSG_CANCEL_AUTO_REPEAT, target->GetPackGUID().size()); - data.append(target->GetPackGUID()); // may be it's target guid + data << target->GetPackGUID(); // may be it's target guid SendMessageToSet(&data, true); } @@ -21044,17 +21085,17 @@ void Player::SendResetFailedNotify(uint32 mapid) } /// Reset all solo instances and optionally send a message on success for each -void Player::ResetInstances(uint64 guid, uint8 method, bool isRaid) +void Player::ResetInstances(ObjectGuid guid, uint8 method, bool isRaid) { switch (method) { case INSTANCE_RESET_ALL: { - Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* p = ObjectAccessor::FindConnectedPlayer(guid); if (!p || p->GetDifficulty(false) != DUNGEON_DIFFICULTY_NORMAL) break; std::vector<InstanceSave*> toUnbind; - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(p->GetGUIDLow(), Difficulty(DUNGEON_DIFFICULTY_NORMAL)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(p->GetGUID(), Difficulty(DUNGEON_DIFFICULTY_NORMAL)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { InstanceSave* instanceSave = itr->second.save; @@ -21077,11 +21118,11 @@ void Player::ResetInstances(uint64 guid, uint8 method, bool isRaid) break; case INSTANCE_RESET_CHANGE_DIFFICULTY: { - Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* p = ObjectAccessor::FindConnectedPlayer(guid); if (!p) break; std::vector<InstanceSave*> toUnbind; - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(p->GetGUIDLow(), p->GetDifficulty(isRaid)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(p->GetGUID(), p->GetDifficulty(isRaid)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { InstanceSave* instanceSave = itr->second.save; @@ -21104,13 +21145,13 @@ void Player::ResetInstances(uint64 guid, uint8 method, bool isRaid) break; case INSTANCE_RESET_GROUP_JOIN: { - Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* p = ObjectAccessor::FindConnectedPlayer(guid); if (!p) break; for (uint8 d = 0; d < MAX_DIFFICULTY; ++d) { std::vector<InstanceSave*> toUnbind; - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(p->GetGUIDLow(), Difficulty(d)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(p->GetGUID(), Difficulty(d)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { if (itr->second.perm) @@ -21126,17 +21167,17 @@ void Player::ResetInstances(uint64 guid, uint8 method, bool isRaid) // p->SendResetInstanceFailed(0, instanceSave->GetMapId()); } for (std::vector<InstanceSave*>::const_iterator itr = toUnbind.begin(); itr != toUnbind.end(); ++itr) - sInstanceSaveMgr->PlayerUnbindInstance(p->GetGUIDLow(), (*itr)->GetMapId(), (*itr)->GetDifficulty(), true, p); + sInstanceSaveMgr->PlayerUnbindInstance(p->GetGUID(), (*itr)->GetMapId(), (*itr)->GetDifficulty(), true, p); } } break; case INSTANCE_RESET_GROUP_LEAVE: { - Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* p = ObjectAccessor::FindConnectedPlayer(guid); for (uint8 d = 0; d < MAX_DIFFICULTY; ++d) { std::vector<InstanceSave*> toUnbind; - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(GUID_LOPART(guid), Difficulty(d)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(guid, Difficulty(d)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { if (itr->second.perm) @@ -21152,7 +21193,7 @@ void Player::ResetInstances(uint64 guid, uint8 method, bool isRaid) // p->SendResetInstanceFailed(0, instanceSave->GetMapId()); } for (std::vector<InstanceSave*>::const_iterator itr = toUnbind.begin(); itr != toUnbind.end(); ++itr) - sInstanceSaveMgr->PlayerUnbindInstance(GUID_LOPART(guid), (*itr)->GetMapId(), (*itr)->GetDifficulty(), true, p); + sInstanceSaveMgr->PlayerUnbindInstance(guid, (*itr)->GetMapId(), (*itr)->GetDifficulty(), true, p); } } break; @@ -21271,9 +21312,9 @@ void Player::UpdateDuelFlag(time_t currTime) Pet* Player::GetPet() const { - if (uint64 pet_guid = GetPetGUID()) + if (ObjectGuid pet_guid = GetPetGUID()) { - if (!IS_PET_GUID(pet_guid)) + if (!pet_guid.IsPet()) return nullptr; Pet* pet = ObjectAccessor::GetPet(*this, pet_guid); @@ -21285,7 +21326,7 @@ Pet* Player::GetPet() const return pet; //there may be a guardian in slot - //LOG_ERROR("server", "Player::GetPet: Pet %u not exist.", GUID_LOPART(pet_guid)); + //LOG_ERROR("server", "Player::GetPet: Pet %s not exist.", pet_guid.ToString().c_str()); //const_cast<Player*>(this)->SetPetGUID(0); } @@ -21387,10 +21428,10 @@ void Player::StopCastingCharm() if (GetCharmGUID()) { - LOG_FATAL("server", "Player %s (GUID: " UI64FMTD " is not able to uncharm unit (GUID: " UI64FMTD " Entry: %u, Type: %u)", GetName().c_str(), GetGUID(), GetCharmGUID(), charm->GetEntry(), charm->GetTypeId()); + LOG_FATAL("server", "Player %s (%s is not able to uncharm unit (%s)", GetName().c_str(), GetGUID().ToString().c_str(), GetCharmGUID().ToString().c_str()); if (charm->GetCharmerGUID()) { - LOG_FATAL("server", "Charmed unit has charmer guid " UI64FMTD, charm->GetCharmerGUID()); + LOG_FATAL("server", "Charmed unit has charmer %s", charm->GetCharmerGUID().ToString().c_str()); ABORT(); } else @@ -21460,14 +21501,14 @@ void Player::TextEmote(const std::string& text) } } -void Player::Whisper(const std::string& text, uint32 language, uint64 receiver) +void Player::Whisper(const std::string& text, uint32 language, ObjectGuid receiver) { bool isAddonMessage = language == LANG_ADDON; if (!isAddonMessage) // if not addon data language = LANG_UNIVERSAL; // whispers should always be readable - Player* rPlayer = ObjectAccessor::GetObjectInOrOutOfWorld(receiver, (Player*)nullptr); + Player* rPlayer = ObjectAccessor::FindConnectedPlayer(receiver); std::string _text(text); sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, rPlayer); @@ -21514,7 +21555,7 @@ void Player::PetSpellInitialize() CharmInfo* charmInfo = pet->GetCharmInfo(); WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 1); - data << uint64(pet->GetGUID()); + data << pet->GetGUID(); data << uint16(pet->GetCreatureTemplate()->family); // creature family (required for pet talents) data << uint32(pet->GetDuration()); data << uint8(pet->GetReactState()); @@ -21573,12 +21614,12 @@ void Player::PossessSpellInitialize() if (!charmInfo) { - LOG_ERROR("server", "Player::PossessSpellInitialize(): charm (" UI64FMTD ") has no charminfo!", charm->GetGUID()); + LOG_ERROR("server", "Player::PossessSpellInitialize(): charm (%s) has no charminfo!", charm->GetGUID().ToString().c_str()); return; } WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 1); - data << uint64(charm->GetGUID()); + data << charm->GetGUID(); data << uint16(0); data << uint32(0); data << uint32(0); @@ -21600,7 +21641,7 @@ void Player::VehicleSpellInitialize() uint8 cooldownCount = vehicle->m_CreatureSpellCooldowns.size(); WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * 10 + 1 + 1 + cooldownCount * (4 + 2 + 4 + 4)); - data << uint64(vehicle->GetGUID()); // Guid + data << vehicle->GetGUID(); // Guid data << uint16(0); // Pet Family (0 for all vehicles) data << uint32(vehicle->IsSummon() ? vehicle->ToTempSummon()->GetTimer() : 0); // Duration // The following three segments are read by the client as one uint32 @@ -21665,7 +21706,7 @@ void Player::CharmSpellInitialize() CharmInfo* charmInfo = charm->GetCharmInfo(); if (!charmInfo) { - LOG_ERROR("server", "Player::CharmSpellInitialize(): the player's charm (" UI64FMTD ") has no charminfo!", charm->GetGUID()); + LOG_ERROR("server", "Player::CharmSpellInitialize(): the player's charm (%s) has no charminfo!", charm->GetGUID().ToString().c_str()); return; } @@ -21682,7 +21723,7 @@ void Player::CharmSpellInitialize() } WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 4 * addlist + 1); - data << uint64(charm->GetGUID()); + data << charm->GetGUID(); data << uint16(0); data << uint32(0); @@ -21990,14 +22031,12 @@ void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) GetSession()->SendPacket(&data); } -void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) +void Player::RemovePetitionsAndSigns(ObjectGuid guid, uint32 type) { SignatureContainer* signatureStore = sPetitionMgr->GetSignatureStore(); - uint32 playerGuid = GUID_LOPART(guid); - for (SignatureContainer::iterator itr = signatureStore->begin(); itr != signatureStore->end(); ++itr) { - SignatureMap::iterator signItr = itr->second.signatureMap.find(playerGuid); + SignatureMap::iterator signItr = itr->second.signatureMap.find(guid); if (signItr != itr->second.signatureMap.end()) { Petition const* petition = sPetitionMgr->GetPetition(itr->first); @@ -22007,26 +22046,23 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) // erase this itr->second.signatureMap.erase(signItr); - uint64 ownerguid = MAKE_NEW_GUID(petition->ownerGuid, 0, HIGHGUID_PLAYER); - uint64 petitionguid = MAKE_NEW_GUID(petition->petitionGuid, 0, HIGHGUID_ITEM); - // send update if charter owner in game - Player* owner = ObjectAccessor::FindPlayerInOrOutOfWorld(ownerguid); + Player* owner = ObjectAccessor::FindConnectedPlayer(petition->ownerGuid); if (owner) - owner->GetSession()->SendPetitionQueryOpcode(petitionguid); + owner->GetSession()->SendPetitionQueryOpcode(petition->petitionGuid); } } if (type == 10) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ALL_PETITION_SIGNATURES); - stmt->setUInt32(0, playerGuid); + stmt->setUInt32(0, guid.GetCounter()); CharacterDatabase.Execute(stmt); } else { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE); - stmt->setUInt32(0, playerGuid); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt8(1, uint8(type)); CharacterDatabase.Execute(stmt); } @@ -22035,39 +22071,39 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) if (type == 10) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_BY_OWNER); - stmt->setUInt32(0, playerGuid); + stmt->setUInt32(0, guid.GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE_BY_OWNER); - stmt->setUInt32(0, playerGuid); + stmt->setUInt32(0, guid.GetCounter()); trans->Append(stmt); // xinef: clear petition store - sPetitionMgr->RemovePetitionByOwnerAndType(playerGuid, 0); + sPetitionMgr->RemovePetitionByOwnerAndType(guid, 0); } else { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_BY_OWNER_AND_TYPE); - stmt->setUInt32(0, playerGuid); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt8(1, uint8(type)); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE_BY_OWNER_AND_TYPE); - stmt->setUInt32(0, playerGuid); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt8(1, uint8(type)); trans->Append(stmt); // xinef: clear petition store - sPetitionMgr->RemovePetitionByOwnerAndType(playerGuid, uint8(type)); + sPetitionMgr->RemovePetitionByOwnerAndType(guid, uint8(type)); } CharacterDatabase.CommitTransaction(trans); } -void Player::LeaveAllArenaTeams(uint64 guid) +void Player::LeaveAllArenaTeams(ObjectGuid guid) { // xinef: zomg! sync query PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PLAYER_ARENA_TEAMS); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -22341,7 +22377,7 @@ void Player::ContinueTaxiFlight() return; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.unit", "WORLD: Restart character %u taxi flight", GetGUIDLow()); + LOG_DEBUG("entities.unit", "WORLD: Restart character %s taxi flight", GetGUID().ToString().c_str()); #endif uint32 mountDisplayId = sObjectMgr->GetTaxiMountDisplayId(sourceNode, GetTeamId(true), true); @@ -22476,7 +22512,7 @@ void Player::InitDisplayIds() PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(true), getClass()); if (!info) { - LOG_ERROR("server", "Player %u has incorrect race/class pair. Can't init display ids.", GetGUIDLow()); + LOG_ERROR("server", "Player %s has incorrect race/class pair. Can't init display ids.", GetGUID().ToString().c_str()); return; } @@ -22536,7 +22572,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c uint32 new_count = pVendor->UpdateVendorItemCurrentCount(crItem, pProto->BuyCount * count); WorldPacket data(SMSG_BUY_ITEM, (8 + 4 + 4 + 4)); - data << uint64(pVendor->GetGUID()); + data << pVendor->GetGUID(); data << uint32(vendorslot + 1); // numbered from 1 at client data << int32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); data << uint32(count); @@ -22549,11 +22585,11 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c if (pProto->Flags & ITEM_FLAG_ITEM_PURCHASE_RECORD && crItem->ExtendedCost && pProto->GetMaxStackSize() == 1) { it->SetFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE); - it->SetRefundRecipient(GetGUIDLow()); + it->SetRefundRecipient(GetGUID().GetCounter()); it->SetPaidMoney(price); it->SetPaidExtendedCost(crItem->ExtendedCost); it->SaveRefundDataToDB(); - AddRefundReference(it->GetGUIDLow()); + AddRefundReference(it->GetGUID()); } } @@ -22563,7 +22599,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c } // Return true is the bought item has a max count to force refresh of window by caller -bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot) +bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot) { sScriptMgr->OnBeforeBuyItemFromVendor(this, vendorguid, vendorslot, item, count, bag, slot); @@ -22601,7 +22637,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: BuyItemFromVendor - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid))); + LOG_DEBUG("network", "WORLD: BuyItemFromVendor - Unit (%s) not found or you can't interact with him.", vendorguid.ToString().c_str()); #endif SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, nullptr, item, 0); return false; @@ -22798,7 +22834,7 @@ void Player::UpdateHomebindTime(uint32 time) data << uint32(1); GetSession()->SendPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("maps", "PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName().c_str(), GetGUIDLow()); + LOG_DEBUG("maps", "PLAYER: Player '%s' (%s) will be teleported to homebind in 60 seconds", GetName().c_str(), GetGUID().ToString().c_str()); #endif } } @@ -23035,7 +23071,7 @@ void Player::ModifySpellCooldown(uint32 spellId, int32 cooldown) WorldPacket data(SMSG_MODIFY_COOLDOWN, 4 + 8 + 4); data << uint32(spellId); // Spell ID - data << uint64(GetGUID()); // Player GUID + data << GetGUID(); // Player GUID data << int32(cooldown); // Cooldown mod in milliseconds GetSession()->SendPacket(&data); } @@ -23049,7 +23085,7 @@ void Player::SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId /*= 0*/ // Send activate cooldown timer (possible 0) at client side WorldPacket data(SMSG_COOLDOWN_EVENT, 4 + 8); data << uint32(spellInfo->Id); - data << uint64(GetGUID()); + data << GetGUID(); SendDirectMessage(&data); } @@ -23288,7 +23324,7 @@ void Player::LeaveBattleground(Battleground* bg) if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_BG); CharacterDatabase.Execute(stmt); } @@ -23335,9 +23371,9 @@ void Player::ReportedAfkBy(Player* reporter) return; // check if player has 'Idle' or 'Inactive' debuff - if (m_bgData.bgAfkReporter.find(reporter->GetGUIDLow()) == m_bgData.bgAfkReporter.end() && !HasAura(43680) && !HasAura(43681) && reporter->CanReportAfkDueToLimit()) + if (m_bgData.bgAfkReporter.find(reporter->GetGUID()) == m_bgData.bgAfkReporter.end() && !HasAura(43680) && !HasAura(43681) && reporter->CanReportAfkDueToLimit()) { - m_bgData.bgAfkReporter.insert(reporter->GetGUIDLow()); + m_bgData.bgAfkReporter.insert(reporter->GetGUID()); // by default 3 players have to complain to apply debuff if (m_bgData.bgAfkReporter.size() >= sWorld->getIntConfig(CONFIG_BATTLEGROUND_REPORT_AFK)) { @@ -23374,7 +23410,7 @@ bool Player::CanAlwaysSee(WorldObject const* obj) const if (m_mover == obj) return true; - if (uint64 guid = GetUInt64Value(PLAYER_FARSIGHT)) + if (ObjectGuid guid = GetGuidValue(PLAYER_FARSIGHT)) if (obj->GetGUID() == guid) return true; @@ -23418,13 +23454,13 @@ bool Player::IsVisibleGloballyFor(Player const* u) const } template<class T> -inline void UpdateVisibilityOf_helper(Player::ClientGUIDs& s64, T* target, std::vector<Unit*>& /*v*/) +inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, T* target, std::vector<Unit*>& /*v*/) { s64.insert(target->GetGUID()); } template<> -inline void UpdateVisibilityOf_helper(Player::ClientGUIDs& s64, GameObject* target, std::vector<Unit*>& /*v*/) +inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, GameObject* target, std::vector<Unit*>& /*v*/) { // @HACK: This is to prevent objects like deeprun tram from disappearing when player moves far from its spawn point while riding it if ((target->GetGOInfo()->type != GAMEOBJECT_TYPE_TRANSPORT)) @@ -23432,14 +23468,14 @@ inline void UpdateVisibilityOf_helper(Player::ClientGUIDs& s64, GameObject* targ } template<> -inline void UpdateVisibilityOf_helper(Player::ClientGUIDs& s64, Creature* target, std::vector<Unit*>& v) +inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, Creature* target, std::vector<Unit*>& v) { s64.insert(target->GetGUID()); v.push_back(target); } template<> -inline void UpdateVisibilityOf_helper(Player::ClientGUIDs& s64, Player* target, std::vector<Unit*>& v) +inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, Player* target, std::vector<Unit*>& v) { s64.insert(target->GetGUID()); v.push_back(target); @@ -23495,9 +23531,9 @@ void Player::UpdateTriggerVisibility() UpdateData udata; WorldPacket packet; - for (ClientGUIDs::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) + for (GuidUnorderedSet::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) { - if (IS_VEHICLE_GUID(*itr) || IS_CREATURE_GUID(*itr)) + if ((*itr).IsCreatureOrVehicle()) { Creature* creature = GetMap()->GetCreature(*itr); // Update fields of triggers, transformed units or unselectable units (values dependent on GM state) @@ -23508,7 +23544,7 @@ void Player::UpdateTriggerVisibility() creature->BuildValuesUpdateBlockForPlayer(&udata, this); creature->RemoveFieldNotifyFlag(UF_FLAG_PUBLIC); } - else if (IS_GAMEOBJECT_GUID((*itr))) + else if ((*itr).IsGameObject()) { GameObject* go = GetMap()->GetGameObject(*itr); if (!go) @@ -23626,21 +23662,23 @@ bool Player::ModifyMoney(int32 amount, bool sendError /*= true*/) Unit* Player::GetSelectedUnit() const { - if (uint64 selectionGUID = GetUInt64Value(UNIT_FIELD_TARGET)) + if (ObjectGuid selectionGUID = GetGuidValue(UNIT_FIELD_TARGET)) return ObjectAccessor::GetUnit(*this, selectionGUID); + return nullptr; } Player* Player::GetSelectedPlayer() const { - if (uint64 selectionGUID = GetUInt64Value(UNIT_FIELD_TARGET)) + if (ObjectGuid selectionGUID = GetGuidValue(UNIT_FIELD_TARGET)) return ObjectAccessor::GetPlayer(*this, selectionGUID); + return nullptr; } -void Player::SetSelection(uint64 guid) +void Player::SetSelection(ObjectGuid guid) { - SetUInt64Value(UNIT_FIELD_TARGET, guid); + SetGuidValue(UNIT_FIELD_TARGET, guid); if (NeedSendSpectatorData()) ArenaSpectator::SendCommand_GUID(FindMap(), GetGUID(), "TRG", guid); @@ -23655,11 +23693,11 @@ void Player::SendComboPoints() if (m_mover != this) { data.Initialize(SMSG_PET_UPDATE_COMBO_POINTS, m_mover->GetPackGUID().size() + combotarget->GetPackGUID().size() + 1); - data.append(m_mover->GetPackGUID()); + data << m_mover->GetPackGUID(); } else data.Initialize(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size() + 1); - data.append(combotarget->GetPackGUID()); + data << combotarget->GetPackGUID(); data << uint8(m_comboPoints); GetSession()->SendPacket(&data); } @@ -23681,12 +23719,12 @@ void Player::AddComboPoints(Unit* target, int8 count) { if (m_comboTarget) if (Unit* target2 = ObjectAccessor::GetUnit(*this, m_comboTarget)) - target2->RemoveComboPointHolder(GetGUIDLow()); + target2->RemoveComboPointHolder(GetGUID()); m_comboTarget = target->GetGUID(); *comboPoints = count; - target->AddComboPointHolder(GetGUIDLow()); + target->AddComboPointHolder(GetGUID()); } if (*comboPoints > 5) @@ -23710,9 +23748,9 @@ void Player::ClearComboPoints() SendComboPoints(); if (Unit* target = ObjectAccessor::GetUnit(*this, m_comboTarget)) - target->RemoveComboPointHolder(GetGUIDLow()); + target->RemoveComboPointHolder(GetGUID()); - m_comboTarget = 0; + m_comboTarget.Clear(); } void Player::SetGroup(Group* group, int8 subgroup) @@ -23833,7 +23871,7 @@ void Player::SendInitialPacketsAfterAddToMap() if (HasAuraType(SPELL_AURA_MOD_ROOT)) { WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10); - data2.append(GetPackGUID()); + data2 << GetPackGUID(); data2 << (uint32)2; SendMessageToSet(&data2, true); } @@ -23890,7 +23928,7 @@ void Player::SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool onEnterMap) { // pussywizard: - InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(GetGUIDLow(), mapid, difficulty); + InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(GetGUID(), mapid, difficulty); if (bind && bind->extended) { if (!onEnterMap) // extended id player shouldn't be warned about lock expiration @@ -24103,7 +24141,7 @@ void Player::GetAurasForTarget(Unit* target) // pussywizard: contact before chan target->SendMovementHover(this); WorldPacket data(SMSG_AURA_UPDATE_ALL); - data.append(target->GetPackGUID()); + data<< target->GetPackGUID(); Unit::VisibleAuraMap const* visibleAuras = target->GetVisibleAuras(); for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr) @@ -24360,14 +24398,14 @@ void Player::UpdateForQuestWorldObjects() UpdateData udata; WorldPacket packet; - for (ClientGUIDs::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) + for (GuidUnorderedSet::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) { - if (IS_GAMEOBJECT_GUID(*itr)) + if ((*itr).IsGameObject()) { - if (GameObject* obj = HashMapHolder<GameObject>::Find(*itr)) + if (GameObject* obj = ObjectAccessor::GetGameObject(*this, *itr)) obj->BuildValuesUpdateBlockForPlayer(&udata, this); } - else if (IS_CRE_OR_VEH_GUID(*itr)) + else if ((*itr).IsCreatureOrVehicle()) { Creature* obj = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr); if (!obj) @@ -24400,7 +24438,7 @@ void Player::UpdateForQuestWorldObjects() GetSession()->SendPacket(&packet); } -void Player::SummonIfPossible(bool agree, uint32 summoner_guid) +void Player::SummonIfPossible(bool agree, ObjectGuid summoner_guid) { if (!agree) { @@ -24721,7 +24759,8 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar { if (!pRewardSource) return; - uint64 creature_guid = (pRewardSource->GetTypeId() == TYPEID_UNIT) ? pRewardSource->GetGUID() : uint64(0); + + ObjectGuid creature_guid = (pRewardSource->GetTypeId() == TYPEID_UNIT) ? pRewardSource->GetGUID() : ObjectGuid::Empty; // prepare data for near group iteration if (Group* group = GetGroup()) @@ -24846,7 +24885,7 @@ void Player::SetClientControl(Unit* target, bool allowMove, bool packetOnly /*= if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE)) { // Xinef: restore original orientation, important for shooting vehicles! - Position pos = target->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && target->GetTransGUID() && IS_MO_TRANSPORT_GUID(target->GetTransGUID()) ? target->ToCreature()->GetTransportHomePosition() : target->ToCreature()->GetHomePosition(); + Position pos = target->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && target->GetTransGUID() && target->GetTransGUID().IsMOTransport() ? target->ToCreature()->GetTransportHomePosition() : target->ToCreature()->GetHomePosition(); target->SetOrientation(pos.GetOrientation()); target->SetFacingTo(pos.GetOrientation()); target->DisableSpline(); @@ -24860,14 +24899,14 @@ void Player::SetMover(Unit* target) { if (this != target && target->m_movedByPlayer && target->m_movedByPlayer != target && target->m_movedByPlayer != this) { - LOG_INFO("misc", "Player::SetMover (A1) - %u, %u, %u, %u, %u, %u, %u, %u", GetGUIDLow(), GetMapId(), GetInstanceId(), FindMap()->GetId(), IsInWorld() ? 1 : 0, IsDuringRemoveFromWorld() ? 1 : 0, IsBeingTeleported() ? 1 : 0, isBeingLoaded() ? 1 : 0); - LOG_INFO("misc", "Player::SetMover (A2) - %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u", target->GetTypeId(), target->GetEntry(), target->GetUnitTypeMask(), target->GetGUIDLow(), target->GetMapId(), target->GetInstanceId(), target->FindMap()->GetId(), target->IsInWorld() ? 1 : 0, target->IsDuringRemoveFromWorld() ? 1 : 0, (target->ToPlayer() && target->ToPlayer()->IsBeingTeleported() ? 1 : 0), target->isBeingLoaded() ? 1 : 0); - LOG_INFO("misc", "Player::SetMover (A3) - %u, %u, %u, %u, %u, %u, %u, %u", target->m_movedByPlayer->GetGUIDLow(), target->m_movedByPlayer->GetMapId(), target->m_movedByPlayer->GetInstanceId(), target->m_movedByPlayer->FindMap()->GetId(), target->m_movedByPlayer->IsInWorld() ? 1 : 0, target->m_movedByPlayer->IsDuringRemoveFromWorld() ? 1 : 0, target->m_movedByPlayer->ToPlayer()->IsBeingTeleported() ? 1 : 0, target->m_movedByPlayer->isBeingLoaded() ? 1 : 0); + LOG_INFO("misc", "Player::SetMover (A1) - %s, %u, %u, %u, %u, %u, %u, %u", GetGUID().ToString().c_str(), GetMapId(), GetInstanceId(), FindMap()->GetId(), IsInWorld() ? 1 : 0, IsDuringRemoveFromWorld() ? 1 : 0, IsBeingTeleported() ? 1 : 0, isBeingLoaded() ? 1 : 0); + LOG_INFO("misc", "Player::SetMover (A2) - %s, %u, %u, %u, %u, %u, %u, %u", target->GetGUID().ToString().c_str(), target->GetMapId(), target->GetInstanceId(), target->FindMap()->GetId(), target->IsInWorld() ? 1 : 0, target->IsDuringRemoveFromWorld() ? 1 : 0, (target->ToPlayer() && target->ToPlayer()->IsBeingTeleported() ? 1 : 0), target->isBeingLoaded() ? 1 : 0); + LOG_INFO("misc", "Player::SetMover (A3) - %s, %u, %u, %u, %u, %u, %u, %u", target->m_movedByPlayer->GetGUID().ToString().c_str(), target->m_movedByPlayer->GetMapId(), target->m_movedByPlayer->GetInstanceId(), target->m_movedByPlayer->FindMap()->GetId(), target->m_movedByPlayer->IsInWorld() ? 1 : 0, target->m_movedByPlayer->IsDuringRemoveFromWorld() ? 1 : 0, target->m_movedByPlayer->ToPlayer()->IsBeingTeleported() ? 1 : 0, target->m_movedByPlayer->isBeingLoaded() ? 1 : 0); } if (this != target && (!target->IsInWorld() || target->IsDuringRemoveFromWorld() || GetMapId() != target->GetMapId() || GetInstanceId() != target->GetInstanceId())) { - LOG_INFO("misc", "Player::SetMover (B1) - %u, %u, %u, %u, %u, %u, %u, %u", GetGUIDLow(), GetMapId(), GetInstanceId(), FindMap()->GetId(), IsInWorld() ? 1 : 0, IsDuringRemoveFromWorld() ? 1 : 0, IsBeingTeleported() ? 1 : 0, isBeingLoaded() ? 1 : 0); - LOG_INFO("misc", "Player::SetMover (B2) - %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u", target->GetTypeId(), target->GetEntry(), target->GetUnitTypeMask(), target->GetGUIDLow(), target->GetMapId(), target->GetInstanceId(), target->FindMap()->GetId(), target->IsInWorld() ? 1 : 0, target->IsDuringRemoveFromWorld() ? 1 : 0, (target->ToPlayer() && target->ToPlayer()->IsBeingTeleported() ? 1 : 0), target->isBeingLoaded() ? 1 : 0); + LOG_INFO("misc", "Player::SetMover (B1) - %s, %u, %u, %u, %u, %u, %u, %u", GetGUID().ToString().c_str(), GetMapId(), GetInstanceId(), FindMap()->GetId(), IsInWorld() ? 1 : 0, IsDuringRemoveFromWorld() ? 1 : 0, IsBeingTeleported() ? 1 : 0, isBeingLoaded() ? 1 : 0); + LOG_INFO("misc", "Player::SetMover (B2) - %s, %u, %u, %u, %u, %u, %u, %u", target->GetGUID().ToString().c_str(), target->GetMapId(), target->GetInstanceId(), target->FindMap()->GetId(), target->IsInWorld() ? 1 : 0, target->IsDuringRemoveFromWorld() ? 1 : 0, (target->ToPlayer() && target->ToPlayer()->IsBeingTeleported() ? 1 : 0), target->isBeingLoaded() ? 1 : 0); } m_mover->m_movedByPlayer = nullptr; m_mover = target; @@ -25058,7 +25097,7 @@ PartyResult Player::CanUninviteFromGroup() const if (grp->isLFGGroup()) { - uint64 gguid = grp->GetGUID(); + ObjectGuid gguid = grp->GetGUID(); if (!sLFGMgr->GetKicksLeft(gguid)) return ERR_PARTY_LFG_BOOT_LIMIT; @@ -25294,7 +25333,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply) LOG_DEBUG("maps", "Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName().c_str(), target->GetEntry(), target->GetTypeId()); #endif - if (!AddUInt64Value(PLAYER_FARSIGHT, target->GetGUID())) + if (!AddGuidValue(PLAYER_FARSIGHT, target->GetGUID())) { LOG_FATAL("server", "Player::CreateViewpoint: Player %s cannot add new viewpoint!", GetName().c_str()); return; @@ -25318,7 +25357,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply) if (target->isType(TYPEMASK_UNIT) && !GetVehicle()) ((Unit*)target)->RemovePlayerFromVision(this); - if (!RemoveUInt64Value(PLAYER_FARSIGHT, target->GetGUID())) + if (!RemoveGuidValue(PLAYER_FARSIGHT, target->GetGUID())) { LOG_FATAL("server", "Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName().c_str()); return; @@ -25331,7 +25370,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply) WorldObject* Player::GetViewpoint() const { - if (uint64 guid = GetUInt64Value(PLAYER_FARSIGHT)) + if (ObjectGuid guid = GetGuidValue(PLAYER_FARSIGHT)) return (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_SEER); return nullptr; } @@ -25804,7 +25843,7 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot) // Xinef: exploit protection, dont allow to loot normal items if player is not master loot and not below loot threshold // Xinef: only quest, ffa and conditioned items - if (!item->is_underthreshold && !IS_ITEM_GUID(GetLootGUID()) && GetGroup() && GetGroup()->GetLootMethod() == MASTER_LOOT && GetGUID() != GetGroup()->GetMasterLooterGuid()) + if (!item->is_underthreshold && !GetLootGUID().IsItem() && GetGroup() && GetGroup()->GetLootMethod() == MASTER_LOOT && GetGUID() != GetGroup()->GetMasterLooterGuid()) if (qitem == nullptr && ffaitem == nullptr && conditem == nullptr) { SendLootRelease(GetLootGUID()); @@ -25874,8 +25913,8 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot) UpdateLootAchievements(item, loot); // LootItem is being removed (looted) from the container, delete it from the DB. - if (loot->containerId > 0) - sLootItemStorage->RemoveStoredLootItem(loot->containerId, item->itemid, item->count, loot); + if (loot->containerGUID) + sLootItemStorage->RemoveStoredLootItem(loot->containerGUID, item->itemid, item->count, loot); #ifdef ELUNA sEluna->OnLootItem(this, newitem, item->count, this->GetLootGUID()); @@ -25936,7 +25975,7 @@ void Player::learnSpellHighRank(uint32 spellid) void Player::_LoadSkills(PreparedQueryResult result) { // 0 1 2 - // SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", GUID_LOPART(m_guid)); + // SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", m_guid.GetCounter()); uint32 count = 0; if (result) @@ -25951,7 +25990,7 @@ void Player::_LoadSkills(PreparedQueryResult result) SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(skill); if (!pSkill) { - LOG_ERROR("server", "Character %u has skill %u that does not exist.", GetGUIDLow(), skill); + LOG_ERROR("server", "Character %s has skill %u that does not exist.", GetGUID().ToString().c_str(), skill); continue; } @@ -25969,11 +26008,11 @@ void Player::_LoadSkills(PreparedQueryResult result) } if (value == 0) { - LOG_ERROR("server", "Character %u has skill %u with value 0. Will be deleted.", GetGUIDLow(), skill); + LOG_ERROR("server", "Character %s has skill %u with value 0. Will be deleted.", GetGUID().ToString().c_str(), skill); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_SKILL); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt16(1, skill); CharacterDatabase.Execute(stmt); @@ -25998,7 +26037,7 @@ void Player::_LoadSkills(PreparedQueryResult result) if (count >= PLAYER_MAX_SKILLS) // client limit { - LOG_ERROR("server", "Character %u has more than %u skills.", GetGUIDLow(), PLAYER_MAX_SKILLS); + LOG_ERROR("server", "Character %s has more than %u skills.", GetGUID().ToString().c_str(), PLAYER_MAX_SKILLS); break; } } while (result->NextRow()); @@ -26337,7 +26376,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) #endif } -void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank) +void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank) { Pet* pet = GetPet(); @@ -26713,9 +26752,9 @@ void Player::BuildEnchantmentsInfoData(WorldPacket* data) data->put<uint16>(enchantmentMaskPos, enchantmentMask); - *data << uint16(item->GetItemRandomPropertyId()); // item random property id - data->appendPackGUID(item->GetUInt64Value(ITEM_FIELD_CREATOR)); // item creator - *data << uint32(item->GetItemSuffixFactor()); // item suffix factor + *data << uint16(item->GetItemRandomPropertyId()); // item random property id + *data << item->GetGuidValue(ITEM_FIELD_CREATOR).WriteAsPacked(); // item creator + *data << uint32(item->GetItemSuffixFactor()); // item suffix factor } data->put<uint32>(slotUsedMaskPos, slotUsedMask); @@ -26738,11 +26777,11 @@ void Player::SendEquipmentSetList() data << itr->second.IconName; for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) { - // ignored slots stored in IgnoreMask, client wants "1" as raw GUID, so no HIGHGUID_ITEM + // 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)); else // xinef: send proper data (do not append 0 with high guid) - data.appendPackGUID(itr->second.Items[i] > 0 ? MAKE_NEW_GUID(itr->second.Items[i], 0, HIGHGUID_ITEM) : uint64(0)); + data.appendPackGUID(itr->second.Items[i] ? itr->second.Items[i].GetRawValue() : uint64(0)); } ++count; // client have limit but it checked at loading and set @@ -26811,8 +26850,8 @@ void Player::_SaveEquipmentSets(SQLTransaction& trans) stmt->setString(j++, eqset.IconName.c_str()); stmt->setUInt32(j++, eqset.IgnoreMask); for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i) - stmt->setUInt32(j++, eqset.Items[i]); - stmt->setUInt32(j++, GetGUIDLow()); + stmt->setUInt32(j++, eqset.Items[i].GetCounter()); + stmt->setUInt32(j++, GetGUID().GetCounter()); stmt->setUInt64(j++, eqset.Guid); stmt->setUInt32(j, index); trans->Append(stmt); @@ -26821,14 +26860,14 @@ void Player::_SaveEquipmentSets(SQLTransaction& trans) break; case EQUIPMENT_SET_NEW: stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_EQUIP_SET); - stmt->setUInt32(j++, GetGUIDLow()); + stmt->setUInt32(j++, GetGUID().GetCounter()); stmt->setUInt64(j++, eqset.Guid); stmt->setUInt32(j++, index); stmt->setString(j++, eqset.Name.c_str()); stmt->setString(j++, eqset.IconName.c_str()); stmt->setUInt32(j++, eqset.IgnoreMask); for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i) - stmt->setUInt32(j++, eqset.Items[i]); + stmt->setUInt32(j++, eqset.Items[i].GetCounter()); trans->Append(stmt); eqset.state = EQUIPMENT_SET_UNCHANGED; ++itr; @@ -26851,10 +26890,11 @@ void Player::_SaveEntryPoint(SQLTransaction& trans) return; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_ENTRY_POINT); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_ENTRY_POINT); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setFloat (1, m_entryPointData.joinPos.GetPositionX()); stmt->setFloat (2, m_entryPointData.joinPos.GetPositionY()); stmt->setFloat (3, m_entryPointData.joinPos.GetPositionZ()); @@ -26897,7 +26937,7 @@ void Player::RemoveAtLoginFlag(AtLoginFlags flags, bool persist /*= false*/) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_REM_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(flags)); - stmt->setUInt32(1, GetGUIDLow()); + stmt->setUInt32(1, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -26907,7 +26947,7 @@ void Player::SendClearCooldown(uint32 spell_id, Unit* target) { WorldPacket data(SMSG_CLEAR_COOLDOWN, 4 + 8); data << uint32(spell_id); - data << uint64(target->GetGUID()); + data << target->GetGUID(); SendDirectMessage(&data); if (target == this && NeedSendSpectatorData()) @@ -26942,7 +26982,7 @@ void Player::_SaveCharacter(bool create, SQLTransaction& trans) //! Insert query //! TO DO: Filter out more redundant fields that can take their default value at player create stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER); - stmt->setUInt32(index++, GetGUIDLow()); + stmt->setUInt32(index++, GetGUID().GetCounter()); stmt->setUInt32(index++, GetSession()->GetAccountId()); stmt->setString(index++, GetName()); stmt->setUInt8(index++, getRace(true)); @@ -26970,10 +27010,16 @@ void Player::_SaveCharacter(bool create, SQLTransaction& trans) stmt->setFloat(index++, finiteAlways(GetTransOffsetY())); stmt->setFloat(index++, finiteAlways(GetTransOffsetZ())); stmt->setFloat(index++, finiteAlways(GetTransOffsetO())); - uint32 transLowGUID = 0; - if (GetTransport()) - transLowGUID = GetTransport()->GetGUIDLow(); - stmt->setUInt32(index++, transLowGUID); + + int32 lowGuidOrSpawnId = 0; + if (Transport* transport = GetTransport()) + { + if (transport->IsMotionTransport()) + lowGuidOrSpawnId = static_cast<int32>(transport->GetGUID().GetCounter()); + else if (transport->IsStaticTransport()) + lowGuidOrSpawnId = -static_cast<int32>(transport->GetSpawnId()); + } + stmt->setInt32(index++, lowGuidOrSpawnId); std::ostringstream ss; ss << m_taxi; @@ -27102,10 +27148,16 @@ void Player::_SaveCharacter(bool create, SQLTransaction& trans) stmt->setFloat(index++, finiteAlways(GetTransOffsetY())); stmt->setFloat(index++, finiteAlways(GetTransOffsetZ())); stmt->setFloat(index++, finiteAlways(GetTransOffsetO())); - uint32 transLowGUID = 0; - if (GetTransport()) - transLowGUID = GetTransport()->GetGUIDLow(); - stmt->setUInt32(index++, transLowGUID); + + int32 lowGuidOrSpawnId = 0; + if (Transport* transport = GetTransport()) + { + if (transport->IsMotionTransport()) + lowGuidOrSpawnId = static_cast<int32>(transport->GetGUID().GetCounter()); + else if (transport->IsStaticTransport()) + lowGuidOrSpawnId = -static_cast<int32>(transport->GetSpawnId()); + } + stmt->setInt32(index++, lowGuidOrSpawnId); std::ostringstream ss; ss << m_taxi; @@ -27184,7 +27236,7 @@ void Player::_SaveCharacter(bool create, SQLTransaction& trans) stmt->setUInt8(index++, IsInWorld() && !GetSession()->PlayerLogout() ? 1 : 0); // Index - stmt->setUInt32(index++, GetGUIDLow()); + stmt->setUInt32(index++, GetGUID().GetCounter()); } trans->Append(stmt); @@ -27219,7 +27271,7 @@ void Player::_SaveGlyphs(SQLTransaction& trans) return; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_GLYPHS); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); for (uint8 spec = 0; spec < m_specsCount; ++spec) @@ -27227,7 +27279,7 @@ void Player::_SaveGlyphs(SQLTransaction& trans) uint8 index = 0; stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_GLYPHS); - stmt->setUInt32(index++, GetGUIDLow()); + stmt->setUInt32(index++, GetGUID().GetCounter()); stmt->setUInt8(index++, spec); for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i) @@ -27241,7 +27293,7 @@ void Player::_SaveGlyphs(SQLTransaction& trans) void Player::_LoadTalents(PreparedQueryResult result) { - // SetPQuery(PLAYER_LOGIN_QUERY_LOADTALENTS, "SELECT spell, specMask FROM character_talent WHERE guid = '%u'", GUID_LOPART(m_guid)); + // SetPQuery(PLAYER_LOGIN_QUERY_LOADTALENTS, "SELECT spell, specMask FROM character_talent WHERE guid = '%u'", m_guid.GetCounter()); if (result) { do @@ -27277,7 +27329,7 @@ void Player::_SaveTalents(SQLTransaction& trans) if (itr->second->State == PLAYERSPELL_REMOVED || itr->second->State == PLAYERSPELL_CHANGED) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_TALENT_BY_SPELL); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, itr->first); trans->Append(stmt); } @@ -27286,7 +27338,7 @@ void Player::_SaveTalents(SQLTransaction& trans) if (itr->second->State == PLAYERSPELL_NEW || itr->second->State == PLAYERSPELL_CHANGED) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_TALENT); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, itr->first); stmt->setUInt8(2, itr->second->specMask); trans->Append(stmt); @@ -27324,7 +27376,7 @@ void Player::UpdateSpecCount(uint8 count) for (ActionButtonList::iterator itr = m_actionButtons.begin(); itr != m_actionButtons.end(); ++itr) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACTION); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt8(1, 1); stmt->setUInt8(2, itr->first); stmt->setUInt32(3, itr->second.GetAction()); @@ -27339,7 +27391,7 @@ void Player::UpdateSpecCount(uint8 count) stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACTION_EXCEPT_SPEC); stmt->setUInt8(0, m_activeSpec); - stmt->setUInt32(1, GetGUIDLow()); + stmt->setUInt32(1, GetGUID().GetCounter()); trans->Append(stmt); m_activeSpec = 0; @@ -27455,7 +27507,7 @@ void Player::ActivateSpec(uint8 spec) // xinef: optimization, use callback to read the data PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_ACTIONS_SPEC); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt8(1, m_activeSpec); GetSession()->_loadActionsSwitchSpecCallback = CharacterDatabase.AsyncQuery(stmt); // FutureResult @@ -27707,14 +27759,14 @@ void Player::PrepareCharmAISpells() } } -void Player::AddRefundReference(uint32 it) +void Player::AddRefundReference(ObjectGuid itemGUID) { - m_refundableItems.insert(it); + m_refundableItems.insert(itemGUID); } -void Player::DeleteRefundReference(uint32 it) +void Player::DeleteRefundReference(ObjectGuid itemGUID) { - RefundableItemsSet::iterator itr = m_refundableItems.find(it); + RefundableItemsSet::iterator itr = m_refundableItems.find(itemGUID); if (itr != m_refundableItems.end()) m_refundableItems.erase(itr); } @@ -27732,7 +27784,7 @@ void Player::SendRefundInfo(Item* item) return; } - if (GetGUIDLow() != item->GetRefundRecipient()) // Formerly refundable item got traded + if (GetGUID().GetCounter() != item->GetRefundRecipient()) // Formerly refundable item got traded { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("entities.player.items", "Item refund: item was traded!"); @@ -27751,7 +27803,7 @@ void Player::SendRefundInfo(Item* item) } WorldPacket data(SMSG_ITEM_REFUND_INFO_RESPONSE, 8 + 4 + 4 + 4 + 4 * 4 + 4 * 4 + 4 + 4); - data << uint64(item->GetGUID()); // item guid + data << item->GetGUID(); // item guid data << uint32(item->GetPaidMoney()); // money cost data << uint32(iece->reqhonorpoints); // honor point cost data << uint32(iece->reqarenapoints); // arena point cost @@ -27802,13 +27854,13 @@ void Player::RefundItem(Item* item) { item->SetNotRefundable(this); WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8 + 4); - data << uint64(item->GetGUID()); // Guid + data << item->GetGUID(); // Guid data << uint32(10); // Error! GetSession()->SendPacket(&data); return; } - if (GetGUIDLow() != item->GetRefundRecipient()) // Formerly refundable item got traded + if (GetGUID().GetCounter() != item->GetRefundRecipient()) // Formerly refundable item got traded { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("entities.player.items", "Item refund: item was traded!"); @@ -27847,14 +27899,14 @@ void Player::RefundItem(Item* item) if (store_error) { WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8 + 4); - data << uint64(item->GetGUID()); // Guid + data << item->GetGUID(); // Guid data << uint32(10); // Error! GetSession()->SendPacket(&data); return; } WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8 + 4 + 4 + 4 + 4 + 4 * 4 + 4 * 4); - data << uint64(item->GetGUID()); // item guid + data << item->GetGUID(); // item guid data << uint32(0); // 0, or error code data << uint32(item->GetPaidMoney()); // money cost data << uint32(iece->reqhonorpoints); // honor point cost @@ -27915,7 +27967,7 @@ void Player::SetRandomWinner(bool isWinner) if (m_IsBGRandomWinner) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_BATTLEGROUND_RANDOM); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } } @@ -28014,11 +28066,11 @@ void Player::_LoadBrewOfTheMonth(PreparedQueryResult result) SQLTransaction trans = CharacterDatabase.BeginTransaction(); MailSender sender(MAIL_CREATURE, 27487 /*NPC_BREW_OF_THE_MONTH_CLUB*/); MailDraft draft(uint16(212 + month)); // 212 is starting template id - draft.SendMailTo(trans, MailReceiver(this, GetGUIDLow()), sender); + draft.SendMailTo(trans, MailReceiver(this, GetGUID().GetCounter()), sender); // Update Event Id PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_BREW_OF_THE_MONTH); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, uint32(eventId)); trans->Append(stmt); @@ -28045,7 +28097,7 @@ void Player::_SaveInstanceTimeRestrictions(SQLTransaction& trans) } } -bool Player::IsInWhisperWhiteList(uint64 guid) +bool Player::IsInWhisperWhiteList(ObjectGuid guid) { for (WhisperListContainer::const_iterator itr = WhisperList.begin(); itr != WhisperList.end(); ++itr) if (*itr == guid) @@ -28060,12 +28112,12 @@ bool Player::SetDisableGravity(bool disable, bool packetOnly /*= false*/) return false; WorldPacket data(disable ? SMSG_MOVE_GRAVITY_DISABLE : SMSG_MOVE_GRAVITY_ENABLE, 12); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(0); //! movement counter SendDirectMessage(&data); data.Initialize(MSG_MOVE_GRAVITY_CHNG, 64); - data.append(GetPackGUID()); + data << GetPackGUID(); BuildMovementPacket(&data); SendMessageToSet(&data, false); return true; @@ -28080,12 +28132,12 @@ bool Player::SetCanFly(bool apply, bool packetOnly /*= false*/) SetFallInformation(time(nullptr), GetPositionZ()); WorldPacket data(apply ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY, 12); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(0); //! movement counter SendDirectMessage(&data); data.Initialize(MSG_MOVE_UPDATE_CAN_FLY, 64); - data.append(GetPackGUID()); + data << GetPackGUID(); BuildMovementPacket(&data); SendMessageToSet(&data, false); return true; @@ -28097,12 +28149,12 @@ bool Player::SetHover(bool apply, bool packetOnly /*= false*/) return false; WorldPacket data(apply ? SMSG_MOVE_SET_HOVER : SMSG_MOVE_UNSET_HOVER, 12); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(0); //! movement counter SendDirectMessage(&data); data.Initialize(MSG_MOVE_HOVER, 64); - data.append(GetPackGUID()); + data << GetPackGUID(); BuildMovementPacket(&data); SendMessageToSet(&data, false); return true; @@ -28114,12 +28166,12 @@ bool Player::SetWaterWalking(bool apply, bool packetOnly /*= false*/) return false; WorldPacket data(apply ? SMSG_MOVE_WATER_WALK : SMSG_MOVE_LAND_WALK, 12); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(0); //! movement counter SendDirectMessage(&data); data.Initialize(MSG_MOVE_WATER_WALK, 64); - data.append(GetPackGUID()); + data << GetPackGUID(); BuildMovementPacket(&data); SendMessageToSet(&data, false); return true; @@ -28135,12 +28187,12 @@ bool Player::SetFeatherFall(bool apply, bool packetOnly /*= false*/) } WorldPacket data(apply ? SMSG_MOVE_FEATHER_FALL : SMSG_MOVE_NORMAL_FALL, 12); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(0); //! movement counter SendDirectMessage(&data); data.Initialize(MSG_MOVE_FEATHER_FALL, 64); - data.append(GetPackGUID()); + data << GetPackGUID(); BuildMovementPacket(&data); SendMessageToSet(&data, false); return true; @@ -28288,7 +28340,7 @@ Guild* Player::GetGuild() const return guildId ? sGuildMgr->GetGuildById(guildId) : nullptr; } -void Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration, uint32 createdBySpell, uint64 casterGUID, uint8 asynchLoadType) +void Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration, uint32 createdBySpell, ObjectGuid casterGUID, uint8 asynchLoadType) { Position pos = {x, y, z, ang}; if (!pos.IsPositionValid()) @@ -28305,7 +28357,7 @@ bool Player::IsPetDismissed() * Changes the slot flag, they will break this validation. */ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT); - stmt->setUInt32(0, GetGUIDLow()); + stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt8(1, uint8(PET_SAVE_NOT_IN_SLOT)); if (PreparedQueryResult result = CharacterDatabase.AsyncQuery(stmt)) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 6cafa79908..1dd9c502d0 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -156,7 +156,7 @@ typedef std::unordered_map<uint32, PlayerTalent*> PlayerTalentMap; typedef std::unordered_map<uint32, PlayerSpell*> PlayerSpellMap; typedef std::list<SpellModifier*> SpellModList; -typedef std::list<uint64> WhisperListContainer; +typedef GuidList WhisperListContainer; struct SpellCooldown { @@ -503,7 +503,8 @@ enum AtLoginFlags AT_LOGIN_CHANGE_RACE = 0x80, AT_LOGIN_RESET_AP = 0x100, AT_LOGIN_RESET_ARENA = 0x200, - AT_LOGIN_CHECK_ACHIEVS = 0x400 + AT_LOGIN_CHECK_ACHIEVS = 0x400, + AT_LOGIN_RESURRECT = 0x800 }; typedef std::map<uint32, QuestStatusData> QuestStatusMap; @@ -642,17 +643,13 @@ enum EquipmentSetUpdateState struct EquipmentSet { - EquipmentSet() - { - for (unsigned int & Item : Items) - Item = 0; - } + EquipmentSet() { } - uint64 Guid{0}; + uint64 Guid; std::string Name; std::string IconName; uint32 IgnoreMask{0}; - uint32 Items[EQUIPMENT_SLOT_END]; + ObjectGuid Items[EQUIPMENT_SLOT_END]; EquipmentSetUpdateState state{EQUIPMENT_SET_NEW}; }; @@ -791,7 +788,8 @@ enum PlayerLoginQueryIndex PLAYER_LOGIN_QUERY_LOAD_SEASONAL_QUEST_STATUS = 31, PLAYER_LOGIN_QUERY_LOAD_MONTHLY_QUEST_STATUS = 32, PLAYER_LOGIN_QUERY_LOAD_BREW_OF_THE_MONTH = 34, - MAX_PLAYER_LOGIN_QUERY, + PLAYER_LOGIN_QUERY_LOAD_CORPSE_LOCATION = 35, + MAX_PLAYER_LOGIN_QUERY }; enum PlayerDelayedOperations @@ -983,7 +981,7 @@ struct BGData bool isInvited{false}; bool bgIsRandom{false}; - std::set<uint32> bgAfkReporter; + GuidSet bgAfkReporter; uint8 bgAfkReportedCount{0}; time_t bgAfkReportedTimer{0}; }; @@ -1007,23 +1005,23 @@ struct EntryPointData class TradeData { public: // constructors - TradeData(Player* player, Player* trader) : - m_player(player), m_trader(trader), m_accepted(false), m_acceptProccess(false), - m_money(0), m_spell(0), m_spellCastItem(0) { memset(m_items, 0, TRADE_SLOT_COUNT * sizeof(uint64)); } + TradeData(Player* player, Player* trader) : m_player(player), m_trader(trader), m_accepted(false), m_acceptProccess(false), m_money(0), m_spell(0) + { + } [[nodiscard]] Player* GetTrader() const { return m_trader; } [[nodiscard]] TradeData* GetTraderData() const; [[nodiscard]] Item* GetItem(TradeSlots slot) const; - [[nodiscard]] bool HasItem(uint64 itemGuid) const; - [[nodiscard]] TradeSlots GetTradeSlotForItem(uint64 itemGuid) const; + [[nodiscard]] bool HasItem(ObjectGuid itemGuid) const; + [[nodiscard]] TradeSlots GetTradeSlotForItem(ObjectGuid itemGuid) const; void SetItem(TradeSlots slot, Item* item); [[nodiscard]] uint32 GetSpell() const { return m_spell; } void SetSpell(uint32 spell_id, Item* castItem = nullptr); [[nodiscard]] Item* GetSpellCastItem() const; - [[nodiscard]] bool HasSpellCastItem() const { return m_spellCastItem != 0; } + [[nodiscard]] bool HasSpellCastItem() const { return m_spellCastItem; } [[nodiscard]] uint32 GetMoney() const { return m_money; } void SetMoney(uint32 money); @@ -1047,9 +1045,9 @@ private: // fields uint32 m_money; // m_player place money to trade uint32 m_spell; // m_player apply spell to non-traded slot item - uint64 m_spellCastItem; // applied spell casted by item use + ObjectGuid m_spellCastItem; // applied spell casted by item use - uint64 m_items[TRADE_SLOT_COUNT]; // traded itmes from m_player side including non-traded slot + ObjectGuid m_items[TRADE_SLOT_COUNT]; // traded itmes from m_player side including non-traded slot }; class KillRewarder @@ -1128,10 +1126,10 @@ public: } [[nodiscard]] bool IsSummonAsSpectator() const { return m_summon_asSpectator && m_summon_expire >= time(nullptr); } void SetSummonAsSpectator(bool on) { m_summon_asSpectator = on; } - void SummonIfPossible(bool agree, uint32 summoner_guid); + void SummonIfPossible(bool agree, ObjectGuid summoner_guid); [[nodiscard]] time_t GetSummonExpireTimer() const { return m_summon_expire; } - bool Create(uint32 guidlow, CharacterCreateInfo* createInfo); + bool Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo); void Update(uint32 time) override; @@ -1150,8 +1148,8 @@ public: void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool onEnterMap); bool CanInteractWithQuestGiver(Object* questGiver); - Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask); - [[nodiscard]] GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const; + Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask); + [[nodiscard]] GameObject* GetGameObjectIfCanInteractWith(ObjectGuid guid, GameobjectTypes type) const; void ToggleAFK(); void ToggleDND(); @@ -1220,14 +1218,14 @@ public: [[nodiscard]] Pet* GetPet() const; bool IsPetDismissed(); - void SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime, uint32 createdBySpell, uint64 casterGUID, uint8 asynchLoadType); + void SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime, uint32 createdBySpell, ObjectGuid casterGUID, uint8 asynchLoadType); void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false); [[nodiscard]] uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn void Say(std::string const& text, const uint32 language); void Yell(std::string const& text, const uint32 language); void TextEmote(std::string const& text); - void Whisper(std::string const& text, const uint32 language, uint64 receiver); + void Whisper(std::string const& text, const uint32 language, ObjectGuid receiver); /*********************************************************/ /*** STORAGE SYSTEM ***/ @@ -1238,7 +1236,7 @@ public: uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const; uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = nullptr) const; uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const; - [[nodiscard]] Item* GetItemByGuid(uint64 guid) const; + [[nodiscard]] Item* GetItemByGuid(ObjectGuid guid) const; [[nodiscard]] Item* GetItemByEntry(uint32 entry) const; [[nodiscard]] Item* GetItemByPos(uint16 pos) const; [[nodiscard]] Item* GetItemByPos(uint8 bag, uint8 slot) const; @@ -1314,8 +1312,8 @@ public: InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = nullptr) const; InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = nullptr, bool swap = false, uint32* no_space_count = nullptr) const; - void AddRefundReference(uint32 it); - void DeleteRefundReference(uint32 it); + void AddRefundReference(ObjectGuid itemGUID); + void DeleteRefundReference(ObjectGuid itemGUID); void ApplyEquipCooldown(Item* pItem); void SetAmmo(uint32 item); @@ -1349,7 +1347,7 @@ public: [[nodiscard]] uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END - KEYRING_SLOT_START; } void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = nullptr, uint32 itemid = 0); void SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param); - void SendSellError(SellResult msg, Creature* creature, uint64 guid, uint32 param); + void SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param); void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; } void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; } [[nodiscard]] uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } @@ -1361,7 +1359,7 @@ public: return mainItem && mainItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip(); } void SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast = false, bool sendChatMessage = true); - bool BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); + bool BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore); float GetReputationPriceDiscount(Creature const* creature) const; @@ -1388,7 +1386,7 @@ public: void AddItemDurations(Item* item); void RemoveItemDurations(Item* item); void SendItemDurations(); - void LoadCorpse(); + void LoadCorpse(PreparedQueryResult result); void LoadPet(); bool AddItem(uint32 itemId, uint32 count); @@ -1415,10 +1413,10 @@ public: int32 GetQuestLevel(Quest const* quest) const { return quest && (quest->GetQuestLevel() > 0) ? quest->GetQuestLevel() : getLevel(); } - void PrepareQuestMenu(uint64 guid); - void SendPreparedQuest(uint64 guid); + void PrepareQuestMenu(ObjectGuid guid); + void SendPreparedQuest(ObjectGuid guid); [[nodiscard]] bool IsActiveQuest(uint32 quest_id) const; - Quest const* GetNextQuest(uint64 guid, Quest const* quest); + Quest const* GetNextQuest(ObjectGuid guid, Quest const* quest); bool CanSeeStartQuest(Quest const* quest); bool CanTakeQuest(Quest const* quest, bool msg); bool CanAddQuest(Quest const* quest, bool msg); @@ -1509,11 +1507,11 @@ public: void GroupEventHappens(uint32 questId, WorldObject const* pEventObject); void ItemAddedQuestCheck(uint32 entry, uint32 count); void ItemRemovedQuestCheck(uint32 entry, uint32 count); - void KilledMonster(CreatureTemplate const* cInfo, uint64 guid); - void KilledMonsterCredit(uint32 entry, uint64 guid); + void KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid); + void KilledMonsterCredit(uint32 entry, ObjectGuid guid = ObjectGuid::Empty); void KilledPlayerCredit(); - void KillCreditGO(uint32 entry, uint64 guid = 0); - void TalkedToCreature(uint32 entry, uint64 guid); + void KillCreditGO(uint32 entry, ObjectGuid guid = ObjectGuid::Empty); + void TalkedToCreature(uint32 entry, ObjectGuid guid); void MoneyChanged(uint32 value); void ReputationChanged(FactionEntry const* factionEntry); void ReputationChanged2(FactionEntry const* factionEntry); @@ -1530,11 +1528,11 @@ public: void SendQuestConfirmAccept(Quest const* quest, Player* pReceiver); void SendPushToPartyResponse(Player const* player, uint8 msg) const; void SendQuestUpdateAddItem(Quest const* quest, uint32 item_idx, uint16 count); - void SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uint32 creatureOrGO_idx, uint16 old_count, uint16 add_count); + void SendQuestUpdateAddCreatureOrGo(Quest const* quest, ObjectGuid guid, uint32 creatureOrGO_idx, uint16 old_count, uint16 add_count); void SendQuestUpdateAddPlayer(Quest const* quest, uint16 old_count, uint16 add_count); - uint64 GetDivider() { return m_divider; } - void SetDivider(uint64 guid) { m_divider = guid; } + ObjectGuid GetDivider() { return m_divider; } + void SetDivider(ObjectGuid guid = ObjectGuid::Empty) { m_divider = guid; } uint32 GetInGameTime() { return m_ingametime; } @@ -1549,15 +1547,15 @@ public: /*** LOAD SYSTEM ***/ /*********************************************************/ - bool LoadFromDB(uint32 guid, SQLQueryHolder* holder); + bool LoadFromDB(ObjectGuid guid, SQLQueryHolder* holder); [[nodiscard]] bool isBeingLoaded() const override; - void Initialize(uint32 guid); + void Initialize(ObjectGuid::LowType guid); static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index); static float GetFloatValueFromArray(Tokenizer const& data, uint16 index); - static uint32 GetZoneIdFromDB(uint64 guid); - static uint32 GetLevelFromStorage(uint64 guid); - static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, uint64 guid); + static uint32 GetZoneIdFromDB(ObjectGuid guid); + static uint32 GetLevelFromStorage(ObjectGuid::LowType guid); + static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid::LowType guid); static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; } @@ -1571,17 +1569,17 @@ public: static void SetUInt32ValueInArray(Tokenizer& data, uint16 index, uint32 value); static void SetFloatValueInArray(Tokenizer& data, uint16 index, float value); - static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair); - static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, uint64 guid); + static void Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair); + static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, ObjectGuid guid); - static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars, bool deleteFinally); + static void DeleteFromDB(ObjectGuid::LowType lowGuid, uint32 accountId, bool updateRealmChars, bool deleteFinally); static void DeleteOldCharacters(); static void DeleteOldCharacters(uint32 keepDays); bool m_mailsUpdated; - void SetBindPoint(uint64 guid); - void SendTalentWipeConfirm(uint64 guid); + void SetBindPoint(ObjectGuid guid); + void SendTalentWipeConfirm(ObjectGuid guid); void ResetPetTalents(); void CalcRage(uint32 damage, bool attacker); void RegenerateAll(); @@ -1620,17 +1618,17 @@ public: [[nodiscard]] Unit* GetSelectedUnit() const; [[nodiscard]] Player* GetSelectedPlayer() const; - void SetTarget(uint64 /*guid*/) override { } /// Used for serverside target changes, does not apply to players - void SetSelection(uint64 guid); + void SetTarget(ObjectGuid /*guid*/ = ObjectGuid::Empty) override { } /// Used for serverside target changes, does not apply to players + void SetSelection(ObjectGuid guid); [[nodiscard]] uint8 GetComboPoints() const { return m_comboPoints; } - [[nodiscard]] uint64 GetComboTarget() const { return m_comboTarget; } + [[nodiscard]] ObjectGuid GetComboTarget() const { return m_comboTarget; } void AddComboPoints(Unit* target, int8 count); void ClearComboPoints(); void SendComboPoints(); - void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0); + void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, ObjectGuid::LowType item_guid = 0, uint32 item_count = 0); void SendNewMail(); void UpdateNextMailTimeAndUnreads(); void AddNewMailDeliverTime(time_t deliver_time); @@ -1653,13 +1651,13 @@ public: uint32 totalMailCount; time_t m_nextMailDelivereTime; - typedef std::unordered_map<uint32, Item*> ItemMap; + typedef std::unordered_map<ObjectGuid::LowType, Item*> ItemMap; ItemMap mMitems; //template defined in objectmgr.cpp - Item* GetMItem(uint32 id) + Item* GetMItem(ObjectGuid::LowType itemLowGuid) { - ItemMap::const_iterator itr = mMitems.find(id); + ItemMap::const_iterator itr = mMitems.find(itemLowGuid); return itr != mMitems.end() ? itr->second : nullptr; } @@ -1667,12 +1665,12 @@ public: { ASSERT(it); //ASSERT deleted, because items can be added before loading - mMitems[it->GetGUIDLow()] = it; + mMitems[it->GetGUID().GetCounter()] = it; } - bool RemoveMItem(uint32 id) + bool RemoveMItem(ObjectGuid::LowType itemLowGuid) { - return !!mMitems.erase(id); + return !!mMitems.erase(itemLowGuid); } void PetSpellInitialize(); @@ -1710,7 +1708,7 @@ public: void BuildPetTalentsInfoData(WorldPacket* data); void SendTalentsInfoData(bool pet); void LearnTalent(uint32 talentId, uint32 talentRank); - void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank); + void LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank); bool addTalent(uint32 spellId, uint8 addSpecMask, uint8 oldTalentRank); void _removeTalent(PlayerTalentMap::iterator& itr, uint8 specMask); @@ -1806,7 +1804,7 @@ public: void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; } void UpdatePotionCooldown(); - void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) + void setResurrectRequestData(ObjectGuid guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) { m_resurrectGUID = guid; m_resurrectMap = mapId; @@ -1816,9 +1814,9 @@ public: m_resurrectHealth = health; m_resurrectMana = mana; } - void clearResurrectRequestData() { setResurrectRequestData(0, 0, 0.0f, 0.0f, 0.0f, 0, 0); } - [[nodiscard]] bool isResurrectRequestedBy(uint64 guid) const { return m_resurrectGUID && m_resurrectGUID == guid; } - [[nodiscard]] bool isResurrectRequested() const { return m_resurrectGUID != 0; } + void clearResurrectRequestData() { setResurrectRequestData(ObjectGuid::Empty, 0, 0.0f, 0.0f, 0.0f, 0, 0); } + [[nodiscard]] bool isResurrectRequestedBy(ObjectGuid guid) const { return m_resurrectGUID && m_resurrectGUID == guid; } + [[nodiscard]] bool isResurrectRequested() const { return m_resurrectGUID; } void ResurectUsingRequestData(); [[nodiscard]] uint8 getCinematic() const @@ -1881,7 +1879,7 @@ public: bool IsInSameGroupWith(Player const* p) const; bool IsInSameRaidWith(Player const* p) const { return p == this || (GetGroup() != nullptr && GetGroup() == p->GetGroup()); } void UninviteFromGroup(); - static void RemoveFromGroup(Group* group, uint64 guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, uint64 kicker = 0, const char* reason = nullptr); + static void RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, const char* reason = nullptr); void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); } void SendUpdateToOutOfRangeGroupMembers(); @@ -1889,18 +1887,18 @@ public: { SetUInt32Value(PLAYER_GUILDID, GuildId); // xinef: update global storage - sWorld->UpdateGlobalPlayerGuild(GetGUIDLow(), GuildId); + sWorld->UpdateGlobalPlayerGuild(GetGUID().GetCounter(), GuildId); } void SetRank(uint8 rankId) { SetUInt32Value(PLAYER_GUILDRANK, rankId); } [[nodiscard]] uint8 GetRank() const { return uint8(GetUInt32Value(PLAYER_GUILDRANK)); } void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } [[nodiscard]] uint32 GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); } [[nodiscard]] Guild* GetGuild() const; - static uint32 GetGuildIdFromStorage(uint32 guid); - static uint32 GetGroupIdFromStorage(uint32 guid); - static uint32 GetArenaTeamIdFromStorage(uint32 guid, uint8 slot); + static uint32 GetGuildIdFromStorage(ObjectGuid::LowType guid); + static uint32 GetGroupIdFromStorage(ObjectGuid::LowType guid); + static uint32 GetArenaTeamIdFromStorage(ObjectGuid::LowType guid, uint8 slot); uint32 GetGuildIdInvited() { return m_GuildIdInvited; } - static void RemovePetitionsAndSigns(uint64 guid, uint32 type); + static void RemovePetitionsAndSigns(ObjectGuid guid, uint32 type); // Arena Team void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type) @@ -1910,8 +1908,8 @@ public: } void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value); uint32 GetArenaPersonalRating(uint8 slot) const; - static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot); - static void LeaveAllArenaTeams(uint64 guid); + static uint32 GetArenaTeamIdFromDB(ObjectGuid guid, uint8 slot); + static void LeaveAllArenaTeams(ObjectGuid guid); [[nodiscard]] uint32 GetArenaTeamId(uint8 slot) const; void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; } uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; } @@ -1989,8 +1987,8 @@ public: void UpdateManaRegen(); void UpdateRuneRegen(RuneType rune); - [[nodiscard]] uint64 GetLootGUID() const { return m_lootGuid; } - void SetLootGUID(uint64 guid) { m_lootGuid = guid; } + [[nodiscard]] ObjectGuid GetLootGUID() const { return m_lootGuid; } + void SetLootGUID(ObjectGuid guid) { m_lootGuid = guid; } void RemovedInsignia(Player* looterPlr); @@ -2012,7 +2010,7 @@ public: void SendDungeonDifficulty(bool IsInGroup); void SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty = -1); - static void ResetInstances(uint64 guid, uint8 method, bool isRaid); + static void ResetInstances(ObjectGuid guid, uint8 method, bool isRaid); void SendResetInstanceSuccess(uint32 MapId); void SendResetInstanceFailed(uint32 reason, uint32 MapId); void SendResetFailedNotify(uint32 mapid); @@ -2029,9 +2027,12 @@ public: void SendTeleportAckPacket(); [[nodiscard]] Corpse* GetCorpse() const; - void SpawnCorpseBones(); - void CreateCorpse(); + void SpawnCorpseBones(bool triggerSave = true); + Corpse* CreateCorpse(); void KillPlayer(); + static void OfflineResurrect(ObjectGuid const guid, SQLTransaction& trans); + bool HasCorpse() const { return _corpseLocation.GetMapId() != MAPID_INVALID; } + WorldLocation GetCorpseLocation() const { return _corpseLocation; } uint32 GetResurrectionSpellId(); void ResurrectPlayer(float restore_percent, bool applySickness = false); void BuildPlayerRepop(); @@ -2228,9 +2229,9 @@ public: PlayerMenu* PlayerTalkClass; std::vector<ItemSetEffect*> ItemSetEff; - void SendLoot(uint64 guid, LootType loot_type); - void SendLootError(uint64 guid, LootError error); - void SendLootRelease(uint64 guid); + void SendLoot(ObjectGuid guid, LootType loot_type); + void SendLootError(ObjectGuid guid, LootError error); + void SendLootRelease(ObjectGuid guid); void SendNotifyLootItemRemoved(uint8 lootSlot); void SendNotifyLootMoneyRemoved(); @@ -2394,12 +2395,11 @@ public: void SetEntryPoint(); // currently visible objects at player client - typedef std::unordered_set<uint64> ClientGUIDs; - ClientGUIDs m_clientGUIDs; + GuidUnorderedSet m_clientGUIDs; std::vector<Unit*> m_newVisible; // pussywizard bool HaveAtClient(WorldObject const* u) const { return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end(); } - [[nodiscard]] bool HaveAtClient(uint64 guid) const { return guid == GetGUID() || m_clientGUIDs.find(guid) != m_clientGUIDs.end(); } + [[nodiscard]] bool HaveAtClient(ObjectGuid guid) const { return guid == GetGUID() || m_clientGUIDs.find(guid) != m_clientGUIDs.end(); } [[nodiscard]] bool IsNeverVisible() const override; @@ -2560,8 +2560,8 @@ public: bool isDebugAreaTriggers; void ClearWhisperWhiteList() { WhisperList.clear(); } - void AddWhisperWhiteList(uint64 guid) { WhisperList.push_back(guid); } - bool IsInWhisperWhiteList(uint64 guid); + void AddWhisperWhiteList(ObjectGuid guid) { WhisperList.push_back(guid); } + bool IsInWhisperWhiteList(ObjectGuid guid); bool SetDisableGravity(bool disable, bool packetOnly /* = false */) override; bool SetCanFly(bool apply, bool packetOnly = false) override; @@ -2583,18 +2583,18 @@ public: [[nodiscard]] bool HasPendingSpectatorForBG(uint32 bgInstanceId) const { return m_pendingSpectatorForBG == bgInstanceId; } void SetPendingSpectatorInviteInstanceId(uint32 bgInstanceId) { m_pendingSpectatorInviteInstanceId = bgInstanceId; } [[nodiscard]] uint32 GetPendingSpectatorInviteInstanceId() const { return m_pendingSpectatorInviteInstanceId; } - bool HasReceivedSpectatorResetFor(uint32 guid) { return m_receivedSpectatorResetFor.find(guid) != m_receivedSpectatorResetFor.end(); } + bool HasReceivedSpectatorResetFor(ObjectGuid guid) { return m_receivedSpectatorResetFor.find(guid) != m_receivedSpectatorResetFor.end(); } void ClearReceivedSpectatorResetFor() { m_receivedSpectatorResetFor.clear(); } - void AddReceivedSpectatorResetFor(uint32 guid) { m_receivedSpectatorResetFor.insert(guid); } - void RemoveReceivedSpectatorResetFor(uint32 guid) { m_receivedSpectatorResetFor.erase(guid); } + void AddReceivedSpectatorResetFor(ObjectGuid guid) { m_receivedSpectatorResetFor.insert(guid); } + void RemoveReceivedSpectatorResetFor(ObjectGuid guid) { m_receivedSpectatorResetFor.erase(guid); } uint32 m_pendingSpectatorForBG; uint32 m_pendingSpectatorInviteInstanceId; - std::set<uint32> m_receivedSpectatorResetFor; + GuidSet m_receivedSpectatorResetFor; // Dancing Rune weapon - void setRuneWeaponGUID(uint64 guid) { m_drwGUID = guid; }; - uint64 getRuneWeaponGUID() { return m_drwGUID; }; - uint64 m_drwGUID; + void setRuneWeaponGUID(ObjectGuid guid) { m_drwGUID = guid; }; + ObjectGuid getRuneWeaponGUID() { return m_drwGUID; }; + ObjectGuid m_drwGUID; [[nodiscard]] bool CanSeeDKPet() const { return m_ExtraFlags & PLAYER_EXTRA_SHOW_DK_PET; } void SetShowDKPet(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_SHOW_DK_PET; else m_ExtraFlags &= ~PLAYER_EXTRA_SHOW_DK_PET; }; @@ -2682,7 +2682,7 @@ protected: QuestSet m_monthlyquests; SeasonalEventQuestMap m_seasonalquests; - uint64 m_divider; + ObjectGuid m_divider; uint32 m_ingametime; /*********************************************************/ @@ -2755,7 +2755,7 @@ protected: time_t m_lastHonorUpdateTime; void outDebugValues() const; - uint64 m_lootGuid; + ObjectGuid m_lootGuid; TeamId m_team; uint32 m_nextSave; // pussywizard @@ -2778,7 +2778,7 @@ protected: uint32 m_ExtraFlags; - uint64 m_comboTarget; + ObjectGuid m_comboTarget; int8 m_comboPoints; QuestStatusMap m_QuestStatus; @@ -2823,7 +2823,7 @@ protected: ItemDurationList m_itemSoulboundTradeable; std::mutex m_soulboundTradableLock; - uint64 m_resurrectGUID; + ObjectGuid m_resurrectGUID; uint32 m_resurrectMap; float m_resurrectX, m_resurrectY, m_resurrectZ; uint32 m_resurrectHealth, m_resurrectMana; @@ -2915,7 +2915,7 @@ private: Item* _StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update); Item* _LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, Field* fields); - typedef std::set<uint32> RefundableItemsSet; + typedef GuidSet RefundableItemsSet; RefundableItemsSet m_refundableItems; void SendRefundInfo(Item* item); void RefundItem(Item* item); @@ -2984,6 +2984,8 @@ private: FlyByCameraCollection* m_cinematicCamera; Position m_remoteSightPosition; Creature* m_CinematicObject; + + WorldLocation _corpseLocation; }; void AddItemsSetItem(Player* player, Item* item); diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index 1181981c8b..7db1ef1827 100644 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -26,7 +26,7 @@ uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag) const return counter; } -bool PlayerSocial::AddToSocialList(uint64 friendGuid, SocialFlag flag) +bool PlayerSocial::AddToSocialList(ObjectGuid friendGuid, SocialFlag flag) { // check client limits if (GetNumberOfSocialsWithFlag(flag) >= (((flag & SOCIAL_FLAG_FRIEND) != 0) ? SOCIALMGR_FRIEND_LIMIT : SOCIALMGR_IGNORE_LIMIT)) @@ -40,8 +40,8 @@ bool PlayerSocial::AddToSocialList(uint64 friendGuid, SocialFlag flag) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_CHARACTER_SOCIAL_FLAGS); stmt->setUInt8(0, itr->second.Flags); - stmt->setUInt32(1, GetPlayerGUID()); - stmt->setUInt32(2, friendGuid); + stmt->setUInt32(1, GetPlayerGUID().GetCounter()); + stmt->setUInt32(2, friendGuid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -51,8 +51,8 @@ bool PlayerSocial::AddToSocialList(uint64 friendGuid, SocialFlag flag) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SOCIAL); - stmt->setUInt32(0, GetPlayerGUID()); - stmt->setUInt32(1, friendGuid); + stmt->setUInt32(0, GetPlayerGUID().GetCounter()); + stmt->setUInt32(1, friendGuid.GetCounter()); stmt->setUInt8(2, flag); CharacterDatabase.Execute(stmt); @@ -60,7 +60,7 @@ bool PlayerSocial::AddToSocialList(uint64 friendGuid, SocialFlag flag) return true; } -void PlayerSocial::RemoveFromSocialList(uint64 friendGuid, SocialFlag flag) +void PlayerSocial::RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag) { auto itr = m_playerSocialMap.find(friendGuid); if (itr == m_playerSocialMap.end()) // not exist @@ -72,8 +72,8 @@ void PlayerSocial::RemoveFromSocialList(uint64 friendGuid, SocialFlag flag) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_SOCIAL); - stmt->setUInt32(0, GetPlayerGUID()); - stmt->setUInt32(1, friendGuid); + stmt->setUInt32(0, GetPlayerGUID().GetCounter()); + stmt->setUInt32(1, friendGuid.GetCounter()); CharacterDatabase.Execute(stmt); @@ -84,14 +84,14 @@ void PlayerSocial::RemoveFromSocialList(uint64 friendGuid, SocialFlag flag) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_REM_CHARACTER_SOCIAL_FLAGS); stmt->setUInt8(0, flag); - stmt->setUInt32(1, GetPlayerGUID()); - stmt->setUInt32(2, friendGuid); + stmt->setUInt32(1, GetPlayerGUID().GetCounter()); + stmt->setUInt32(2, friendGuid.GetCounter()); CharacterDatabase.Execute(stmt); } } -void PlayerSocial::SetFriendNote(uint64 friendGuid, std::string note) +void PlayerSocial::SetFriendNote(ObjectGuid friendGuid, std::string note) { auto itr = m_playerSocialMap.find(friendGuid); if (itr == m_playerSocialMap.end()) // not exist @@ -102,8 +102,8 @@ void PlayerSocial::SetFriendNote(uint64 friendGuid, std::string note) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_SOCIAL_NOTE); stmt->setString(0, note); - stmt->setUInt32(1, GetPlayerGUID()); - stmt->setUInt32(2, friendGuid); + stmt->setUInt32(1, GetPlayerGUID().GetCounter()); + stmt->setUInt32(2, friendGuid.GetCounter()); CharacterDatabase.Execute(stmt); @@ -145,7 +145,7 @@ void PlayerSocial::SendSocialList(Player* player, uint32 flags) sSocialMgr->GetFriendInfo(player, itr.first, friendInfo); - data << uint64(itr.first); // player guid + data << itr.first; // player guid data << uint32(contactFlags); // player flag (0x1 = Friend, 0x2 = Ignored, 0x4 = Muted) data << friendInfo.Note; // string note if (contactFlags & SOCIAL_FLAG_FRIEND) // if IsFriend() @@ -165,7 +165,7 @@ void PlayerSocial::SendSocialList(Player* player, uint32 flags) LOG_DEBUG("network", "WORLD: Sent SMSG_CONTACT_LIST"); } -bool PlayerSocial::_checkContact(uint64 guid, SocialFlag flags) const +bool PlayerSocial::_checkContact(ObjectGuid guid, SocialFlag flags) const { const auto& itr = m_playerSocialMap.find(guid); if (itr != m_playerSocialMap.end()) @@ -174,12 +174,12 @@ bool PlayerSocial::_checkContact(uint64 guid, SocialFlag flags) const return false; } -bool PlayerSocial::HasFriend(uint64 friend_guid) const +bool PlayerSocial::HasFriend(ObjectGuid friend_guid) const { return _checkContact(friend_guid, SOCIAL_FLAG_FRIEND); } -bool PlayerSocial::HasIgnore(uint64 ignore_guid) const +bool PlayerSocial::HasIgnore(ObjectGuid ignore_guid) const { return _checkContact(ignore_guid, SOCIAL_FLAG_IGNORED); } @@ -198,7 +198,7 @@ SocialMgr* SocialMgr::instance() return &instance; } -void SocialMgr::GetFriendInfo(Player* player, uint64 friendGUID, FriendInfo& friendInfo) +void SocialMgr::GetFriendInfo(Player* player, ObjectGuid friendGUID, FriendInfo& friendInfo) { if (!player) return; @@ -208,7 +208,7 @@ void SocialMgr::GetFriendInfo(Player* player, uint64 friendGUID, FriendInfo& fri friendInfo.Level = 0; friendInfo.Class = 0; - Player* pFriend = ObjectAccessor::FindPlayerInOrOutOfWorld(friendGUID); + Player* pFriend = ObjectAccessor::FindConnectedPlayer(friendGUID); if (!pFriend || AccountMgr::IsGMAccount(pFriend->GetSession()->GetSecurity())) return; @@ -236,14 +236,14 @@ void SocialMgr::GetFriendInfo(Player* player, uint64 friendGUID, FriendInfo& fri } } -void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint64 guid, WorldPacket* data) +void SocialMgr::MakeFriendStatusPacket(FriendsResult result, ObjectGuid guid, WorldPacket* data) { data->Initialize(SMSG_FRIEND_STATUS, 9); *data << uint8(result); - *data << uint64(guid); + *data << guid; } -void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, uint64 friendGuid, bool broadcast) +void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGuid friendGuid, bool broadcast) { FriendInfo fi; GetFriendInfo(player, friendGuid, fi); @@ -287,16 +287,15 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet) TeamId teamId = player->GetTeamId(); AccountTypes security = player->GetSession()->GetSecurity(); - uint32 guid = player->GetGUIDLow(); bool allowTwoSideWhoList = sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST); AccountTypes gmLevelInWhoList = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST)); for (auto const& itr : m_socialMap) { - auto const& itr2 = itr.second.m_playerSocialMap.find(guid); + auto const& itr2 = itr.second.m_playerSocialMap.find(player->GetGUID()); if (itr2 != itr.second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND)) { - Player* pFriend = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr.first, 0, HIGHGUID_PLAYER)); + Player* pFriend = ObjectAccessor::FindPlayer(itr.first); // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all @@ -306,7 +305,7 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet) } } -PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint64 guid) +PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, ObjectGuid guid) { PlayerSocial* social = &m_socialMap[guid]; social->SetPlayerGUID(guid); @@ -318,7 +317,7 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint64 guid) { Field* fields = result->Fetch(); - auto friendGuid = fields[0].GetUInt32(); + auto friendGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()); auto flags = fields[1].GetUInt8(); auto note = fields[2].GetString(); diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h index 8004b37529..9f8329c336 100644 --- a/src/server/game/Entities/Player/SocialMgr.h +++ b/src/server/game/Entities/Player/SocialMgr.h @@ -93,22 +93,22 @@ class PlayerSocial public: PlayerSocial(); // adding/removing - bool AddToSocialList(uint64 friend_guid, SocialFlag flag); - void RemoveFromSocialList(uint64 friend_guid, SocialFlag flag); - void SetFriendNote(uint64 friendGuid, std::string note); + bool AddToSocialList(ObjectGuid friend_guid, SocialFlag flag); + void RemoveFromSocialList(ObjectGuid friend_guid, SocialFlag flag); + void SetFriendNote(ObjectGuid friendGuid, std::string note); // Packet send's void SendSocialList(Player* player, uint32 flags); // Misc - bool HasFriend(uint64 friend_guid) const; - bool HasIgnore(uint64 ignore_guid) const; - uint64 GetPlayerGUID() const { return m_playerGUID; } - void SetPlayerGUID(uint64 guid) { m_playerGUID = guid; } + bool HasFriend(ObjectGuid friend_guid) const; + bool HasIgnore(ObjectGuid ignore_guid) const; + ObjectGuid GetPlayerGUID() const { return m_playerGUID; } + void SetPlayerGUID(ObjectGuid guid) { m_playerGUID = guid; } uint32 GetNumberOfSocialsWithFlag(SocialFlag flag) const; private: - bool _checkContact(uint64 guid, SocialFlag flags) const; - typedef std::map<uint32, FriendInfo> PlayerSocialMap; + bool _checkContact(ObjectGuid guid, SocialFlag flags) const; + typedef std::map<ObjectGuid, FriendInfo> PlayerSocialMap; PlayerSocialMap m_playerSocialMap; - uint64 m_playerGUID; + ObjectGuid m_playerGUID; }; class SocialMgr @@ -120,16 +120,16 @@ class SocialMgr public: static SocialMgr* instance(); // Misc - void RemovePlayerSocial(uint64 guid) { m_socialMap.erase(guid); } - static void GetFriendInfo(Player* player, uint64 friendGUID, FriendInfo& friendInfo); + void RemovePlayerSocial(ObjectGuid guid) { m_socialMap.erase(guid); } + static void GetFriendInfo(Player* player, ObjectGuid friendGUID, FriendInfo& friendInfo); // Packet management - void MakeFriendStatusPacket(FriendsResult result, uint64 friend_guid, WorldPacket* data); - void SendFriendStatus(Player* player, FriendsResult result, uint64 friend_guid, bool broadcast); + void MakeFriendStatusPacket(FriendsResult result, ObjectGuid friend_guid, WorldPacket* data); + void SendFriendStatus(Player* player, FriendsResult result, ObjectGuid friend_guid, bool broadcast); void BroadcastToFriendListers(Player* player, WorldPacket* packet); // Loading - PlayerSocial* LoadFromDB(PreparedQueryResult result, uint64 guid); + PlayerSocial* LoadFromDB(PreparedQueryResult result, ObjectGuid guid); private: - typedef std::map<uint32, PlayerSocial> SocialMap; + typedef std::map<ObjectGuid, PlayerSocial> SocialMap; SocialMap m_socialMap; }; diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp index 958dbf01b7..5c998ed64b 100644 --- a/src/server/game/Entities/Totem/Totem.cpp +++ b/src/server/game/Entities/Totem/Totem.cpp @@ -15,7 +15,7 @@ #include "Totem.h" #include "WorldPacket.h" -Totem::Totem(SummonPropertiesEntry const* properties, uint64 owner) : Minion(properties, owner, false) +Totem::Totem(SummonPropertiesEntry const* properties, ObjectGuid owner) : Minion(properties, owner, false) { m_unitTypeMask |= UNIT_MASK_TOTEM; m_duration = 0; @@ -45,13 +45,13 @@ void Totem::InitStats(uint32 duration) { // client requires SMSG_TOTEM_CREATED to be sent before adding to world and before removing old totem // Xinef: Set level for Unit totems - if (Unit* owner = ObjectAccessor::FindUnit(m_owner)) + if (Unit* owner = ObjectAccessor::GetUnit(*this, m_owner)) { if (owner->GetTypeId() == TYPEID_PLAYER && m_Properties->Slot >= SUMMON_SLOT_TOTEM && m_Properties->Slot < MAX_TOTEM_SLOT) { WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4); data << uint8(m_Properties->Slot - 1); - data << uint64(GetGUID()); + data << GetGUID(); data << uint32(duration); data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL)); owner->ToPlayer()->SendDirectMessage(&data); @@ -109,7 +109,7 @@ void Totem::UnSummon(uint32 msTime) { if (owner->m_SummonSlot[i] == GetGUID()) { - owner->m_SummonSlot[i] = 0; + owner->m_SummonSlot[i].Clear(); break; } } diff --git a/src/server/game/Entities/Totem/Totem.h b/src/server/game/Entities/Totem/Totem.h index 34799cb780..779ed5b056 100644 --- a/src/server/game/Entities/Totem/Totem.h +++ b/src/server/game/Entities/Totem/Totem.h @@ -26,7 +26,7 @@ constexpr uint32 SPELL_CYCLONE = 33786; class Totem : public Minion { public: - explicit Totem(SummonPropertiesEntry const* properties, uint64 owner); + explicit Totem(SummonPropertiesEntry const* properties, ObjectGuid owner); ~Totem() override {}; void Update(uint32 time) override; void InitStats(uint32 duration) override; diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index bd4a9f7be5..1abbe77ecc 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -32,7 +32,7 @@ MotionTransport::~MotionTransport() UnloadStaticPassengers(); } -bool MotionTransport::CreateMoTrans(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress) +bool MotionTransport::CreateMoTrans(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress) { Relocate(x, y, z, ang); @@ -43,7 +43,7 @@ bool MotionTransport::CreateMoTrans(uint32 guidlow, uint32 entry, uint32 mapid, return false; } - Object::_Create(guidlow, 0, HIGHGUID_MO_TRANSPORT); + Object::_Create(guidlow, 0, HighGuid::Mo_Transport); GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry); @@ -292,7 +292,7 @@ void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll) { passenger->SetTransport(nullptr); passenger->m_movementInfo.flags &= ~MOVEMENTFLAG_ONTRANSPORT; - passenger->m_movementInfo.transport.guid = 0; + passenger->m_movementInfo.transport.guid.Clear(); passenger->m_movementInfo.transport.pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f); if (passenger->ToUnit()) { @@ -302,7 +302,7 @@ void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll) } } -Creature* MotionTransport::CreateNPCPassenger(uint32 guid, CreatureData const* data) +Creature* MotionTransport::CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data) { Map* map = GetMap(); Creature* creature = new Creature(); @@ -333,7 +333,8 @@ Creature* MotionTransport::CreateNPCPassenger(uint32 guid, CreatureData const* d if (!creature->IsPositionValid()) { - LOG_ERROR("server", "Creature (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)", creature->GetGUIDLow(), creature->GetEntry(), creature->GetPositionX(), creature->GetPositionY()); + LOG_ERROR("server", "Creature (%s) not created. Suggested coordinates aren't valid (X: %f Y: %f)", + creature->GetGUID().ToString().c_str(), creature->GetPositionX(), creature->GetPositionY()); delete creature; return nullptr; } @@ -349,7 +350,7 @@ Creature* MotionTransport::CreateNPCPassenger(uint32 guid, CreatureData const* d return creature; } -GameObject* MotionTransport::CreateGOPassenger(uint32 guid, GameObjectData const* data) +GameObject* MotionTransport::CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data) { Map* map = GetMap(); GameObject* go = new GameObject(); @@ -374,7 +375,8 @@ GameObject* MotionTransport::CreateGOPassenger(uint32 guid, GameObjectData const if (!go->IsPositionValid()) { - LOG_ERROR("server", "GameObject (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)", go->GetGUIDLow(), go->GetEntry(), go->GetPositionX(), go->GetPositionY()); + LOG_ERROR("server", "GameObject (%s) not created. Suggested coordinates aren't valid (X: %f Y: %f)", + go->GetGUID().ToString().c_str(), go->GetPositionX(), go->GetPositionY()); delete go; return nullptr; } @@ -660,7 +662,7 @@ StaticTransport::~StaticTransport() ASSERT(_passengers.empty()); } -bool StaticTransport::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit) +bool StaticTransport::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit) { ASSERT(map); SetMap(map); @@ -690,7 +692,7 @@ bool StaticTransport::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 ph return false; } - Object::_Create(guidlow, 0, HIGHGUID_TRANSPORT); + Object::_Create(guidlow, 0, HighGuid::Transport); m_goInfo = goinfo; @@ -970,7 +972,7 @@ void StaticTransport::RemovePassenger(WorldObject* passenger, bool withAll) { passenger->SetTransport(nullptr); passenger->m_movementInfo.flags &= ~MOVEMENTFLAG_ONTRANSPORT; - passenger->m_movementInfo.transport.guid = 0; + passenger->m_movementInfo.transport.guid.Clear(); passenger->m_movementInfo.transport.pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f); } } diff --git a/src/server/game/Entities/Transport/Transport.h b/src/server/game/Entities/Transport/Transport.h index 42d5024232..eb06337af6 100644 --- a/src/server/game/Entities/Transport/Transport.h +++ b/src/server/game/Entities/Transport/Transport.h @@ -35,12 +35,12 @@ protected: class MotionTransport : public Transport { - friend MotionTransport* TransportMgr::CreateTransport(uint32, uint32, Map*); + friend MotionTransport* TransportMgr::CreateTransport(uint32, ObjectGuid::LowType, Map*); MotionTransport(); public: ~MotionTransport() override; - bool CreateMoTrans(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress); + bool CreateMoTrans(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress); void CleanupsBeforeDelete(bool finalCleanup = true) override; void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&) override; @@ -50,8 +50,8 @@ public: void AddPassenger(WorldObject* passenger, bool withAll = false) override; void RemovePassenger(WorldObject* passenger, bool withAll = false) override; - Creature* CreateNPCPassenger(uint32 guid, CreatureData const* data); - GameObject* CreateGOPassenger(uint32 guid, GameObjectData const* data); + Creature* CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data); + GameObject* CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data); void LoadStaticPassengers(); PassengerSet const& GetStaticPassengers() const { return _staticPassengers; } @@ -102,7 +102,7 @@ public: StaticTransport(); ~StaticTransport() override; - bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0) override; + bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0) override; void CleanupsBeforeDelete(bool finalCleanup = true) override; void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&) override; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 25bee45c81..ed361f4cf2 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -203,10 +203,10 @@ Unit::Unit(bool isWorldObject) : WorldObject(isWorldObject), m_currentSpells[i] = nullptr; for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i) - m_SummonSlot[i] = 0; + m_SummonSlot[i].Clear(); for (uint8 i = 0; i < MAX_GAMEOBJECT_SLOT; ++i) - m_ObjectSlot[i] = 0; + m_ObjectSlot[i].Clear(); m_auraUpdateIterator = m_ownedAuras.end(); @@ -459,7 +459,7 @@ void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed) void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 TransitTime, SplineFlags sf) { WorldPacket data(SMSG_MONSTER_MOVE, 1 + 12 + 4 + 1 + 4 + 4 + 4 + 12 + GetPackGUID().size()); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint8(0); // new in 3.1 data << GetPositionX() << GetPositionY() << GetPositionZ(); @@ -939,7 +939,7 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage if (victim->GetTypeId() != TYPEID_PLAYER) { // Part of Evade mechanics. DoT's and Thorns / Retribution Aura do not contribute to this - if (damagetype != DOT && damage > 0 && !IS_PLAYER_GUID(victim->GetOwnerGUID()) && (!spellProto || !spellProto->HasAura(SPELL_AURA_DAMAGE_SHIELD))) + if (damagetype != DOT && damage > 0 && !victim->GetOwnerGUID().IsPlayer() && (!spellProto || !spellProto->HasAura(SPELL_AURA_DAMAGE_SHIELD))) victim->ToCreature()->SetLastDamagedTime(sWorld->GetGameTime() + MAX_AGGRO_RESET_TIME); if (attacker) @@ -1031,11 +1031,11 @@ void Unit::CastStop(uint32 except_spellid, bool withInstant) InterruptSpell(CurrentSpellTypes(i), false, withInstant); } -SpellCastResult Unit::CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +SpellCastResult Unit::CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster) { if (!spellInfo) { - LOG_ERROR("server", "CastSpell: unknown spell by caster: %s %u)", (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + LOG_ERROR("server", "CastSpell: unknown spell by caster: %s %u)", (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry())); return SPELL_FAILED_SPELL_UNAVAILABLE; } @@ -1059,36 +1059,36 @@ SpellCastResult Unit::CastSpell(SpellCastTargets const& targets, SpellInfo const return spell->prepare(&targets, triggeredByAura); } -SpellCastResult Unit::CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +SpellCastResult Unit::CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster) { return CastSpell(victim, spellId, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } -SpellCastResult Unit::CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags /*= TRIGGER_NONE*/, Item* castItem /*= nullptr*/, AuraEffect const* triggeredByAura /*= nullptr*/, uint64 originalCaster /*= 0*/) +SpellCastResult Unit::CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags /*= TRIGGER_NONE*/, Item* castItem /*= nullptr*/, AuraEffect const* triggeredByAura /*= nullptr*/, ObjectGuid originalCaster /*= ObjectGuid::Empty*/) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) { - LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry())); return SPELL_FAILED_SPELL_UNAVAILABLE; } return CastSpell(victim, spellInfo, triggerFlags, castItem, triggeredByAura, originalCaster); } -SpellCastResult Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem/*= nullptr*/, AuraEffect const* triggeredByAura /*= nullptr*/, uint64 originalCaster /*= 0*/) +SpellCastResult Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem/*= nullptr*/, AuraEffect const* triggeredByAura /*= nullptr*/, ObjectGuid originalCaster /*= ObjectGuid::Empty*/) { return CastSpell(victim, spellInfo, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } -SpellCastResult Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +SpellCastResult Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster) { SpellCastTargets targets; targets.SetUnitTarget(victim); return CastSpell(targets, spellInfo, nullptr, triggerFlags, castItem, triggeredByAura, originalCaster); } -SpellCastResult Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +SpellCastResult Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster) { CustomSpellValues values; if (bp0) @@ -1100,26 +1100,26 @@ SpellCastResult Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* return CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } -SpellCastResult Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +SpellCastResult Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster) { CustomSpellValues values; values.AddSpellMod(mod, value); return CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } -SpellCastResult Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +SpellCastResult Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster) { CustomSpellValues values; values.AddSpellMod(mod, value); return CastCustomSpell(spellId, values, target, triggerFlags, castItem, triggeredByAura, originalCaster); } -SpellCastResult Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +SpellCastResult Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) { - LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry())); return SPELL_FAILED_SPELL_UNAVAILABLE; } SpellCastTargets targets; @@ -1128,12 +1128,12 @@ SpellCastResult Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& v return CastSpell(targets, spellInfo, &value, triggerFlags, castItem, triggeredByAura, originalCaster); } -SpellCastResult Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +SpellCastResult Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) { - LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry())); return SPELL_FAILED_SPELL_UNAVAILABLE; } SpellCastTargets targets; @@ -1142,12 +1142,12 @@ SpellCastResult Unit::CastSpell(float x, float y, float z, uint32 spellId, bool return CastSpell(targets, spellInfo, nullptr, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } -SpellCastResult Unit::CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem, AuraEffect* triggeredByAura, uint64 originalCaster) +SpellCastResult Unit::CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem, AuraEffect* triggeredByAura, ObjectGuid originalCaster) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) { - LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry())); return SPELL_FAILED_SPELL_UNAVAILABLE; } SpellCastTargets targets; @@ -1617,8 +1617,8 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) // TODO: Move this to a packet handler WorldPacket data(SMSG_SPELLDAMAGESHIELD, (8 + 8 + 4 + 4 + 4 + 4)); - data << uint64(victim->GetGUID()); - data << uint64(GetGUID()); + data << victim->GetGUID(); + data << GetGUID(); data << uint32(i_spellProto->Id); data << uint32(damage); // Damage int32 overkill = int32(damage) - int32(GetHealth()); @@ -1635,7 +1635,7 @@ void Unit::HandleEmoteCommand(uint32 anim_id) { WorldPacket data(SMSG_EMOTE, 4 + 8); data << uint32(anim_id); - data << uint64(GetGUID()); + data << GetGUID(); SendMessageToSet(&data, true); } @@ -2221,11 +2221,11 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) if (GetTypeId() == TYPEID_PLAYER) - LOG_DEBUG("server", "AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", - GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); + LOG_DEBUG("server", "AttackerStateUpdate: (Player) %s attacked %s for %u dmg, absorbed %u, blocked %u, resisted %u.", + GetGUID().ToString().c_str(), victim->GetGUID().ToString().c_str(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); else - LOG_DEBUG("server", "AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", - GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); + LOG_DEBUG("server", "AttackerStateUpdate: (NPC) %s attacked %s for %u dmg, absorbed %u, blocked %u, resisted %u.", + GetGUID().ToString().c_str(), victim->GetGUID().ToString().c_str(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); #endif } } @@ -2618,8 +2618,8 @@ float Unit::CalculateLevelPenalty(SpellInfo const* spellProto) const void Unit::SendMeleeAttackStart(Unit* victim, Player* sendTo) { WorldPacket data(SMSG_ATTACKSTART, 8 + 8); - data << uint64(GetGUID()); - data << uint64(victim->GetGUID()); + data << GetGUID(); + data << victim->GetGUID(); if (sendTo) sendTo->SendDirectMessage(&data); else @@ -2636,17 +2636,17 @@ void Unit::SendMeleeAttackStop(Unit* victim) // ClearUnitState(UNIT_STATE_MELEE_ATTACKING); // ZOMG! commented out for now WorldPacket data(SMSG_ATTACKSTOP, (8 + 8 + 4)); - data.append(GetPackGUID()); - data.append(victim ? victim->GetPackGUID() : 0); + data << GetPackGUID(); + data << (victim ? victim->GetPackGUID() : PackedGuid()); data << uint32(0); //! Can also take the value 0x01, which seems related to updating rotation SendMessageToSet(&data, true); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("server", "WORLD: Sent SMSG_ATTACKSTOP"); if (victim) - LOG_DEBUG("server", "%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow()); + LOG_DEBUG("server", "%s %s stopped attacking %s %s", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUID().ToString().c_str(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUID().ToString().c_str()); else - LOG_DEBUG("server", "%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow()); + LOG_DEBUG("server", "%s %s stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUID().ToString().c_str()); #endif } @@ -3335,7 +3335,7 @@ void Unit::_UpdateSpells(uint32 time) if (GameObject* go = ObjectAccessor::GetGameObject(*this, *itr)) if (!go->isSpawned()) { - go->SetOwnerGUID(0); + go->SetOwnerGUID(ObjectGuid::Empty); go->SetRespawnTime(0); go->Delete(); m_gameObj.erase(itr++); @@ -3616,7 +3616,7 @@ bool Unit::isInAccessiblePlaceFor(Creature const* c) const return false; // special handling for ICC (map 631), for non-flying pets in Gunship Battle, for trash npcs this is done via CanAIAttack - if (IS_PLAYER_GUID(c->GetOwnerGUID()) && !c->CanFly()) + if (c->GetOwnerGUID().IsPlayer() && !c->CanFly()) { if (c->GetTransport() != this->GetTransport()) return false; @@ -3804,14 +3804,14 @@ void Unit::UpdateEnvironmentIfNeeded(const uint8 option) if (canUpdateEnvironment && canChangeFlying) { // xinef: summoned vehicles are treated as always in air, fixes flying on such units - if (IsVehicle() && !c->GetDBTableGUIDLow()) + if (IsVehicle() && !c->GetSpawnId()) isInAir = true; // xinef: triggers with inhabit type air are treated as always in air if (c->IsTrigger() && c->CanFly()) isInAir = true; - if (IS_PLAYER_GUID(c->GetOwnerGUID()) && c->CanFly() && IsVehicle() && !c->GetDBTableGUIDLow()) // mainly for oculus drakes + if (c->GetOwnerGUID().IsPlayer() && c->CanFly() && IsVehicle() && !c->GetSpawnId()) // mainly for oculus drakes { if (!HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY) || !HasUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY)) { @@ -3893,7 +3893,8 @@ void SafeUnitPointer::UnitDeleted() { if (Player* p = defaultValue->ToPlayer()) { - LOG_INFO("misc", "SafeUnitPointer::UnitDeleted (A1) - %u, %u, %u, %u, %u, %u, %u, %u", p->GetGUIDLow(), p->GetMapId(), p->GetInstanceId(), p->FindMap()->GetId(), p->IsInWorld() ? 1 : 0, p->IsDuringRemoveFromWorld() ? 1 : 0, p->IsBeingTeleported() ? 1 : 0, p->isBeingLoaded() ? 1 : 0); + LOG_INFO("misc", "SafeUnitPointer::UnitDeleted (A1) - %s, %u, %u, %u, %u, %u, %u, %u", + p->GetGUID().ToString().c_str(), p->GetMapId(), p->GetInstanceId(), p->FindMap()->GetId(), p->IsInWorld() ? 1 : 0, p->IsDuringRemoveFromWorld() ? 1 : 0, p->IsBeingTeleported() ? 1 : 0, p->isBeingLoaded() ? 1 : 0); if (ptr) LOG_INFO("misc", "SafeUnitPointer::UnitDeleted (A2)"); @@ -3939,7 +3940,7 @@ void Unit::DeMorph() SetDisplayId(GetNativeDisplayId()); } -Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, uint64 casterGUID /*= 0*/, bool periodicReset /*= false*/) +Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/, bool periodicReset /*= false*/) { ASSERT(casterGUID || caster); if (!casterGUID) @@ -3953,12 +3954,12 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 if (!newAura->IsMultiSlotAura()) { // check if cast item changed - uint64 castItemGUID = 0; + ObjectGuid castItemGUID; if (castItem) castItemGUID = castItem->GetGUID(); // find current aura from spell and change it's stackamount, or refresh it's duration - if (Aura* foundAura = GetOwnedAura(newAura->Id, newAura->HasAttribute(SPELL_ATTR0_CU_SINGLE_AURA_STACK) ? 0 : casterGUID, newAura->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC) ? castItemGUID : 0, 0)) + if (Aura* foundAura = GetOwnedAura(newAura->Id, newAura->HasAttribute(SPELL_ATTR0_CU_SINGLE_AURA_STACK) ? ObjectGuid::Empty : casterGUID, newAura->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC) ? castItemGUID : ObjectGuid::Empty, 0)) { // effect masks do not match // extremely rare case @@ -3985,7 +3986,7 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 // correct cast item guid if needed if (castItemGUID != foundAura->GetCastItemGUID()) { - uint64* oldGUID = const_cast<uint64*>(&foundAura->m_castItemGuid); + ObjectGuid* oldGUID = const_cast<ObjectGuid*>(&foundAura->m_castItemGuid); *oldGUID = castItemGUID; } @@ -4114,7 +4115,7 @@ void Unit::_ApplyAura(AuraApplication* aurApp, uint8 effMask) } else if (caster) { - ConflagrateAuraStateDelayEvent* pEvent = new ConflagrateAuraStateDelayEvent(GetGUID(), caster->GetGUID()); + ConflagrateAuraStateDelayEvent* pEvent = new ConflagrateAuraStateDelayEvent(this, caster->GetGUID()); m_Events.AddEvent(pEvent, m_Events.CalculateTime(700)); // intended 700ms delay before allowing to cast conflagrate } } @@ -4302,7 +4303,7 @@ void Unit::RemoveOwnedAura(AuraMap::iterator& i, AuraRemoveMode removeMode) i = m_ownedAuras.begin(); } -void Unit::RemoveOwnedAura(uint32 spellId, uint64 casterGUID, uint8 reqEffMask, AuraRemoveMode removeMode) +void Unit::RemoveOwnedAura(uint32 spellId, ObjectGuid casterGUID, uint8 reqEffMask, AuraRemoveMode removeMode) { for (AuraMap::iterator itr = m_ownedAuras.lower_bound(spellId); itr != m_ownedAuras.upper_bound(spellId);) if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && (!casterGUID || itr->second->GetCasterGUID() == casterGUID)) @@ -4336,7 +4337,7 @@ void Unit::RemoveOwnedAura(Aura* aura, AuraRemoveMode removeMode) ABORT(); } -Aura* Unit::GetOwnedAura(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask, Aura* except) const +Aura* Unit::GetOwnedAura(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask, Aura* except) const { AuraMapBounds range = m_ownedAuras.equal_range(spellId); for (AuraMap::const_iterator itr = range.first; itr != range.second; ++itr) @@ -4367,7 +4368,7 @@ void Unit::RemoveAura(AuraApplicationMap::iterator& i, AuraRemoveMode mode) sScriptMgr->OnAuraRemove(this, aurApp, mode); } -void Unit::RemoveAura(uint32 spellId, uint64 caster, uint8 reqEffMask, AuraRemoveMode removeMode) +void Unit::RemoveAura(uint32 spellId, ObjectGuid caster, uint8 reqEffMask, AuraRemoveMode removeMode) { AuraApplicationMapBoundsNonConst range = m_appliedAuras.equal_range(spellId); for (AuraApplicationMap::iterator iter = range.first; iter != range.second;) @@ -4479,7 +4480,7 @@ void Unit::RemoveAppliedAuras(uint32 spellId, std::function<bool(AuraApplication } } -void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID, uint8 reqEffMask, AuraRemoveMode removeMode) +void Unit::RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID, uint8 reqEffMask, AuraRemoveMode removeMode) { for (AuraApplicationMap::iterator iter = m_appliedAuras.lower_bound(spellId); iter != m_appliedAuras.upper_bound(spellId);) { @@ -4495,7 +4496,7 @@ void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID, uint8 reqEff } } -void Unit::RemoveAuraFromStack(uint32 spellId, uint64 casterGUID, AuraRemoveMode removeMode) +void Unit::RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID, AuraRemoveMode removeMode) { AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId); for (AuraMap::iterator iter = range.first; iter != range.second;) @@ -4512,7 +4513,7 @@ void Unit::RemoveAuraFromStack(uint32 spellId, uint64 casterGUID, AuraRemoveMode } } -void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, uint64 casterGUID, Unit* dispeller, uint8 chargesRemoved/*= 1*/) +void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, Unit* dispeller, uint8 chargesRemoved/*= 1*/) { AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId); for (AuraMap::iterator iter = range.first; iter != range.second;) @@ -4576,7 +4577,7 @@ void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId } } -void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* stealer) +void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, Unit* stealer) { AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId); for (AuraMap::iterator iter = range.first; iter != range.second;) @@ -4655,7 +4656,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* } } -void Unit::RemoveAurasDueToItemSpell(uint32 spellId, uint64 castItemGuid) +void Unit::RemoveAurasDueToItemSpell(uint32 spellId, ObjectGuid castItemGuid) { for (AuraApplicationMap::iterator iter = m_appliedAuras.lower_bound(spellId); iter != m_appliedAuras.upper_bound(spellId);) { @@ -4669,7 +4670,7 @@ void Unit::RemoveAurasDueToItemSpell(uint32 spellId, uint64 castItemGuid) } } -void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura* except, bool negative, bool positive) +void Unit::RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID, Aura* except, bool negative, bool positive) { // simple check if list is empty if (m_modAuras[auraType].empty()) @@ -4769,7 +4770,7 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except) UpdateInterruptMask(); } -void Unit::RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID) +void Unit::RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID) { for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { @@ -5000,7 +5001,7 @@ void Unit::RemoveEvadeAuras() for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { Aura const* aura = iter->second->GetBase(); - if (aura->GetSpellInfo()->HasAura(SPELL_AURA_CONTROL_VEHICLE) || aura->GetSpellInfo()->HasAura(SPELL_AURA_CLONE_CASTER) || (aura->IsPassive() && IS_PLAYER_GUID(GetOwnerGUID()))) + if (aura->GetSpellInfo()->HasAura(SPELL_AURA_CONTROL_VEHICLE) || aura->GetSpellInfo()->HasAura(SPELL_AURA_CLONE_CASTER) || (aura->IsPassive() && GetOwnerGUID().IsPlayer())) ++iter; else _UnapplyAura(iter, AURA_REMOVE_BY_DEFAULT); @@ -5009,14 +5010,14 @@ void Unit::RemoveEvadeAuras() for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();) { Aura* aura = iter->second; - if (aura->GetSpellInfo()->HasAura(SPELL_AURA_CONTROL_VEHICLE) || aura->GetSpellInfo()->HasAura(SPELL_AURA_CLONE_CASTER) || (aura->IsPassive() && IS_PLAYER_GUID(GetOwnerGUID()))) + if (aura->GetSpellInfo()->HasAura(SPELL_AURA_CONTROL_VEHICLE) || aura->GetSpellInfo()->HasAura(SPELL_AURA_CLONE_CASTER) || (aura->IsPassive() && GetOwnerGUID().IsPlayer())) ++iter; else RemoveOwnedAura(iter, AURA_REMOVE_BY_DEFAULT); } } -void Unit::DelayOwnedAuras(uint32 spellId, uint64 caster, int32 delaytime) +void Unit::DelayOwnedAuras(uint32 spellId, ObjectGuid caster, int32 delaytime) { AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId); for (; range.first != range.second; ++range.first) @@ -5032,7 +5033,7 @@ void Unit::DelayOwnedAuras(uint32 spellId, uint64 caster, int32 delaytime) // update for out of range group members (on 1 slot use) aura->SetNeedClientUpdateForTargets(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("spells.aura", "Aura %u partially interrupted on unit %u, new duration: %u ms", aura->GetId(), GetGUIDLow(), aura->GetDuration()); + LOG_DEBUG("spells.aura", "Aura %u partially interrupted on unit %s, new duration: %u ms", aura->GetId(), GetGUID().ToString().c_str(), aura->GetDuration()); #endif } } @@ -5050,7 +5051,7 @@ void Unit::_ApplyAllAuraStatMods() (*i).second->GetBase()->HandleAllEffects(i->second, AURA_EFFECT_HANDLE_STAT, true); } -AuraEffect* Unit::GetAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster) const +AuraEffect* Unit::GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster) const { AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId); for (AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr) @@ -5064,7 +5065,7 @@ AuraEffect* Unit::GetAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster) c return nullptr; } -AuraEffect* Unit::GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, uint64 caster) const +AuraEffect* Unit::GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, ObjectGuid caster) const { uint32 rankSpell = sSpellMgr->GetFirstSpellInChain(spellId); while (rankSpell) @@ -5090,7 +5091,7 @@ AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 ico return nullptr; } -AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID) const +AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID) const { AuraEffectList const& auras = GetAuraEffectsByType(type); for (AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i) @@ -5118,7 +5119,7 @@ AuraEffect* Unit::GetAuraEffectDummy(uint32 spellid) const return nullptr; } -AuraApplication* Unit::GetAuraApplication(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask, AuraApplication* except) const +AuraApplication* Unit::GetAuraApplication(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask, AuraApplication* except) const { AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId); for (; range.first != range.second; ++range.first) @@ -5137,13 +5138,13 @@ AuraApplication* Unit::GetAuraApplication(uint32 spellId, uint64 casterGUID, uin return nullptr; } -Aura* Unit::GetAura(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask) const +Aura* Unit::GetAura(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask) const { AuraApplication* aurApp = GetAuraApplication(spellId, casterGUID, itemCasterGUID, reqEffMask); return aurApp ? aurApp->GetBase() : nullptr; } -AuraApplication* Unit::GetAuraApplicationOfRankedSpell(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask, AuraApplication* except) const +AuraApplication* Unit::GetAuraApplicationOfRankedSpell(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask, AuraApplication* except) const { uint32 rankSpell = sSpellMgr->GetFirstSpellInChain(spellId); while (rankSpell) @@ -5155,7 +5156,7 @@ AuraApplication* Unit::GetAuraApplicationOfRankedSpell(uint32 spellId, uint64 ca return nullptr; } -Aura* Unit::GetAuraOfRankedSpell(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask) const +Aura* Unit::GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask) const { AuraApplication* aurApp = GetAuraApplicationOfRankedSpell(spellId, casterGUID, itemCasterGUID, reqEffMask); return aurApp ? aurApp->GetBase() : nullptr; @@ -5198,7 +5199,7 @@ void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelCharges } } -bool Unit::HasAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster) const +bool Unit::HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster) const { AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId); for (AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr) @@ -5228,7 +5229,7 @@ uint32 Unit::GetAuraCount(uint32 spellId) const return count; } -bool Unit::HasAura(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask) const +bool Unit::HasAura(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask) const { if (GetAuraApplication(spellId, casterGUID, itemCasterGUID, reqEffMask)) return true; @@ -5240,7 +5241,7 @@ bool Unit::HasAuraType(AuraType auraType) const return (!m_modAuras[auraType].empty()); } -bool Unit::HasAuraTypeWithCaster(AuraType auratype, uint64 caster) const +bool Unit::HasAuraTypeWithCaster(AuraType auratype, ObjectGuid caster) const { AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) @@ -5286,7 +5287,7 @@ bool Unit::HasAuraTypeWithValue(AuraType auratype, int32 value) const return false; } -bool Unit::HasNegativeAuraWithInterruptFlag(uint32 flag, uint64 guid) +bool Unit::HasNegativeAuraWithInterruptFlag(uint32 flag, ObjectGuid guid) { if (!(m_interruptMask & flag)) return false; @@ -5298,7 +5299,7 @@ bool Unit::HasNegativeAuraWithInterruptFlag(uint32 flag, uint64 guid) return false; } -bool Unit::HasNegativeAuraWithAttribute(uint32 flag, uint64 guid) +bool Unit::HasNegativeAuraWithAttribute(uint32 flag, ObjectGuid guid) { for (AuraApplicationMap::const_iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end(); ++iter) { @@ -5338,7 +5339,7 @@ AuraEffect* Unit::IsScriptOverriden(SpellInfo const* spell, int32 script) const return nullptr; } -uint32 Unit::GetDiseasesByCaster(uint64 casterGUID, uint8 mode) +uint32 Unit::GetDiseasesByCaster(ObjectGuid casterGUID, uint8 mode) { static const AuraType diseaseAuraTypes[] = { @@ -5347,7 +5348,7 @@ uint32 Unit::GetDiseasesByCaster(uint64 casterGUID, uint8 mode) SPELL_AURA_NONE }; - uint64 drwGUID = 0; + ObjectGuid drwGUID; if (Player* playerCaster = ObjectAccessor::GetPlayer(*this, casterGUID)) drwGUID = playerCaster->getRuneWeaponGUID(); @@ -5384,7 +5385,7 @@ uint32 Unit::GetDiseasesByCaster(uint64 casterGUID, uint8 mode) return diseases; } -uint32 Unit::GetDoTsByCaster(uint64 casterGUID) const +uint32 Unit::GetDoTsByCaster(ObjectGuid casterGUID) const { static const AuraType diseaseAuraTypes[] = { @@ -5693,7 +5694,7 @@ GameObject* Unit::GetGameObject(uint32 spellId) const void Unit::AddGameObject(GameObject* gameObj) { - if (!gameObj || gameObj->GetOwnerGUID() != 0) + if (!gameObj || gameObj->GetOwnerGUID()) return; m_gameObj.push_back(gameObj->GetGUID()); @@ -5714,13 +5715,13 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del) if (!gameObj || gameObj->GetOwnerGUID() != GetGUID()) return; - gameObj->SetOwnerGUID(0); + gameObj->SetOwnerGUID(ObjectGuid::Empty); for (uint8 i = 0; i < MAX_GAMEOBJECT_SLOT; ++i) { if (m_ObjectSlot[i] == gameObj->GetGUID()) { - m_ObjectSlot[i] = 0; + m_ObjectSlot[i].Clear(); break; } } @@ -5764,7 +5765,7 @@ void Unit::RemoveGameObject(uint32 spellid, bool del) continue; } - go->SetOwnerGUID(0); + go->SetOwnerGUID(ObjectGuid::Empty); if(del) { go->SetRespawnTime(0); @@ -5782,7 +5783,7 @@ void Unit::RemoveAllGameObjects() GameObject* go = ObjectAccessor::GetGameObject(*this, *m_gameObj.begin()); if(go) { - go->SetOwnerGUID(0); + go->SetOwnerGUID(ObjectGuid::Empty); go->SetRespawnTime(0); go->Delete(); } @@ -5805,8 +5806,8 @@ void Unit::SendSpellNonMeleeReflectLog(SpellNonMeleeDamage* log, Unit* attacker) absorb = damage; damage = 0; } - data.append(log->target->GetPackGUID()); - data.append(attacker->GetPackGUID()); + data << log->target->GetPackGUID(); + data << attacker->GetPackGUID(); data << uint32(log->SpellID); data << uint32(damage); // damage amount int32 overkill = damage - log->target->GetHealth(); @@ -5833,8 +5834,8 @@ void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log) absorb = damage; damage = 0; } - data.append(log->target->GetPackGUID()); - data.append(log->attacker->GetPackGUID()); + data << log->target->GetPackGUID(); + data << log->attacker->GetPackGUID(); data << uint32(log->SpellID); data << uint32(damage); // damage amount int32 overkill = damage - log->target->GetHealth(); @@ -5879,8 +5880,8 @@ void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo) { AuraEffect const* aura = pInfo->auraEff; WorldPacket data(SMSG_PERIODICAURALOG, 30); - data.append(GetPackGUID()); - data.appendPackGUID(aura->GetCasterGUID()); + data << GetPackGUID(); + data << aura->GetCasterGUID().WriteAsPacked(); data << uint32(aura->GetId()); // spellId data << uint32(1); // count data << uint32(aura->GetAuraType()); // auraId @@ -5935,11 +5936,11 @@ void Unit::SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo) { WorldPacket data(SMSG_SPELLLOGMISS, (4 + 8 + 1 + 4 + 8 + 1)); data << uint32(spellID); - data << uint64(GetGUID()); + data << GetGUID(); data << uint8(0); // can be 0 or 1 data << uint32(1); // target count // for (i = 0; i < target count; ++i) - data << uint64(target->GetGUID()); // target GUID + data << target->GetGUID(); // target GUID data << uint8(missInfo); // end loop SendMessageToSet(&data, true); @@ -5948,8 +5949,8 @@ void Unit::SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo) void Unit::SendSpellDamageResist(Unit* target, uint32 spellId) { WorldPacket data(SMSG_PROCRESIST, 8 + 8 + 4 + 1); - data << uint64(GetGUID()); - data << uint64(target->GetGUID()); + data << GetGUID(); + data << target->GetGUID(); data << uint32(spellId); data << uint8(0); // bool - log format: 0-default, 1-debug SendMessageToSet(&data, true); @@ -5958,8 +5959,8 @@ void Unit::SendSpellDamageResist(Unit* target, uint32 spellId) void Unit::SendSpellDamageImmune(Unit* target, uint32 spellId) { WorldPacket data(SMSG_SPELLORDAMAGE_IMMUNE, 8 + 8 + 4 + 1); - data << uint64(GetGUID()); - data << uint64(target->GetGUID()); + data << GetGUID(); + data << target->GetGUID(); data << uint32(spellId); data << uint8(0); // bool - log format: 0-default, 1-debug SendMessageToSet(&data, true); @@ -5984,8 +5985,8 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo) size_t maxsize = 4 + 5 + 5 + 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 * 12; WorldPacket data(SMSG_ATTACKERSTATEUPDATE, maxsize); // we guess size data << uint32(damageInfo->HitInfo); - data.append(damageInfo->attacker->GetPackGUID()); - data.append(damageInfo->target->GetPackGUID()); + data << damageInfo->attacker->GetPackGUID(); + data << damageInfo->target->GetPackGUID(); data << uint32(damage); // Full damage int32 overkill = damage - damageInfo->target->GetHealth(); data << uint32(overkill < 0 ? 0 : overkill); // Overkill @@ -6070,7 +6071,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // otherwise, it's the triggered_spell_id by default Unit* target = victim; int32 basepoints0 = 0; - uint64 originalCaster = 0; + ObjectGuid originalCaster; switch (dummySpell->SpellFamilyName) { @@ -6573,7 +6574,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere { if (!target) return false; - target->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE, 0, target->GetAura(32409)); // SW:D shall not be removed. + target->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE, ObjectGuid::Empty, target->GetAura(32409)); // SW:D shall not be removed. target->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT); target->RemoveAurasByType(SPELL_AURA_PERIODIC_LEECH); return true; @@ -6581,7 +6582,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Glyph of Icy Veins case 56374: { - RemoveAurasByType(SPELL_AURA_HASTE_SPELLS, 0, 0, true, false); + RemoveAurasByType(SPELL_AURA_HASTE_SPELLS, ObjectGuid::Empty, 0, true, false); RemoveAurasByType(SPELL_AURA_MOD_DECREASE_SPEED); return true; } @@ -6661,7 +6662,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere if (triggeredByAura->GetAmount() <= int32(damage) || GetHealth() <= damage) { // remember guid before aura delete - uint64 casterGuid = triggeredByAura->GetCasterGUID(); + ObjectGuid casterGuid = triggeredByAura->GetCasterGUID(); // Remove aura (before cast for prevent infinite loop handlers) RemoveAurasDueToSpell(triggeredByAura->GetId()); @@ -6689,7 +6690,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere if (triggeredByAura->GetAmount() <= int32(damage)) { // remember guid before aura delete - uint64 casterGuid = triggeredByAura->GetCasterGUID(); + ObjectGuid casterGuid = triggeredByAura->GetCasterGUID(); // Remove aura (before cast for prevent infinite loop handlers) RemoveAurasDueToSpell(triggeredByAura->GetId()); @@ -9584,7 +9585,7 @@ FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(getFaction()); if (!entry) { - static uint64 guid = 0; // prevent repeating spam same faction problem + static ObjectGuid guid; // prevent repeating spam same faction problem if (GetGUID() != guid) { @@ -9919,7 +9920,7 @@ bool Unit::AttackStop() m_attacking = nullptr; // Clear our target - SetTarget(0); + SetTarget(); ClearUnitState(UNIT_STATE_MELEE_ATTACKING); @@ -10074,16 +10075,16 @@ bool Unit::HasAuraState(AuraStateType flag, SpellInfo const* spellProto, Unit co return HasFlag(UNIT_FIELD_AURASTATE, 1 << (flag - 1)); } -void Unit::SetOwnerGUID(uint64 owner) +void Unit::SetOwnerGUID(ObjectGuid owner) { if (GetOwnerGUID() == owner) return; - SetUInt64Value(UNIT_FIELD_SUMMONEDBY, owner); + SetGuidValue(UNIT_FIELD_SUMMONEDBY, owner); if (!owner) return; - m_applyResilience = !IsVehicle() && IS_PLAYER_GUID(owner); + m_applyResilience = !IsVehicle() && owner.IsPlayer(); // Update owner dependent fields Player* player = ObjectAccessor::GetPlayer(*this, owner); @@ -10103,7 +10104,7 @@ void Unit::SetOwnerGUID(uint64 owner) Unit* Unit::GetOwner() const { - if (uint64 ownerGUID = GetOwnerGUID()) + if (ObjectGuid ownerGUID = GetOwnerGUID()) return ObjectAccessor::GetUnit(*this, ownerGUID); return nullptr; @@ -10111,7 +10112,7 @@ Unit* Unit::GetOwner() const Unit* Unit::GetCharmer() const { - if (uint64 charmerGUID = GetCharmerGUID()) + if (ObjectGuid charmerGUID = GetCharmerGUID()) return ObjectAccessor::GetUnit(*this, charmerGUID); return nullptr; @@ -10119,8 +10120,8 @@ Unit* Unit::GetCharmer() const Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const { - uint64 guid = GetCharmerOrOwnerGUID(); - if (IS_PLAYER_GUID(guid)) + ObjectGuid guid = GetCharmerOrOwnerGUID(); + if (guid.IsPlayer()) return ObjectAccessor::GetPlayer(*this, guid); return const_cast<Unit*>(this)->ToPlayer(); @@ -10139,14 +10140,14 @@ Player* Unit::GetAffectingPlayer() const Minion* Unit::GetFirstMinion() const { - if (uint64 pet_guid = GetMinionGUID()) + if (ObjectGuid pet_guid = GetMinionGUID()) { if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid)) if (pet->HasUnitTypeMask(UNIT_MASK_MINION)) return (Minion*)pet; - LOG_ERROR("server", "Unit::GetFirstMinion: Minion %u not exist.", GUID_LOPART(pet_guid)); - const_cast<Unit*>(this)->SetMinionGUID(0); + LOG_ERROR("server", "Unit::GetFirstMinion: Minion %s not exist.", pet_guid.ToString().c_str()); + const_cast<Unit*>(this)->SetMinionGUID(ObjectGuid::Empty); } return nullptr; @@ -10154,14 +10155,14 @@ Minion* Unit::GetFirstMinion() const Guardian* Unit::GetGuardianPet() const { - if (uint64 pet_guid = GetPetGUID()) + if (ObjectGuid pet_guid = GetPetGUID()) { if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid)) if (pet->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) return (Guardian*)pet; - LOG_FATAL("server", "Unit::GetGuardianPet: Guardian " UI64FMTD " not exist.", pet_guid); - const_cast<Unit*>(this)->SetPetGUID(0); + LOG_FATAL("server", "Unit::GetGuardianPet: Guardian %s not exist.", pet_guid.ToString().c_str()); + const_cast<Unit*>(this)->SetPetGUID(ObjectGuid::Empty); } return nullptr; @@ -10169,13 +10170,13 @@ Guardian* Unit::GetGuardianPet() const Unit* Unit::GetCharm() const { - if (uint64 charm_guid = GetCharmGUID()) + if (ObjectGuid charm_guid = GetCharmGUID()) { if (Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid)) return pet; - LOG_ERROR("server", "Unit::GetCharm: Charmed creature %u not exist.", GUID_LOPART(charm_guid)); - const_cast<Unit*>(this)->SetUInt64Value(UNIT_FIELD_CHARM, 0); + LOG_ERROR("server", "Unit::GetCharm: Charmed creature %s not exist.", charm_guid.ToString().c_str()); + const_cast<Unit*>(this)->SetGuidValue(UNIT_FIELD_CHARM, ObjectGuid::Empty); } return nullptr; @@ -10218,21 +10219,19 @@ void Unit::SetMinion(Minion* minion, bool apply) else oldPet->UnSummon(); SetPetGUID(minion->GetGUID()); - SetMinionGUID(0); + SetMinionGUID(ObjectGuid::Empty); } } else { SetPetGUID(minion->GetGUID()); - SetMinionGUID(0); + SetMinionGUID(ObjectGuid::Empty); } } if (minion->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)) { - if (AddUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID())) - { - } + AddGuidValue(UNIT_FIELD_SUMMON, minion->GetGUID()); } if (minion->m_Properties && minion->m_Properties->Type == SUMMON_TYPE_MINIPET) @@ -10274,13 +10273,13 @@ void Unit::SetMinion(Minion* minion, bool apply) if (minion->m_Properties && minion->m_Properties->Type == SUMMON_TYPE_MINIPET) { if (GetCritterGUID() == minion->GetGUID()) - SetCritterGUID(0); + SetCritterGUID(ObjectGuid::Empty); } if (minion->IsGuardianPet()) { if (GetPetGUID() == minion->GetGUID()) - SetPetGUID(0); + SetPetGUID(ObjectGuid::Empty); } else if (minion->IsTotem()) { @@ -10309,7 +10308,7 @@ void Unit::SetMinion(Minion* minion, bool apply) //if (minion->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) { - if (RemoveUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID())) + if (RemoveGuidValue(UNIT_FIELD_SUMMON, minion->GetGUID())) { // Check if there is another minion for (ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) @@ -10331,7 +10330,7 @@ void Unit::SetMinion(Minion* minion, bool apply) if (!(*itr)->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)) continue; - if (AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID())) + if (AddGuidValue(UNIT_FIELD_SUMMON, (*itr)->GetGUID())) { // show another pet bar if there is no charm bar if (GetTypeId() == TYPEID_PLAYER && !GetCharmGUID()) @@ -10380,8 +10379,8 @@ void Unit::SetCharm(Unit* charm, bool apply) { if (GetTypeId() == TYPEID_PLAYER) { - if (!AddUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) - LOG_FATAL("server", "Player %s is trying to charm unit %u, but it already has a charmed unit " UI64FMTD "", GetName().c_str(), charm->GetEntry(), GetCharmGUID()); + if (!AddGuidValue(UNIT_FIELD_CHARM, charm->GetGUID())) + LOG_FATAL("server", "Player %s is trying to charm unit %u, but it already has a charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmGUID().ToString().c_str()); charm->m_ControlledByPlayer = true; // TODO: maybe we can use this flag to check if controlled by player @@ -10393,8 +10392,8 @@ void Unit::SetCharm(Unit* charm, bool apply) // PvP, FFAPvP charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1)); - if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) - LOG_FATAL("server", "Unit %u is being charmed, but it already has a charmer " UI64FMTD "", charm->GetEntry(), charm->GetCharmerGUID()); + if (!charm->AddGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID())) + LOG_FATAL("server", "Unit %u is being charmed, but it already has a charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str()); if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALKING)) charm->SetWalk(false); @@ -10405,12 +10404,12 @@ void Unit::SetCharm(Unit* charm, bool apply) { if (GetTypeId() == TYPEID_PLAYER) { - if (!RemoveUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) - LOG_FATAL("server", "Player %s is trying to uncharm unit %u, but it has another charmed unit " UI64FMTD "", GetName().c_str(), charm->GetEntry(), GetCharmGUID()); + if (!RemoveGuidValue(UNIT_FIELD_CHARM, charm->GetGUID())) + LOG_FATAL("server", "Player %s is trying to uncharm unit %u, but it has another charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmGUID().ToString().c_str()); } - if (!charm->RemoveUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) - LOG_FATAL("server", "Unit %u is being uncharmed, but it has another charmer " UI64FMTD "", charm->GetEntry(), charm->GetCharmerGUID()); + if (!charm->RemoveGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID())) + LOG_FATAL("server", "Unit %u is being uncharmed, but it has another charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str()); if (charm->GetTypeId() == TYPEID_PLAYER) { @@ -10568,7 +10567,7 @@ Unit* Unit::GetFirstControlled() const // Sequence: charmed, pet, other guardians Unit* unit = GetCharm(); if (!unit) - if (uint64 guid = GetMinionGUID()) + if (ObjectGuid guid = GetMinionGUID()) unit = ObjectAccessor::GetUnit(*this, guid); return unit; @@ -10592,11 +10591,11 @@ void Unit::RemoveAllControlled() LOG_ERROR("server", "Unit %u is trying to release unit %u which is neither charmed nor owned by it", GetEntry(), target->GetEntry()); } if (GetPetGUID()) - LOG_FATAL("server", "Unit %u is not able to release its pet " UI64FMTD, GetEntry(), GetPetGUID()); + LOG_FATAL("server", "Unit %u is not able to release its pet %s", GetEntry(), GetPetGUID().ToString().c_str()); if (GetMinionGUID()) - LOG_FATAL("server", "Unit %u is not able to release its minion " UI64FMTD, GetEntry(), GetMinionGUID()); + LOG_FATAL("server", "Unit %u is not able to release its minion %s", GetEntry(), GetMinionGUID().ToString().c_str()); if (GetCharmGUID()) - LOG_FATAL("server", "Unit %u is not able to release its charm " UI64FMTD, GetEntry(), GetCharmGUID()); + LOG_FATAL("server", "Unit %u is not able to release its charm %s", GetEntry(), GetCharmGUID().ToString().c_str()); } Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) @@ -10707,8 +10706,8 @@ void Unit::SendHealSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, uint32 { // we guess size WorldPacket data(SMSG_SPELLHEALLOG, (8 + 8 + 4 + 4 + 4 + 4 + 1 + 1)); - data.append(victim->GetPackGUID()); - data.append(GetPackGUID()); + data << victim->GetPackGUID(); + data << GetPackGUID(); data << uint32(SpellID); data << uint32(Damage); data << uint32(OverHeal); @@ -10734,8 +10733,8 @@ int32 Unit::HealBySpell(Unit* victim, SpellInfo const* spellInfo, uint32 addHeal void Unit::SendEnergizeSpellLog(Unit* victim, uint32 spellID, uint32 damage, Powers powerType) { WorldPacket data(SMSG_SPELLENERGIZELOG, (8 + 8 + 4 + 4 + 4 + 1)); - data.append(victim->GetPackGUID()); - data.append(GetPackGUID()); + data << victim->GetPackGUID(); + data << GetPackGUID(); data << uint32(spellID); data << uint32(powerType); data << uint32(damage); @@ -12765,7 +12764,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) // Send others that we now have a vehicle WorldPacket data(SMSG_PLAYER_VEHICLE_DATA, GetPackGUID().size() + 4); - data.appendPackGUID(GetGUID()); + data << GetPackGUID(); data << uint32(VehicleId); SendMessageToSet(&data, true); @@ -12795,7 +12794,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(sWorld->GetGameTime()); // Packet counter data << player->GetCollisionHeight(); player->GetSession()->SendPacket(&data); @@ -12815,14 +12814,14 @@ void Unit::Dismount() if (Player* thisPlayer = ToPlayer()) { WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(sWorld->GetGameTime()); // Packet counter data << thisPlayer->GetCollisionHeight(); thisPlayer->GetSession()->SendPacket(&data); } WorldPacket data(SMSG_DISMOUNT, 8); - data.appendPackGUID(GetGUID()); + data << GetPackGUID(); SendMessageToSet(&data, true); // dismount as a vehicle @@ -12830,7 +12829,7 @@ void Unit::Dismount() { // Send other players that we are no longer a vehicle data.Initialize(SMSG_PLAYER_VEHICLE_DATA, 8 + 4); - data.appendPackGUID(GetGUID()); + data << GetPackGUID(); data << uint32(0); ToPlayer()->SendMessageToSet(&data, true); // Remove vehicle from player @@ -13409,7 +13408,7 @@ bool Unit::IsAlwaysVisibleFor(WorldObject const* seer) const return true; // Always seen by owner - if (uint64 guid = GetCharmerOrOwnerGUID()) + if (ObjectGuid guid = GetCharmerOrOwnerGUID()) if (seer->GetGUID() == guid) return true; @@ -13764,7 +13763,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) LOG_ERROR("server", "Unit::SetSpeed: Unsupported move type (%d), data not sent to client.", mtype); return; } - data.append(GetPackGUID()); + data << GetPackGUID(); data << (uint32)0; // moveEvent, NUM_PMOVE_EVTS = 0x39 if (mtype == MOVE_RUN) data << uint8(0); // new 2.1.0 @@ -13854,7 +13853,7 @@ bool Unit::CanHaveThreatList() const return false; // summons can not have a threat list, unless they are controlled by a creature - if (HasUnitTypeMask(UNIT_MASK_MINION | UNIT_MASK_GUARDIAN | UNIT_MASK_CONTROLABLE_GUARDIAN) && IS_PLAYER_GUID(((Pet*)this)->GetOwnerGUID())) + if (HasUnitTypeMask(UNIT_MASK_MINION | UNIT_MASK_GUARDIAN | UNIT_MASK_CONTROLABLE_GUARDIAN) && ((Pet*)this)->GetOwnerGUID().IsPlayer()) return false; return true; @@ -14684,7 +14683,7 @@ void Unit::SetLevel(uint8 lvl, bool showLevelChange) // xinef: update global data if (GetTypeId() == TYPEID_PLAYER) - sWorld->UpdateGlobalPlayerData(ToPlayer()->GetGUIDLow(), PLAYER_UPDATE_DATA_LEVEL, "", lvl); + sWorld->UpdateGlobalPlayerData(ToPlayer()->GetGUID().GetCounter(), PLAYER_UPDATE_DATA_LEVEL, "", lvl); } void Unit::SetHealth(uint32 val) @@ -14779,7 +14778,7 @@ void Unit::SetPower(Powers power, uint32 val) SetStatInt32Value(UNIT_FIELD_POWER1 + power, val); WorldPacket data(SMSG_POWER_UPDATE); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint8(power); data << uint32(val); SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER); @@ -15010,7 +15009,7 @@ void Unit::DeleteCharmInfo() CharmInfo::CharmInfo(Unit* unit) : _unit(unit), _CommandState(COMMAND_FOLLOW), _petnumber(0), _oldReactState(REACT_PASSIVE), _isCommandAttack(false), _isCommandFollow(false), _isAtStay(false), _isFollowing(false), _isReturning(false), - _forcedSpellId(0), _forcedTargetGUID(0), _stayX(0.0f), _stayY(0.0f), _stayZ(0.0f) + _forcedSpellId(0), _stayX(0.0f), _stayY(0.0f), _stayZ(0.0f) { for (uint8 i = 0; i < MAX_SPELL_CHARM; ++i) _charmspells[i].SetActionAndType(0, ACT_DISABLED); @@ -16038,19 +16037,19 @@ void Unit::SendPetTalk(uint32 pettalk) return; WorldPacket data(SMSG_PET_ACTION_SOUND, 8 + 4); - data << uint64(GetGUID()); + data << GetGUID(); data << uint32(pettalk); owner->ToPlayer()->GetSession()->SendPacket(&data); } -void Unit::SendPetAIReaction(uint64 guid) +void Unit::SendPetAIReaction(ObjectGuid guid) { Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; WorldPacket data(SMSG_AI_REACTION, 8 + 4); - data << uint64(guid); + data << guid; data << uint32(AI_REACTION_HOSTILE); owner->ToPlayer()->GetSession()->SendPacket(&data); } @@ -16202,13 +16201,13 @@ void Unit::ClearComboPointHolders() { while (!m_ComboPointHolders.empty()) { - uint32 lowguid = *m_ComboPointHolders.begin(); + ObjectGuid guid = *m_ComboPointHolders.begin(); - Player* player = ObjectAccessor::GetPlayer(*this, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); + Player* player = ObjectAccessor::GetPlayer(*this, guid); if (player && player->GetComboTarget() == GetGUID()) // recheck for safe player->ClearComboPoints(); // remove also guid from m_ComboPointHolders; else - m_ComboPointHolders.erase(lowguid); // or remove manually + m_ComboPointHolders.erase(guid); // or remove manually } } @@ -16796,7 +16795,7 @@ bool Unit::HandleAuraRaidProcFromChargeWithValue(AuraEffect* triggeredByAura) // aura can be deleted at casts SpellInfo const* spellProto = triggeredByAura->GetSpellInfo(); int32 heal = triggeredByAura->GetAmount(); - uint64 caster_guid = triggeredByAura->GetCasterGUID(); + ObjectGuid caster_guid = triggeredByAura->GetCasterGUID(); // Currently only Prayer of Mending if (!(spellProto->SpellFamilyName == SPELLFAMILY_PRIEST && spellProto->SpellFamilyFlags[1] & 0x20)) @@ -16905,7 +16904,7 @@ bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura) return false; } - uint64 caster_guid = triggeredByAura->GetCasterGUID(); + ObjectGuid caster_guid = triggeredByAura->GetCasterGUID(); // jumps int32 jumps = triggeredByAura->GetBase()->GetCharges() - 1; @@ -16971,7 +16970,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp } // Exploit fix - if (creature && creature->IsPet() && IS_PLAYER_GUID(creature->GetOwnerGUID())) + if (creature && creature->IsPet() && creature->GetOwnerGUID().IsPlayer()) isRewardAllowed = false; // Reward player, his pets, and group/raid members @@ -16979,8 +16978,8 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp if (isRewardAllowed && player && player != victim) { WorldPacket data(SMSG_PARTYKILLLOG, (8 + 8)); // send event PARTY_KILL - data << uint64(player->GetGUID()); // player with killing blow - data << uint64(victim->GetGUID()); // victim + data << player->GetGUID(); // player with killing blow + data << victim->GetGUID(); // victim Player* looter = player; Group* group = player->GetGroup(); @@ -17011,7 +17010,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp if (creature) { WorldPacket data2(SMSG_LOOT_LIST, 8 + 1 + 1); - data2 << uint64(creature->GetGUID()); + data2 << creature->GetGUID(); data2 << uint8(0); // unk1 data2 << uint8(0); // no group looter player->SendMessageToSet(&data2, true); @@ -17076,8 +17075,8 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp // Xinef: aura_spirit_of_redemption is triggered by 27827 shapeshift if (victim->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) || victim->HasAura(27827)) { - /*LOG_INFO("misc", "Player (%u) died with spirit of redemption. Killer (Entry: %u, Name: %s), Map: %u, x: %f, y: %f, z: %f", - victim->GetGUIDLow(), killer ? killer->GetEntry() : 1, killer ? killer->GetName().c_str() : "", victim->GetMapId(), victim->GetPositionX(), + /*LOG_INFO("misc", "Player (%s) died with spirit of redemption. Killer (Entry: %u, Name: %s), Map: %u, x: %f, y: %f, z: %f", + victim->GetGUID().ToString().c_str(), killer ? killer->GetEntry() : 1, killer ? killer->GetName().c_str() : "", victim->GetMapId(), victim->GetPositionX(), victim->GetPositionY(), victim->GetPositionZ()); ACE_Stack_Trace trace(0, 50); @@ -17350,7 +17349,7 @@ void Unit::SetStunned(bool apply) if (m_rootTimes > 0) // blizzard internal check? m_rootTimes++; - SetTarget(0); + SetTarget(); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); // MOVEMENTFLAG_ROOT cannot be used in conjunction with MOVEMENTFLAG_MASK_MOVING (tested 3.3.5a) @@ -17362,14 +17361,14 @@ void Unit::SetStunned(bool apply) if (GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10); - data.append(GetPackGUID()); + data << GetPackGUID(); data << m_rootTimes; SendMessageToSet(&data, true); } else { WorldPacket data(SMSG_SPLINE_MOVE_ROOT, 8); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, true); } @@ -17409,14 +17408,14 @@ void Unit::SetStunned(bool apply) if (GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10); - data.append(GetPackGUID()); + data << GetPackGUID(); data << ++m_rootTimes; SendMessageToSet(&data, true); } else { WorldPacket data(SMSG_SPLINE_MOVE_UNROOT, 8); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, true); } @@ -17441,14 +17440,14 @@ void Unit::SetRooted(bool apply) if (GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10); - data.append(GetPackGUID()); + data << GetPackGUID(); data << m_rootTimes; SendMessageToSet(&data, true); } else { WorldPacket data(SMSG_SPLINE_MOVE_ROOT, 8); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, true); StopMoving(); } @@ -17460,14 +17459,14 @@ void Unit::SetRooted(bool apply) if (GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10); - data.append(GetPackGUID()); + data << GetPackGUID(); data << ++m_rootTimes; SendMessageToSet(&data, true); } else { WorldPacket data(SMSG_SPLINE_MOVE_UNROOT, 8); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, true); } @@ -17491,7 +17490,7 @@ void Unit::SetFeared(bool apply) { if (apply) { - SetTarget(0); + SetTarget(); Unit* caster = nullptr; Unit::AuraEffectList const& fearAuras = GetAuraEffectsByType(SPELL_AURA_MOD_FEAR); @@ -17530,7 +17529,7 @@ void Unit::SetConfused(bool apply) { if (apply) { - SetTarget(0); + SetTarget(); GetMotionMaster()->MoveConfused(); } else @@ -17583,12 +17582,13 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au ASSERT((type == CHARM_TYPE_VEHICLE) == IsVehicle()); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.unit", "SetCharmedBy: charmer %u (GUID %u), charmed %u (GUID %u), type %u.", charmer->GetEntry(), charmer->GetGUIDLow(), GetEntry(), GetGUIDLow(), uint32(type)); + LOG_DEBUG("entities.unit", "SetCharmedBy: charmer %u (%s), charmed %u (%s), type %u.", + charmer->GetEntry(), charmer->GetGUID().ToString().c_str(), GetEntry(), GetGUID().ToString().c_str(), uint32(type)); #endif if (this == charmer) { - LOG_FATAL("server", "Unit::SetCharmedBy: Unit %u (GUID %u) is trying to charm itself!", GetEntry(), GetGUIDLow()); + LOG_FATAL("server", "Unit::SetCharmedBy: Unit %u (%s) is trying to charm itself!", GetEntry(), GetGUID().ToString().c_str()); return false; } @@ -17597,14 +17597,15 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetTransport()) { - LOG_FATAL("server", "Unit::SetCharmedBy: Player on transport is trying to charm %u (GUID %u)", GetEntry(), GetGUIDLow()); + LOG_FATAL("server", "Unit::SetCharmedBy: Player on transport is trying to charm %u (%s)", GetEntry(), GetGUID().ToString().c_str()); return false; } // Already charmed if (GetCharmerGUID()) { - LOG_FATAL("server", "Unit::SetCharmedBy: %u (GUID %u) has already been charmed but %u (GUID %u) is trying to charm it!", GetEntry(), GetGUIDLow(), charmer->GetEntry(), charmer->GetGUIDLow()); + LOG_FATAL("server", "Unit::SetCharmedBy: %u (%s) has already been charmed but %u (%s) is trying to charm it!", + GetEntry(), GetGUID().ToString().c_str(), charmer->GetEntry(), charmer->GetGUID().ToString().c_str()); return false; } @@ -17634,7 +17635,8 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au // StopCastingCharm may remove a possessed pet? if (!IsInWorld()) { - LOG_FATAL("server", "Unit::SetCharmedBy: %u (GUID %u) is not in world but %u (GUID %u) is trying to charm it!", GetEntry(), GetGUIDLow(), charmer->GetEntry(), charmer->GetGUIDLow()); + LOG_FATAL("server", "Unit::SetCharmedBy: %u (%s) is not in world but %u (%s) is trying to charm it!", + GetEntry(), GetGUID().ToString().c_str(), charmer->GetEntry(), charmer->GetGUID().ToString().c_str()); return false; } @@ -17763,8 +17765,8 @@ void Unit::RemoveCharmedBy(Unit* charmer) charmer = GetCharmer(); if (charmer != GetCharmer()) // one aura overrides another? { - // LOG_FATAL("server", "Unit::RemoveCharmedBy: this: " UI64FMTD " true charmer: " UI64FMTD " false charmer: " UI64FMTD, - // GetGUID(), GetCharmerGUID(), charmer->GetGUID()); + // LOG_FATAL("server", "Unit::RemoveCharmedBy: this: %s true charmer: %s false charmer: %s", + // GetGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str(), charmer->GetGUID().ToString().c_str()); // ABORT(); return; } @@ -17848,7 +17850,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) if (GetCharmInfo()) GetCharmInfo()->SetPetNumber(0, true); else - LOG_ERROR("server", "Aura::HandleModCharm: target=" UI64FMTD " with typeid=%d has a charm aura but no charm info!", GetGUID(), GetTypeId()); + LOG_ERROR("server", "Aura::HandleModCharm: target=%s has a charm aura but no charm info!", GetGUID().ToString().c_str()); } } break; @@ -17954,14 +17956,15 @@ Creature* Unit::GetVehicleCreatureBase() const return nullptr; } -uint64 Unit::GetTransGUID() const +ObjectGuid Unit::GetTransGUID() const { if (GetVehicle()) return GetVehicleBase()->GetGUID(); + if (GetTransport()) return GetTransport()->GetGUID(); - return 0; + return ObjectGuid::Empty; } TransportBase* Unit::GetDirectTransport() const @@ -18111,15 +18114,15 @@ void Unit::SetAuraStack(uint32 spellId, Unit* target, uint32 stack) void Unit::SendPlaySpellVisual(uint32 id) { WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 8 + 4); - data << uint64(GetGUID()); + data << GetGUID(); data << uint32(id); // SpellVisualKit.dbc index SendMessageToSet(&data, true); } -void Unit::SendPlaySpellImpact(uint64 guid, uint32 id) +void Unit::SendPlaySpellImpact(ObjectGuid guid, uint32 id) { WorldPacket data(SMSG_PLAY_SPELL_IMPACT, 8 + 4); - data << uint64(guid); // target + data << guid; // target data << uint32(id); // SpellVisualKit.dbc index SendMessageToSet(&data, true); } @@ -18312,7 +18315,7 @@ void Unit::UpdateObjectVisibility(bool forced, bool /*fromUpdate*/) WorldObject::UpdateObjectVisibility(true); // pussywizard: generally this is not needed here, delayed notifier will handle this, call only for pets - if ((IsGuardian() || IsPet()) && IS_PLAYER_GUID(GetOwnerGUID())) + if ((IsGuardian() || IsPet()) && GetOwnerGUID().IsPlayer()) { acore::AIRelocationNotifier notifier(*this); float radius = 60.0f; @@ -18344,7 +18347,7 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ) GetSinCos(x, y, vsin, vcos); WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8 + 4 + 4 + 4 + 4 + 4)); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(0); // counter data << float(vcos); // x direction data << float(vsin); // y direction @@ -18690,7 +18693,7 @@ void Unit::JumpTo(float speedXY, float speedZ, bool forward) float vsin = sin(angle + GetOrientation()); WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8 + 4 + 4 + 4 + 4 + 4)); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(0); // Sequence data << float(vcos); // x direction data << float(vsin); // y direction @@ -18728,7 +18731,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) Unit* caster = (itr->second.castFlags & NPC_CLICK_CAST_CASTER_CLICKER) ? clicker : this; Unit* target = (itr->second.castFlags & NPC_CLICK_CAST_TARGET_CLICKER) ? clicker : this; - uint64 origCasterGUID = (itr->second.castFlags & NPC_CLICK_CAST_ORIG_CASTER_OWNER) ? GetOwnerGUID() : clicker->GetGUID(); + ObjectGuid origCasterGUID = (itr->second.castFlags & NPC_CLICK_CAST_ORIG_CASTER_OWNER) ? GetOwnerGUID() : clicker->GetGUID(); SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(itr->second.spellId); @@ -18955,7 +18958,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) else if (HasUnitMovementFlag(MOVEMENTFLAG_ROOT)) { WorldPacket data(SMSG_SPLINE_MOVE_UNROOT, 8); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, false); } @@ -19039,9 +19042,9 @@ void Unit::BuildMovementPacket(ByteBuffer* data) const if (GetUnitMovementFlags() & MOVEMENTFLAG_ONTRANSPORT) { if (m_vehicle) - data->append(m_vehicle->GetBase()->GetPackGUID()); + *data << m_vehicle->GetBase()->GetPackGUID(); else if (GetTransport()) - data->append(GetTransport()->GetPackGUID()); + *data << GetTransport()->GetPackGUID(); else *data << (uint8)0; @@ -19132,7 +19135,7 @@ void Unit::SendTeleportPacket(Position& pos) Relocate(&pos); WorldPacket data2(MSG_MOVE_TELEPORT, 38); - data2.append(GetPackGUID()); + data2 << GetPackGUID(); BuildMovementPacket(&data2); if (GetTypeId() == TYPEID_UNIT) Relocate(&oldPos); @@ -19197,12 +19200,12 @@ void Unit::SendThreatListUpdate() //LOG_DEBUG("entities.unit", "WORLD: Send SMSG_THREAT_UPDATE Message"); WorldPacket data(SMSG_THREAT_UPDATE, 8 + count * 8); - data.append(GetPackGUID()); + data << GetPackGUID(); data << uint32(count); ThreatContainer::StorageType const& tlist = getThreatManager().getThreatList(); for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { - data.appendPackGUID((*itr)->getUnitGuid()); + data << (*itr)->getUnitGuid().WriteAsPacked(); data << uint32((*itr)->getThreat() * 100); } SendMessageToSet(&data, false); @@ -19219,13 +19222,13 @@ void Unit::SendChangeCurrentVictimOpcode(HostileReference* pHostileReference) LOG_DEBUG("entities.unit", "WORLD: Send SMSG_HIGHEST_THREAT_UPDATE Message"); #endif WorldPacket data(SMSG_HIGHEST_THREAT_UPDATE, 8 + 8 + count * 8); - data.append(GetPackGUID()); - data.appendPackGUID(pHostileReference->getUnitGuid()); + data << GetPackGUID(); + data << pHostileReference->getUnitGuid().WriteAsPacked(); data << uint32(count); ThreatContainer::StorageType const& tlist = getThreatManager().getThreatList(); for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { - data.appendPackGUID((*itr)->getUnitGuid()); + data << (*itr)->getUnitGuid().WriteAsPacked(); data << uint32((*itr)->getThreat() * 100); } SendMessageToSet(&data, false); @@ -19238,7 +19241,7 @@ void Unit::SendClearThreatListOpcode() LOG_DEBUG("entities.unit", "WORLD: Send SMSG_THREAT_CLEAR Message"); #endif WorldPacket data(SMSG_THREAT_CLEAR, 8); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, false); } @@ -19248,8 +19251,8 @@ void Unit::SendRemoveFromThreatListOpcode(HostileReference* pHostileReference) LOG_DEBUG("entities.unit", "WORLD: Send SMSG_THREAT_REMOVE Message"); #endif WorldPacket data(SMSG_THREAT_REMOVE, 8 + 8); - data.append(GetPackGUID()); - data.appendPackGUID(pHostileReference->getUnitGuid()); + data << GetPackGUID(); + data << pHostileReference->getUnitGuid().WriteAsPacked(); SendMessageToSet(&data, false); } @@ -19321,20 +19324,21 @@ void Unit::StopAttackFaction(uint32 faction_id) void Unit::OutDebugInfo() const { LOG_ERROR("server", "Unit::OutDebugInfo"); - LOG_INFO("server", "GUID " UI64FMTD ", entry %u, type %u, name %s", GetGUID(), GetEntry(), (uint32)GetTypeId(), GetName().c_str()); - LOG_INFO("server", "OwnerGUID " UI64FMTD ", MinionGUID " UI64FMTD ", CharmerGUID " UI64FMTD ", CharmedGUID " UI64FMTD, GetOwnerGUID(), GetMinionGUID(), GetCharmerGUID(), GetCharmGUID()); + LOG_INFO("server", "GUID %s, name %s", GetGUID().ToString().c_str(), GetName().c_str()); + LOG_INFO("server", "OwnerGUID %s, MinionGUID %s, CharmerGUID %s, CharmedGUID %s", + GetOwnerGUID().ToString().c_str(), GetMinionGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str(), GetCharmGUID().ToString().c_str()); LOG_INFO("server", "In world %u, unit type mask %u", (uint32)(IsInWorld() ? 1 : 0), m_unitTypeMask); if (IsInWorld()) LOG_INFO("server", "Mapid %u", GetMapId()); LOG_INFO("server", "Summon Slot: "); for (uint32 i = 0; i < MAX_SUMMON_SLOT; ++i) - LOG_INFO("server", UI64FMTD", ", m_SummonSlot[i]); + LOG_INFO("server", "%s, ", m_SummonSlot[i].ToString().c_str()); LOG_INFO("server", " "); LOG_INFO("server", "Controlled List: "); for (ControlSet::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) - LOG_INFO("server", UI64FMTD", ", (*itr)->GetGUID()); + LOG_INFO("server", "%s, ", (*itr)->GetGUID().ToString().c_str()); LOG_INFO("server", " "); LOG_INFO("server", "Aura List: "); @@ -19347,7 +19351,7 @@ void Unit::OutDebugInfo() const LOG_INFO("server", "Passenger List: "); for (SeatMap::iterator itr = GetVehicleKit()->Seats.begin(); itr != GetVehicleKit()->Seats.end(); ++itr) if (Unit* passenger = ObjectAccessor::GetUnit(*GetVehicleBase(), itr->second.Passenger.Guid)) - LOG_INFO("server", UI64FMTD", ", passenger->GetGUID()); + LOG_INFO("server", "%s, ", passenger->GetGUID().ToString().c_str()); LOG_INFO("server", " "); } @@ -19358,7 +19362,7 @@ void Unit::OutDebugInfo() const class AuraMunchingQueue : public BasicEvent { public: - AuraMunchingQueue(Unit& owner, uint64 targetGUID, int32 basePoints, uint32 spellId) : _owner(owner), _targetGUID(targetGUID), _basePoints(basePoints), _spellId(spellId) { } + AuraMunchingQueue(Unit& owner, ObjectGuid targetGUID, int32 basePoints, uint32 spellId) : _owner(owner), _targetGUID(targetGUID), _basePoints(basePoints), _spellId(spellId) { } bool Execute(uint64 /*eventTime*/, uint32 /*updateTime*/) override { @@ -19371,7 +19375,7 @@ public: private: Unit& _owner; - uint64 _targetGUID; + ObjectGuid _targetGUID; int32 _basePoints; uint32 _spellId; }; @@ -19398,7 +19402,7 @@ void Unit::CastDelayedSpellWithPeriodicAmount(Unit* caster, uint32 spellId, Aura void Unit::SendClearTarget() { WorldPacket data(SMSG_BREAK_TARGET, GetPackGUID().size()); - data.append(GetPackGUID()); + data << GetPackGUID(); SendMessageToSet(&data, false); } @@ -19550,7 +19554,7 @@ void Unit::PetSpellFail(const SpellInfo* spellInfo, Unit* target, uint32 result) else { charmInfo->SetForcedSpell(0); - charmInfo->SetForcedTargetGUID(0); + charmInfo->SetForcedTargetGUID(ObjectGuid::Empty); } } } @@ -19564,13 +19568,12 @@ int32 Unit::CalculateAOEDamageReduction(int32 damage, uint32 schoolMask, Unit* c return damage; } -bool ConflagrateAuraStateDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) +bool ConflagrateAuraStateDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { - if (Unit* owner = ObjectAccessor::FindUnit(m_owner)) - if (owner && m_caster && owner->IsInWorld()) - if (owner->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0x4, 0, 0, m_caster) || // immolate - owner->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0, 0, 0x2, m_caster)) // shadowflame - owner->ModifyAuraState(AURA_STATE_CONFLAGRATE, true); + if (m_owner->IsInWorld()) + if (m_owner->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0x4, 0, 0, m_casterGUID) || // immolate + m_owner->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0, 0, 0x2, m_casterGUID)) // shadowflame + m_owner->ModifyAuraState(AURA_STATE_CONFLAGRATE, true); return true; } @@ -19858,7 +19861,7 @@ void Unit::SendMovementWaterWalking(Player* sendTo) if (!movespline->Initialized()) return; WorldPacket data(SMSG_SPLINE_MOVE_WATER_WALK, 9); - data.append(GetPackGUID()); + data << GetPackGUID(); sendTo->SendDirectMessage(&data); } @@ -19880,7 +19883,7 @@ void Unit::SendMovementFeatherFall(Player* sendTo) if (!movespline->Initialized()) return; WorldPacket data(SMSG_SPLINE_MOVE_FEATHER_FALL, 9); - data.append(GetPackGUID()); + data << GetPackGUID(); sendTo->SendDirectMessage(&data); } @@ -19917,7 +19920,7 @@ void Unit::SendMovementHover(Player* sendTo) if (!movespline->Initialized()) return; WorldPacket data(SMSG_SPLINE_MOVE_SET_HOVER, 9); - data.append(GetPackGUID()); + data << GetPackGUID(); sendTo->SendDirectMessage(&data); } @@ -20117,7 +20120,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, uint32 spellId, uint32 cooldown) { data.Initialize(SMSG_SPELL_COOLDOWN, 8 + 1 + 4 + 4); - data << uint64(GetGUID()); + data << GetGUID(); data << uint8(flags); data << uint32(spellId); data << uint32(cooldown); @@ -20126,7 +20129,7 @@ void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, uint32 spellId, u void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns const& cooldowns) { data.Initialize(SMSG_SPELL_COOLDOWN, 8 + 1 + (4 + 4) * cooldowns.size()); - data << uint64(GetGUID()); + data << GetGUID(); data << uint8(flags); for (std::unordered_map<uint32, uint32>::const_iterator itr = cooldowns.begin(); itr != cooldowns.end(); ++itr) { @@ -20161,7 +20164,7 @@ bool Unit::IsInCombatWith(Unit const* who) const if (!who) return false; // Search in threat list - uint64 guid = who->GetGUID(); + ObjectGuid guid = who->GetGUID(); for (ThreatContainer::StorageType::const_iterator i = m_ThreatManager.getThreatList().begin(); i != m_ThreatManager.getThreatList().end(); ++i) { HostileReference* ref = (*i); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index bbbd9dc7aa..bbbb519b25 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1039,13 +1039,13 @@ uint32 createProcExtendMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missC struct RedirectThreatInfo { RedirectThreatInfo() { } - uint64 _targetGUID{0}; + ObjectGuid _targetGUID; uint32 _threatPct{0}; - [[nodiscard]] uint64 GetTargetGUID() const { return _targetGUID; } + [[nodiscard]] ObjectGuid GetTargetGUID() const { return _targetGUID; } [[nodiscard]] uint32 GetThreatPct() const { return _threatPct; } - void Set(uint64 guid, uint32 pct) + void Set(ObjectGuid guid, uint32 pct) { _targetGUID = guid; _threatPct = pct; @@ -1235,8 +1235,8 @@ public: void SetForcedSpell(uint32 id) { _forcedSpellId = id; } int32 GetForcedSpell() { return _forcedSpellId; } - void SetForcedTargetGUID(uint64 guid) { _forcedTargetGUID = guid; } - uint64 GetForcedTarget() { return _forcedTargetGUID; } + void SetForcedTargetGUID(ObjectGuid guid = ObjectGuid::Empty) { _forcedTargetGUID = guid; } + ObjectGuid GetForcedTarget() { return _forcedTargetGUID; } // Player react states void SetPlayerReactState(ReactStates s) { _oldReactState = s; } @@ -1258,7 +1258,7 @@ private: bool _isFollowing; bool _isReturning; int32 _forcedSpellId; - uint64 _forcedTargetGUID; + ObjectGuid _forcedTargetGUID; float _stayX; float _stayY; float _stayZ; @@ -1400,7 +1400,7 @@ public: typedef std::list<Aura*> AuraList; typedef std::list<AuraApplication*> AuraApplicationList; typedef std::list<DiminishingReturn> Diminishing; - typedef std::unordered_set<uint32> ComboPointHolderSet; + typedef GuidUnorderedSet ComboPointHolderSet; typedef std::map<uint8, AuraApplication*> VisibleAuraMap; @@ -1486,7 +1486,7 @@ public: [[nodiscard]] bool CanFreeMove() const { return !HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING | UNIT_STATE_IN_FLIGHT | - UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) && GetOwnerGUID() == 0; + UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) && !GetOwnerGUID(); } [[nodiscard]] uint32 HasUnitTypeMask(uint32 mask) const { return mask & m_unitTypeMask; } @@ -1774,22 +1774,22 @@ public: void SendEnergizeSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, Powers powertype); void EnergizeBySpell(Unit* victim, uint32 SpellID, uint32 Damage, Powers powertype); - SpellCastResult CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0); - SpellCastResult CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0); - SpellCastResult CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0); - SpellCastResult CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0); - SpellCastResult CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0); - SpellCastResult CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0); - SpellCastResult CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect* triggeredByAura = nullptr, uint64 originalCaster = 0); - SpellCastResult CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0); - SpellCastResult CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0); - SpellCastResult CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0); - SpellCastResult CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0); + SpellCastResult CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + SpellCastResult CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + SpellCastResult CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + SpellCastResult CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + SpellCastResult CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + SpellCastResult CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + SpellCastResult CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + SpellCastResult CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + SpellCastResult CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + SpellCastResult CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + SpellCastResult CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); Aura* AddAura(uint32 spellId, Unit* target); Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target); void SetAuraStack(uint32 spellId, Unit* target, uint32 stack); void SendPlaySpellVisual(uint32 id); - void SendPlaySpellImpact(uint64 guid, uint32 id); + void SendPlaySpellImpact(ObjectGuid guid, uint32 id); void BuildCooldownPacket(WorldPacket& data, uint8 flags, uint32 spellId, uint32 cooldown); void BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns const& cooldowns); @@ -1856,30 +1856,31 @@ public: DeathState getDeathState() { return m_deathState; }; virtual void setDeathState(DeathState s, bool despawn = false); // overwrited in Creature/Player/Pet - [[nodiscard]] uint64 GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY); } - void SetOwnerGUID(uint64 owner); - [[nodiscard]] uint64 GetCreatorGUID() const { return GetUInt64Value(UNIT_FIELD_CREATEDBY); } - void SetCreatorGUID(uint64 creator) { SetUInt64Value(UNIT_FIELD_CREATEDBY, creator); } - [[nodiscard]] uint64 GetMinionGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); } - void SetMinionGUID(uint64 guid) { SetUInt64Value(UNIT_FIELD_SUMMON, guid); } - [[nodiscard]] uint64 GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY); } - void SetCharmerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner); } - [[nodiscard]] uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); } - void SetPetGUID(uint64 guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; } - [[nodiscard]] uint64 GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; } - void SetCritterGUID(uint64 guid) { SetUInt64Value(UNIT_FIELD_CRITTER, guid); } - [[nodiscard]] uint64 GetCritterGUID() const { return GetUInt64Value(UNIT_FIELD_CRITTER); } + [[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(UNIT_FIELD_SUMMONEDBY); } + void SetOwnerGUID(ObjectGuid owner); + [[nodiscard]] ObjectGuid GetCreatorGUID() const { return GetGuidValue(UNIT_FIELD_CREATEDBY); } + void SetCreatorGUID(ObjectGuid creator) { SetGuidValue(UNIT_FIELD_CREATEDBY, creator); } + [[nodiscard]] ObjectGuid GetMinionGUID() const { return GetGuidValue(UNIT_FIELD_SUMMON); } + void SetMinionGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_SUMMON, guid); } + [[nodiscard]] ObjectGuid GetCharmerGUID() const { return GetGuidValue(UNIT_FIELD_CHARMEDBY); } + void SetCharmerGUID(ObjectGuid owner) { SetGuidValue(UNIT_FIELD_CHARMEDBY, owner); } + [[nodiscard]] ObjectGuid GetCharmGUID() const { return GetGuidValue(UNIT_FIELD_CHARM); } + void SetPetGUID(ObjectGuid guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; } + [[nodiscard]] ObjectGuid GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; } + void SetCritterGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CRITTER, guid); } + [[nodiscard]] ObjectGuid GetCritterGUID() const { return GetGuidValue(UNIT_FIELD_CRITTER); } [[nodiscard]] bool IsControlledByPlayer() const { return m_ControlledByPlayer; } [[nodiscard]] bool IsCreatedByPlayer() const { return m_CreatedByPlayer; } - [[nodiscard]] uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); } - [[nodiscard]] uint64 GetCharmerOrOwnerOrOwnGUID() const + [[nodiscard]] ObjectGuid GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); } + [[nodiscard]] ObjectGuid GetCharmerOrOwnerOrOwnGUID() const { - if (uint64 guid = GetCharmerOrOwnerGUID()) + if (ObjectGuid guid = GetCharmerOrOwnerGUID()) return guid; + return GetGUID(); } - [[nodiscard]] bool IsCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); } + [[nodiscard]] bool IsCharmedOwnedByPlayerOrPlayer() const { return GetCharmerOrOwnerOrOwnGUID().IsPlayer(); } [[nodiscard]] Player* GetSpellModOwner() const; @@ -1912,9 +1913,9 @@ public: [[nodiscard]] Unit* GetFirstControlled() const; void RemoveAllControlled(); - [[nodiscard]] bool IsCharmed() const { return GetCharmerGUID() != 0; } + [[nodiscard]] bool IsCharmed() const { return GetCharmerGUID(); } [[nodiscard]] bool isPossessed() const { return HasUnitState(UNIT_STATE_POSSESSED); } - [[nodiscard]] bool isPossessedByPlayer() const { return HasUnitState(UNIT_STATE_POSSESSED) && IS_PLAYER_GUID(GetCharmerGUID()); } + [[nodiscard]] bool isPossessedByPlayer() const { return HasUnitState(UNIT_STATE_POSSESSED) && GetCharmerGUID().IsPlayer(); } [[nodiscard]] bool isPossessing() const { if (Unit* u = GetCharm()) @@ -1942,7 +1943,7 @@ public: bool InitTamedPet(Pet* pet, uint8 level, uint32 spell_id); // aura apply/remove helpers - you should better not use these - Aura* _TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, uint64 casterGUID = 0, bool periodicReset = false); + Aura* _TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, ObjectGuid casterGUID = ObjectGuid::Empty, bool periodicReset = false); void _AddAura(UnitAura* aura, Unit* caster); AuraApplication* _CreateAuraApplication(Aura* aura, uint8 effMask); void _ApplyAuraEffect(Aura* aura, uint8 effIndex); @@ -1959,17 +1960,17 @@ public: [[nodiscard]] AuraMap const& GetOwnedAuras() const { return m_ownedAuras; } void RemoveOwnedAura(AuraMap::iterator& i, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); - void RemoveOwnedAura(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); + void RemoveOwnedAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); void RemoveOwnedAura(Aura* aura, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); - Aura* GetOwnedAura(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0, Aura* except = nullptr) const; + Aura* GetOwnedAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, Aura* except = nullptr) const; // m_appliedAuras container management AuraApplicationMap& GetAppliedAuras() { return m_appliedAuras; } [[nodiscard]] AuraApplicationMap const& GetAppliedAuras() const { return m_appliedAuras; } void RemoveAura(AuraApplicationMap::iterator& i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveAura(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); + void RemoveAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); void RemoveAura(AuraApplication* aurApp, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAura(Aura* aur, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); @@ -1981,16 +1982,16 @@ public: void RemoveAppliedAuras(uint32 spellId, std::function<bool(AuraApplication const*)> const& check); void RemoveOwnedAuras(uint32 spellId, std::function<bool(Aura const*)> const& check); - void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); - void RemoveAuraFromStack(uint32 spellId, uint64 casterGUID = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); - void RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, uint64 casterGUID, Unit* dispeller, uint8 chargesRemoved = 1); - void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* stealer); - void RemoveAurasDueToItemSpell(uint32 spellId, uint64 castItemGuid); - void RemoveAurasByType(AuraType auraType, uint64 casterGUID = 0, Aura* except = nullptr, bool negative = true, bool positive = true); + void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); + void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); + void RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, Unit* dispeller, uint8 chargesRemoved = 1); + void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, Unit* stealer); + void RemoveAurasDueToItemSpell(uint32 spellId, ObjectGuid castItemGuid); + void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID = ObjectGuid::Empty, Aura* except = nullptr, bool negative = true, bool positive = true); void RemoveNotOwnSingleTargetAuras(); void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except = 0); void RemoveAurasWithAttribute(uint32 flags); - void RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID); + void RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID); void RemoveAurasWithMechanic(uint32 mechanic_mask, AuraRemoveMode removemode = AURA_REMOVE_BY_DEFAULT, uint32 except = 0); void RemoveMovementImpairingAuras(bool withRoot); void RemoveAurasByShapeShift(); @@ -2003,7 +2004,7 @@ public: void RemoveAllAurasExceptType(AuraType type); //void RemoveAllAurasExceptType(AuraType type1, AuraType type2); // pussywizard: replaced with RemoveEvadeAuras() void RemoveEvadeAuras(); - void DelayOwnedAuras(uint32 spellId, uint64 caster, int32 delaytime); + void DelayOwnedAuras(uint32 spellId, ObjectGuid caster, int32 delaytime); void _RemoveAllAuraStatMods(); void _ApplyAllAuraStatMods(); @@ -2012,37 +2013,37 @@ public: AuraList& GetSingleCastAuras() { return m_scAuras; } [[nodiscard]] AuraList const& GetSingleCastAuras() const { return m_scAuras; } - [[nodiscard]] AuraEffect* GetAuraEffect(uint32 spellId, uint8 effIndex, uint64 casterGUID = 0) const; - [[nodiscard]] AuraEffect* GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, uint64 casterGUID = 0) const; + [[nodiscard]] AuraEffect* GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID = ObjectGuid::Empty) const; + [[nodiscard]] AuraEffect* GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID = ObjectGuid::Empty) const; [[nodiscard]] AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const; // spell mustn't have familyflags - [[nodiscard]] AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID = 0) const; + [[nodiscard]] AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID = ObjectGuid::Empty) const; [[nodiscard]] AuraEffect* GetAuraEffectDummy(uint32 spellid) const; [[nodiscard]] inline AuraEffect* GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const { return GetAuraEffect(SPELL_AURA_DUMMY, name, iconId, effIndex);} - AuraApplication* GetAuraApplication(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const; - [[nodiscard]] Aura* GetAura(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0) const; + AuraApplication* GetAuraApplication(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const; + [[nodiscard]] Aura* GetAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const; - AuraApplication* GetAuraApplicationOfRankedSpell(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const; - [[nodiscard]] Aura* GetAuraOfRankedSpell(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0) const; + AuraApplication* GetAuraApplicationOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const; + [[nodiscard]] Aura* GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const; void GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList); - [[nodiscard]] bool HasAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster = 0) const; + [[nodiscard]] bool HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster = ObjectGuid::Empty) const; [[nodiscard]] uint32 GetAuraCount(uint32 spellId) const; - [[nodiscard]] bool HasAura(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0) const; + [[nodiscard]] bool HasAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const; [[nodiscard]] bool HasAuraType(AuraType auraType) const; - [[nodiscard]] bool HasAuraTypeWithCaster(AuraType auratype, uint64 caster) const; + [[nodiscard]] bool HasAuraTypeWithCaster(AuraType auratype, ObjectGuid caster) const; [[nodiscard]] bool HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const; bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const; [[nodiscard]] bool HasAuraTypeWithValue(AuraType auratype, int32 value) const; - bool HasNegativeAuraWithInterruptFlag(uint32 flag, uint64 guid = 0); + bool HasNegativeAuraWithInterruptFlag(uint32 flag, ObjectGuid guid = ObjectGuid::Empty); [[nodiscard]] bool HasVisibleAuraType(AuraType auraType) const; - bool HasNegativeAuraWithAttribute(uint32 flag, uint64 guid = 0); + bool HasNegativeAuraWithAttribute(uint32 flag, ObjectGuid guid = ObjectGuid::Empty); [[nodiscard]] bool HasAuraWithMechanic(uint32 mechanicMask) const; AuraEffect* IsScriptOverriden(SpellInfo const* spell, int32 script) const; - uint32 GetDiseasesByCaster(uint64 casterGUID, uint8 mode = 0); - [[nodiscard]] uint32 GetDoTsByCaster(uint64 casterGUID) const; + uint32 GetDiseasesByCaster(ObjectGuid casterGUID, uint8 mode = 0); + [[nodiscard]] uint32 GetDoTsByCaster(ObjectGuid casterGUID) const; [[nodiscard]] int32 GetTotalAuraModifierAreaExclusive(AuraType auratype) const; [[nodiscard]] int32 GetTotalAuraModifier(AuraType auratype) const; @@ -2109,8 +2110,8 @@ public: [[nodiscard]] Spell* FindCurrentSpellBySpellId(uint32 spell_id) const; [[nodiscard]] int32 GetCurrentSpellCastTime(uint32 spell_id) const; - uint64 m_SummonSlot[MAX_SUMMON_SLOT]; - uint64 m_ObjectSlot[MAX_GAMEOBJECT_SLOT]; + ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]; + ObjectGuid m_ObjectSlot[MAX_GAMEOBJECT_SLOT]; [[nodiscard]] ShapeshiftForm GetShapeshiftForm() const { return ShapeshiftForm(GetByteValue(UNIT_FIELD_BYTES_2, 3)); } void SetShapeshiftForm(ShapeshiftForm form) @@ -2327,14 +2328,14 @@ public: void DisableRotate(bool apply); void DisableSpline(); - void AddComboPointHolder(uint32 lowguid) { m_ComboPointHolders.insert(lowguid); } - void RemoveComboPointHolder(uint32 lowguid) { m_ComboPointHolders.erase(lowguid); } + void AddComboPointHolder(ObjectGuid lowguid) { m_ComboPointHolders.insert(lowguid); } + void RemoveComboPointHolder(ObjectGuid lowguid) { m_ComboPointHolders.erase(lowguid); } void ClearComboPointHolders(); ///----------Pet responses methods----------------- void SendPetActionFeedback (uint8 msg); void SendPetTalk (uint32 pettalk); - void SendPetAIReaction(uint64 guid); + void SendPetAIReaction(ObjectGuid guid); ///----------End of Pet responses methods---------- void propagateSpeedChange() { GetMotionMaster()->propagateSpeedChange(); } @@ -2372,8 +2373,8 @@ public: uint32 GetModelForTotem(PlayerTotemType totemType); // Redirect Threat - void SetRedirectThreat(uint64 guid, uint32 pct) { _redirectThreatInfo.Set(guid, pct); } - void ResetRedirectThreat() { SetRedirectThreat(0, 0); } + void SetRedirectThreat(ObjectGuid guid, uint32 pct) { _redirectThreatInfo.Set(guid, pct); } + void ResetRedirectThreat() { SetRedirectThreat(ObjectGuid::Empty, 0); } void ModifyRedirectThreat(int32 amount) { _redirectThreatInfo.ModifyThreatPct(amount); } uint32 GetRedirectThreatPercent() { return _redirectThreatInfo.GetThreatPct(); } [[nodiscard]] Unit* GetRedirectThreatTarget() const; @@ -2386,7 +2387,7 @@ public: bool IsOnVehicle(const Unit* vehicle) const { return m_vehicle && m_vehicle == vehicle->GetVehicleKit(); } [[nodiscard]] Unit* GetVehicleBase() const; [[nodiscard]] Creature* GetVehicleCreatureBase() const; - [[nodiscard]] uint64 GetTransGUID() const override; + [[nodiscard]] ObjectGuid GetTransGUID() const override; /// Returns the transport this unit is on directly (if on vehicle and transport, return vehicle) [[nodiscard]] TransportBase* GetDirectTransport() const; @@ -2480,8 +2481,8 @@ public: int32 CalculateAOEDamageReduction(int32 damage, uint32 schoolMask, Unit* caster) const; - [[nodiscard]] uint64 GetTarget() const { return GetUInt64Value(UNIT_FIELD_TARGET); } - virtual void SetTarget(uint64 /*guid*/) = 0; + [[nodiscard]] ObjectGuid GetTarget() const { return GetGuidValue(UNIT_FIELD_TARGET); } + virtual void SetTarget(ObjectGuid /*guid*/ = ObjectGuid::Empty) = 0; void SetInstantCast(bool set) { _instantCast = set; } [[nodiscard]] bool CanInstantCast() const { return _instantCast; } @@ -2524,7 +2525,7 @@ protected: typedef std::list<DynamicObject*> DynObjectList; DynObjectList m_dynObj; - typedef std::list<uint64> GameObjectList; + typedef GuidList GameObjectList; GameObjectList m_gameObj; uint32 m_transform; @@ -2560,7 +2561,7 @@ protected: int32 m_regenTimer; ThreatManager m_ThreatManager; - typedef std::map<uint64, float> CharmThreatMap; + typedef std::map<ObjectGuid, float> CharmThreatMap; CharmThreatMap _charmThreatInfo; Vehicle* m_vehicle; @@ -2680,23 +2681,23 @@ namespace acore class ConflagrateAuraStateDelayEvent : public BasicEvent { public: - ConflagrateAuraStateDelayEvent(uint64 ownerGUID, uint64 casterGUID) : BasicEvent(), m_owner(ownerGUID), m_caster(casterGUID) { } + ConflagrateAuraStateDelayEvent(Unit* owner, ObjectGuid casterGUID) : BasicEvent(), m_owner(owner), m_casterGUID(casterGUID) { } bool Execute(uint64 e_time, uint32 p_time) override; private: - uint64 m_owner; - uint64 m_caster; + Unit* m_owner; + ObjectGuid m_casterGUID; }; class RedirectSpellEvent : public BasicEvent { public: - RedirectSpellEvent(Unit& self, uint64 auraOwnerGUID, AuraEffect* auraEffect) : _self(self), _auraOwnerGUID(auraOwnerGUID), _auraEffect(auraEffect) { } + RedirectSpellEvent(Unit& self, ObjectGuid auraOwnerGUID, AuraEffect* auraEffect) : _self(self), _auraOwnerGUID(auraOwnerGUID), _auraEffect(auraEffect) { } bool Execute(uint64 e_time, uint32 p_time) override; protected: Unit& _self; - uint64 _auraOwnerGUID; + ObjectGuid _auraOwnerGUID; AuraEffect* _auraEffect; }; diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 86d35aedfb..33543d535f 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -50,7 +50,7 @@ Vehicle::~Vehicle() for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr) if (itr->second.Passenger.Guid) { - if (Unit* unit = ObjectAccessor::FindUnit(itr->second.Passenger.Guid)) + if (Unit* unit = ObjectAccessor::GetUnit(*_me, itr->second.Passenger.Guid)) { LOG_INFO("server", "ZOMG! ~Vehicle(), unit: %s, entry: %u, typeid: %u, this_entry: %u, this_typeid: %u!", unit->GetName().c_str(), unit->GetEntry(), unit->GetTypeId(), _me ? _me->GetEntry() : 0, _me ? _me->GetTypeId() : 0); unit->_ExitVehicle(); @@ -95,13 +95,13 @@ void Vehicle::Uninstall() /// @Prevent recursive uninstall call. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.) if (_status == STATUS_UNINSTALLING && !GetBase()->HasUnitTypeMask(UNIT_MASK_MINION)) { - LOG_ERROR("server", "Vehicle GuidLow: %u, Entry: %u attempts to uninstall, but already has STATUS_UNINSTALLING! " - "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry()); + LOG_ERROR("server", "Vehicle %s attempts to uninstall, but already has STATUS_UNINSTALLING! " + "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUID().ToString().c_str()); return; } _status = STATUS_UNINSTALLING; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("vehicles", "Vehicle::Uninstall Entry: %u, GuidLow: %u", _creatureEntry, _me->GetGUIDLow()); + LOG_DEBUG("vehicles", "Vehicle::Uninstall %s", _me->GetGUID().ToString().c_str()); #endif RemoveAllPassengers(); @@ -112,7 +112,7 @@ void Vehicle::Uninstall() void Vehicle::Reset(bool evading /*= false*/) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("vehicles", "Vehicle::Reset Entry: %u, GuidLow: %u", _creatureEntry, _me->GetGUIDLow()); + LOG_DEBUG("vehicles", "Vehicle::Reset: %s", _me->GetGUID().ToString().c_str()); #endif if (_me->GetTypeId() == TYPEID_PLAYER) { @@ -154,7 +154,7 @@ void Vehicle::ApplyAllImmunities() //_me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_UNATTACKABLE, true); _me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_SHIELD, true); _me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_IMMUNE_SHIELD, true); - if (_me->GetZoneId() == BATTLEFIELD_WG_ZONEID || _me->ToCreature()->GetDBTableGUIDLow() || (_me->FindMap() && _me->FindMap()->Instanceable())) + if (_me->GetZoneId() == BATTLEFIELD_WG_ZONEID || _me->ToCreature()->GetSpawnId() || (_me->FindMap() && _me->FindMap()->Instanceable())) _me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_SCHOOL_ABSORB, true); // ... Resistance, Split damage, Change stats ... @@ -198,7 +198,7 @@ void Vehicle::ApplyAllImmunities() void Vehicle::RemoveAllPassengers() { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("vehicles", "Vehicle::RemoveAllPassengers. Entry: %u, GuidLow: %u", _creatureEntry, _me->GetGUIDLow()); + LOG_DEBUG("vehicles", "Vehicle::RemoveAllPassengers. %s", _me->GetGUID().ToString().c_str()); #endif // Passengers always cast an aura with SPELL_AURA_CONTROL_VEHICLE on the vehicle @@ -263,8 +263,8 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ /// @Prevent adding accessories when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.) if (_status == STATUS_UNINSTALLING) { - LOG_ERROR("server", "Vehicle GuidLow: %u, Entry: %u attempts to install accessory Entry: %u on seat %d with STATUS_UNINSTALLING! " - "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry(), entry, (int32)seatId); + LOG_ERROR("server", "Vehicle %s attempts to install accessory Entry: %u on seat %d with STATUS_UNINSTALLING! " + "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUID().ToString().c_str(), entry, (int32)seatId); return; } @@ -310,7 +310,8 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId) if (_status == STATUS_UNINSTALLING) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("vehicles", "Passenger GuidLow: %u, Entry: %u, attempting to board vehicle GuidLow: %u, Entry: %u during uninstall! SeatId: %i", unit->GetGUIDLow(), unit->GetEntry(), _me->GetGUIDLow(), _me->GetEntry(), (int32)seatId); + LOG_DEBUG("vehicles", "Passenger %s, attempting to board vehicle %s during uninstall! SeatId: %i", + unit->GetGUID().ToString().c_str(), _me->GetGUID().ToString().c_str(), (int32)seatId); #endif return false; } @@ -339,14 +340,15 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId) if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger.Guid)) passenger->ExitVehicle(); - seat->second.Passenger.Guid = 0; + seat->second.Passenger.Guid.Clear(); } ASSERT(seat->second.IsEmpty()); } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("vehicles", "Unit %s enter vehicle entry %u id %u dbguid %u seat %d", unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first); + LOG_DEBUG("vehicles", "Unit %s enter vehicle entry %u id %u (%s) seat %d", + unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().ToString().c_str(), (int32)seat->first); #endif seat->second.Passenger.Guid = unit->GetGUID(); @@ -457,7 +459,8 @@ void Vehicle::RemovePassenger(Unit* unit) return; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("vehicles", "Unit %s exit vehicle entry %u id %u dbguid %u seat %d", unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first); + LOG_DEBUG("vehicles", "Unit %s exit vehicle entry %u id %u (%s) seat %d", + unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().ToString().c_str(), (int32)seat->first); #endif if (seat->second.SeatInfo->CanEnterOrExit() && ++_usableSeatNum) @@ -525,7 +528,7 @@ void Vehicle::Dismiss() return; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("vehicles", "Vehicle::Dismiss Entry: %u, GuidLow %u", _creatureEntry, _me->GetGUIDLow()); + LOG_DEBUG("vehicles", "Vehicle::Dismiss %s", _me->GetGUID().ToString().c_str()); #endif Uninstall(); GetBase()->ToCreature()->DespawnOrUnsummon(); diff --git a/src/server/game/Entities/Vehicle/VehicleDefines.h b/src/server/game/Entities/Vehicle/VehicleDefines.h index 5f0ef6842c..bd5acab2e7 100644 --- a/src/server/game/Entities/Vehicle/VehicleDefines.h +++ b/src/server/game/Entities/Vehicle/VehicleDefines.h @@ -54,12 +54,12 @@ enum VehicleNPCs struct PassengerInfo { - uint64 Guid; + ObjectGuid Guid; bool IsUnselectable; void Reset() { - Guid = 0; + Guid.Clear(); IsUnselectable = false; } }; diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index bbdc5a2643..ae8a97238c 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -396,7 +396,7 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); int16 event_id = fields[1].GetInt8(); int32 internal_event_id = mGameEvent.size() + event_id - 1; @@ -407,7 +407,7 @@ void GameEventMgr::LoadFromDB() continue; } - GuidList& crelist = mGameEventCreatureGuids[internal_event_id]; + GuidLowList& crelist = mGameEventCreatureGuids[internal_event_id]; crelist.push_back(guid); ++count; @@ -438,7 +438,7 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); int16 event_id = fields[1].GetInt8(); int32 internal_event_id = mGameEvent.size() + event_id - 1; @@ -449,7 +449,7 @@ void GameEventMgr::LoadFromDB() continue; } - GuidList& golist = mGameEventGameobjectGuids[internal_event_id]; + GuidLowList& golist = mGameEventGameobjectGuids[internal_event_id]; golist.push_back(guid); ++count; @@ -480,8 +480,8 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - uint32 entry = fields[1].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); + uint32 entry = fields[1].GetUInt32(); uint16 event_id = fields[2].GetUInt8(); if (event_id >= mGameEventModelEquip.size()) @@ -508,7 +508,7 @@ void GameEventMgr::LoadFromDB() } } - equiplist.push_back(std::pair<uint32, ModelEquip>(guid, newModelEquipSet)); + equiplist.push_back(std::pair<ObjectGuid::LowType, ModelEquip>(guid, newModelEquipSet)); ++count; } while (result->NextRow()); @@ -747,9 +747,9 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint16 event_id = fields[1].GetUInt8(); - uint32 npcflag = fields[2].GetUInt32(); + uint32 npcflag = fields[2].GetUInt32(); if (event_id >= mGameEvent.size()) { @@ -841,7 +841,7 @@ void GameEventMgr::LoadFromDB() NPCVendorList& vendors = mGameEventVendors[event_id]; NPCVendorEntry newEntry; - uint32 guid = fields[1].GetUInt32(); + ObjectGuid::LowType guid = fields[1].GetUInt32(); newEntry.item = fields[2].GetUInt32(); newEntry.maxcount = fields[3].GetUInt32(); newEntry.incrtime = fields[4].GetUInt32(); @@ -1015,14 +1015,12 @@ void GameEventMgr::LoadHolidayDates() uint32 GameEventMgr::GetNPCFlag(Creature* cr) { uint32 mask = 0; - uint32 guid = cr->GetDBTableGUIDLow(); + ObjectGuid::LowType spawnId = cr->GetSpawnId(); for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) { - for (NPCFlagList::iterator itr = mGameEventNPCFlags[*e_itr].begin(); - itr != mGameEventNPCFlags[*e_itr].end(); - ++ itr) - if (itr->first == guid) + for (NPCFlagList::iterator itr = mGameEventNPCFlags[*e_itr].begin(); itr != mGameEventNPCFlags[*e_itr].end(); ++ itr) + if (itr->first == spawnId) mask |= itr->second; } @@ -1222,25 +1220,36 @@ void GameEventMgr::ApplyNewEvent(uint16 event_id) void GameEventMgr::UpdateEventNPCFlags(uint16 event_id) { + std::unordered_map<uint32, std::unordered_set<ObjectGuid::LowType>> creaturesByMap; + // go through the creatures whose npcflags are changed in the event for (NPCFlagList::iterator itr = mGameEventNPCFlags[event_id].begin(); itr != mGameEventNPCFlags[event_id].end(); ++itr) { // get the creature data from the low guid to get the entry, to be able to find out the whole guid if (CreatureData const* data = sObjectMgr->GetCreatureData(itr->first)) + creaturesByMap[data->mapid].insert(itr->first); + } + + for (auto const& p : creaturesByMap) + { + sMapMgr->DoForAllMapsWithMapId(p.first, [this, &p](Map* map) { - Creature* cr = HashMapHolder<Creature>::Find(MAKE_NEW_GUID(itr->first, data->id, HIGHGUID_UNIT)); - // if we found the creature, modify its npcflag - if (cr) + for (auto& spawnId : p.second) { - uint32 npcflag = GetNPCFlag(cr); - if (const CreatureTemplate* ci = cr->GetCreatureTemplate()) - npcflag |= ci->npcflag; - cr->SetUInt32Value(UNIT_NPC_FLAGS, npcflag); - // reset gossip options, since the flag change might have added / removed some - //cr->ResetGossipOptions(); + auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(spawnId); + for (auto itr = creatureBounds.first; itr != creatureBounds.second; ++itr) + { + Creature* creature = itr->second; + uint32 npcflag = GetNPCFlag(creature); + if (CreatureTemplate const* creatureTemplate = creature->GetCreatureTemplate()) + npcflag |= creatureTemplate->npcflag; + + creature->SetUInt32Value(UNIT_NPC_FLAGS, npcflag); + // reset gossip options, since the flag change might have added / removed some + //cr->ResetGossipOptions(); + } } - // if we didn't find it, then the npcflag will be updated when the creature is loaded - } + }); } } @@ -1274,7 +1283,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) return; } - for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr) + for (GuidLowList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr) { // Add to correct cell if (CreatureData const* data = sObjectMgr->GetCreatureData(*itr)) @@ -1300,7 +1309,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) return; } - for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr) + for (GuidLowList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr) { // Add to correct cell if (GameObjectData const* data = sObjectMgr->GetGOData(*itr)) @@ -1347,18 +1356,27 @@ void GameEventMgr::GameEventUnspawn(int16 event_id) return; } - for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr) + for (GuidLowList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr) { // check if it's needed by another event, if so, don't remove if (event_id > 0 && hasCreatureActiveEventExcept(*itr, event_id)) continue; + // Remove the creature from grid if (CreatureData const* data = sObjectMgr->GetCreatureData(*itr)) { sObjectMgr->RemoveCreatureFromGrid(*itr, data); - if (Creature* creature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_UNIT), (Creature*)nullptr)) - creature->AddObjectToRemoveList(); + sMapMgr->DoForAllMapsWithMapId(data->mapid, [&itr](Map* map) + { + auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(*itr); + for (auto itr2 = creatureBounds.first; itr2 != creatureBounds.second;) + { + Creature* creature = itr2->second; + ++itr2; + creature->AddObjectToRemoveList(); + } + }); } } @@ -1369,7 +1387,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id) return; } - for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr) + for (GuidLowList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr) { // check if it's needed by another event, if so, don't remove if (event_id > 0 && hasGameObjectActiveEventExcept(*itr, event_id)) @@ -1379,8 +1397,16 @@ void GameEventMgr::GameEventUnspawn(int16 event_id) { sObjectMgr->RemoveGameobjectFromGrid(*itr, data); - if (GameObject* pGameobject = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)nullptr)) - pGameobject->AddObjectToRemoveList(); + sMapMgr->DoForAllMapsWithMapId(data->mapid, [&itr](Map* map) + { + auto gameobjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(*itr); + for (auto itr2 = gameobjectBounds.first; itr2 != gameobjectBounds.second;) + { + GameObject* go = itr2->second; + ++itr2; + go->AddObjectToRemoveList(); + } + }); } } if (internal_event_id >= int32(mGameEventPoolIds.size())) @@ -1405,53 +1431,42 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate) continue; // Update if spawned - Creature* creature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(itr->first, data->id, HIGHGUID_UNIT), (Creature*)nullptr); - if (creature) + sMapMgr->DoForAllMapsWithMapId(data->mapid, [&itr, activate](Map* map) { - if (activate) + auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(itr->first); + for (auto itr2 = creatureBounds.first; itr2 != creatureBounds.second; ++itr2) { - itr->second.equipement_id_prev = creature->GetCurrentEquipmentId(); - itr->second.modelid_prev = creature->GetDisplayId(); - creature->LoadEquipment(itr->second.equipment_id, true); - if (itr->second.modelid > 0 && itr->second.modelid_prev != itr->second.modelid && - sObjectMgr->GetCreatureModelInfo(itr->second.modelid)) + Creature* creature = itr2->second; + if (activate) { - creature->SetDisplayId(itr->second.modelid); - creature->SetNativeDisplayId(itr->second.modelid); + itr->second.equipement_id_prev = creature->GetCurrentEquipmentId(); + itr->second.modelid_prev = creature->GetDisplayId(); + creature->LoadEquipment(itr->second.equipment_id, true); + if (itr->second.modelid > 0 && itr->second.modelid_prev != itr->second.modelid && sObjectMgr->GetCreatureModelInfo(itr->second.modelid)) + { + creature->SetDisplayId(itr->second.modelid); + creature->SetNativeDisplayId(itr->second.modelid); + } } - } - else - { - creature->LoadEquipment(itr->second.equipement_id_prev, true); - if (itr->second.modelid_prev > 0 && itr->second.modelid_prev != itr->second.modelid && - sObjectMgr->GetCreatureModelInfo(itr->second.modelid_prev)) + else { - creature->SetDisplayId(itr->second.modelid_prev); - creature->SetNativeDisplayId(itr->second.modelid_prev); + creature->LoadEquipment(itr->second.equipement_id_prev, true); + if (itr->second.modelid_prev > 0 && itr->second.modelid_prev != itr->second.modelid && sObjectMgr->GetCreatureModelInfo(itr->second.modelid_prev)) + { + creature->SetDisplayId(itr->second.modelid_prev); + creature->SetNativeDisplayId(itr->second.modelid_prev); + } } } - } - else // If not spawned - { - CreatureData const* data2 = sObjectMgr->GetCreatureData(itr->first); - if (data2 && activate) - { - CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(data2->id); - uint32 displayID = ObjectMgr::ChooseDisplayId(cinfo, data2); - sObjectMgr->GetCreatureModelRandomGender(&displayID); - - if (data2->equipmentId == 0) - itr->second.equipement_id_prev = 0; - else if (data2->equipmentId != -1) - itr->second.equipement_id_prev = data->equipmentId; - itr->second.modelid_prev = displayID; - } - } + }); + // now last step: put in data // just to have write access to it CreatureData& data2 = sObjectMgr->NewOrExistCreatureData(itr->first); if (activate) { + itr->second.modelid_prev = data2.displayid; + itr->second.equipement_id_prev = data2.equipmentId; data2.displayid = itr->second.modelid; data2.equipmentId = itr->second.equipment_id; } @@ -1490,33 +1505,29 @@ bool GameEventMgr::hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 e } return false; } -bool GameEventMgr::hasCreatureActiveEventExcept(uint32 creature_id, uint16 event_id) +bool GameEventMgr::hasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 event_id) { for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) { if ((*e_itr) != event_id) { int32 internal_event_id = mGameEvent.size() + (*e_itr) - 1; - for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); - itr != mGameEventCreatureGuids[internal_event_id].end(); - ++ itr) - if (*itr == creature_id) + for (GuidLowList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++ itr) + if (*itr == creature_guid) return true; } } return false; } -bool GameEventMgr::hasGameObjectActiveEventExcept(uint32 go_id, uint16 event_id) +bool GameEventMgr::hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 event_id) { for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) { if ((*e_itr) != event_id) { int32 internal_event_id = mGameEvent.size() + (*e_itr) - 1; - for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); - itr != mGameEventGameobjectGuids[internal_event_id].end(); - ++ itr) - if (*itr == go_id) + for (GuidLowList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++ itr) + if (*itr == go_guid) return true; } } @@ -1701,24 +1712,43 @@ void GameEventMgr::SendWorldStateUpdate(Player* player, uint16 event_id) } } -void GameEventMgr::RunSmartAIScripts(uint16 event_id, bool activate) +class GameEventAIHookWorker { - //! Iterate over every supported source type (creature and gameobject) - //! Not entirely sure how this will affect units in non-loaded grids. +public: + GameEventAIHookWorker(uint16 eventId, bool activate) : _eventId(eventId), _activate(activate) { } + + void Visit(std::unordered_map<ObjectGuid, Creature*>& creatureMap) { - std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Creature>::GetLock()); - HashMapHolder<Creature>::MapType const& m = ObjectAccessor::GetCreatures(); - for (HashMapHolder<Creature>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter) - if (iter->second->IsInWorld() && !iter->second->IsDuringRemoveFromWorld() && iter->second->FindMap() && iter->second->IsAIEnabled && iter->second->AI()) - iter->second->AI()->sOnGameEvent(activate, event_id); + for (auto const& p : creatureMap) + if (p.second->IsInWorld() && !p.second->IsDuringRemoveFromWorld() && p.second->FindMap() && p.second->IsAIEnabled && p.second->AI()) + p.second->AI()->sOnGameEvent(_activate, _eventId); } + + void Visit(std::unordered_map<ObjectGuid, GameObject*>& gameObjectMap) { - std::shared_lock<std::shared_mutex> lock(*HashMapHolder<GameObject>::GetLock()); - HashMapHolder<GameObject>::MapType const& m = ObjectAccessor::GetGameObjects(); - for (HashMapHolder<GameObject>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter) - if (iter->second->IsInWorld() && iter->second->FindMap() && iter->second->AI()) - iter->second->AI()->OnGameEvent(activate, event_id); + for (auto const& p : gameObjectMap) + if (p.second->IsInWorld() && p.second->FindMap() && p.second->AI()) + p.second->AI()->OnGameEvent(_activate, _eventId); } + + template<class T> + void Visit(std::unordered_map<ObjectGuid, T*>&) { } + +private: + uint16 _eventId; + bool _activate; +}; + +void GameEventMgr::RunSmartAIScripts(uint16 event_id, bool activate) +{ + //! Iterate over every supported source type (creature and gameobject) + //! Not entirely sure how this will affect units in non-loaded grids. + sMapMgr->DoForAllMaps([event_id, activate](Map* map) + { + GameEventAIHookWorker worker(event_id, activate); + TypeContainerVisitor<GameEventAIHookWorker, MapStoredObjectTypesContainer> visitor(worker); + visitor.Visit(map->GetObjectsStore()); + }); } void GameEventMgr::SetHolidayEventTime(GameEventData& event) diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h index 1968530384..781f7b1bda 100644 --- a/src/server/game/Events/GameEventMgr.h +++ b/src/server/game/Events/GameEventMgr.h @@ -8,6 +8,7 @@ #define ACORE_GAMEEVENT_MGR_H #include "Common.h" +#include "ObjectGuid.h" #include "SharedDefines.h" #define max_ge_check_delay DAY // 1 day in seconds @@ -125,15 +126,15 @@ private: void SaveWorldEventStateToDB(uint16 event_id); bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id); bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id); - bool hasCreatureActiveEventExcept(uint32 creature_guid, uint16 event_id); - bool hasGameObjectActiveEventExcept(uint32 go_guid, uint16 event_id); + bool hasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 event_id); + bool hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 event_id); void SetHolidayEventTime(GameEventData& event); - typedef std::list<uint32> GuidList; + typedef std::list<ObjectGuid::LowType> GuidLowList; typedef std::list<uint32> IdList; - typedef std::vector<GuidList> GameEventGuidMap; + typedef std::vector<GuidLowList> GameEventGuidMap; typedef std::vector<IdList> GameEventIdMap; - typedef std::pair<uint32, ModelEquip> ModelEquipPair; + typedef std::pair<ObjectGuid::LowType, ModelEquip> ModelEquipPair; typedef std::list<ModelEquipPair> ModelEquipList; typedef std::vector<ModelEquipList> GameEventModelEquipMap; typedef std::pair<uint32, uint32> QuestRelation; @@ -142,7 +143,7 @@ private: typedef std::list<NPCVendorEntry> NPCVendorList; typedef std::vector<NPCVendorList> GameEventNPCVendorMap; typedef std::map<uint32 /*quest id*/, GameEventQuestToEventConditionNum> QuestIdToEventConditionMap; - typedef std::pair<uint32 /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair; + typedef std::pair<ObjectGuid::LowType /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair; typedef std::list<GuidNPCFlagPair> NPCFlagList; typedef std::vector<NPCFlagList> GameEventNPCFlagMap; typedef std::vector<uint32> GameEventBitmask; diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index 1e5f7fb518..1e02d47bf6 100644 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -22,31 +22,45 @@ #include "Opcodes.h" #include "Pet.h" #include "Player.h" +#include "Transport.h" #include "Vehicle.h" #include "World.h" #include "WorldPacket.h" #include <cmath> - template<class T> void HashMapHolder<T>::Insert(T* o) { + static_assert(std::is_same<Player, T>::value + || std::is_same<MotionTransport, T>::value, + "Only Player and Motion Transport can be registered in global HashMapHolder"); + std::unique_lock<std::shared_mutex> lock(*GetLock()); - m_objectMap[o->GetGUID()] = o; + + GetContainer()[o->GetGUID()] = o; } template<class T> void HashMapHolder<T>::Remove(T* o) { std::unique_lock<std::shared_mutex> lock(*GetLock()); - m_objectMap.erase(o->GetGUID()); + + GetContainer().erase(o->GetGUID()); } template<class T> -T* HashMapHolder<T>::Find(uint64 guid) +T* HashMapHolder<T>::Find(ObjectGuid guid) { std::shared_lock<std::shared_mutex> lock(*GetLock()); - typename MapType::iterator itr = m_objectMap.find(guid); - return (itr != m_objectMap.end()) ? itr->second : nullptr; + + typename MapType::iterator itr = GetContainer().find(guid); + return (itr != GetContainer().end()) ? itr->second : nullptr; +} + +template<class T> +auto HashMapHolder<T>::GetContainer() -> MapType& +{ + static MapType _objectMap; + return _objectMap; } template<class T> @@ -56,179 +70,186 @@ std::shared_mutex* HashMapHolder<T>::GetLock() return &_lock; } -ObjectAccessor::ObjectAccessor() +HashMapHolder<Player>::MapType const& ObjectAccessor::GetPlayers() { + return HashMapHolder<Player>::GetContainer(); } -ObjectAccessor::~ObjectAccessor() -{ -} +template class HashMapHolder<Player>; +template class HashMapHolder<MotionTransport>; -ObjectAccessor* ObjectAccessor::instance() +namespace PlayerNameMapHolder { - static ObjectAccessor instance; - return &instance; -} + typedef std::unordered_map<std::string, Player*> MapType; + static MapType PlayerNameMap; -Player* ObjectAccessor::GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/) -{ - Player* player = HashMapHolder<Player>::Find(guid); - return player && player->IsInWorld() ? player : nullptr; -} + void Insert(Player* p) + { + PlayerNameMap[p->GetName()] = p; + } -WorldObject* ObjectAccessor::GetWorldObject(WorldObject const& p, uint64 guid) + void Remove(Player* p) + { + PlayerNameMap.erase(p->GetName()); + } + + Player* Find(std::string const& name) + { + std::string charName(name); + if (!normalizePlayerName(charName)) + return nullptr; + + auto itr = PlayerNameMap.find(charName); + return (itr != PlayerNameMap.end()) ? itr->second : nullptr; + } + +} // namespace PlayerNameMapHolder + +WorldObject* ObjectAccessor::GetWorldObject(WorldObject const& p, ObjectGuid const guid) { - switch (GUID_HIPART(guid)) + switch (guid.GetHigh()) { - case HIGHGUID_PLAYER: + case HighGuid::Player: return GetPlayer(p, guid); - case HIGHGUID_TRANSPORT: - case HIGHGUID_MO_TRANSPORT: - case HIGHGUID_GAMEOBJECT: + case HighGuid::Transport: + case HighGuid::Mo_Transport: + case HighGuid::GameObject: return GetGameObject(p, guid); - case HIGHGUID_VEHICLE: - case HIGHGUID_UNIT: + case HighGuid::Vehicle: + case HighGuid::Unit: return GetCreature(p, guid); - case HIGHGUID_PET: + case HighGuid::Pet: return GetPet(p, guid); - case HIGHGUID_DYNAMICOBJECT: + case HighGuid::DynamicObject: return GetDynamicObject(p, guid); - case HIGHGUID_CORPSE: + case HighGuid::Corpse: return GetCorpse(p, guid); default: return nullptr; } + + return nullptr; } -Object* ObjectAccessor::GetObjectByTypeMask(WorldObject const& p, uint64 guid, uint32 typemask) +Object* ObjectAccessor::GetObjectByTypeMask(WorldObject const& p, ObjectGuid const guid, uint32 typemask) { - switch (GUID_HIPART(guid)) + switch (guid.GetHigh()) { - case HIGHGUID_ITEM: + case HighGuid::Item: if (typemask & TYPEMASK_ITEM && p.GetTypeId() == TYPEID_PLAYER) return ((Player const&)p).GetItemByGuid(guid); break; - case HIGHGUID_PLAYER: + case HighGuid::Player: if (typemask & TYPEMASK_PLAYER) return GetPlayer(p, guid); break; - case HIGHGUID_TRANSPORT: - case HIGHGUID_MO_TRANSPORT: - case HIGHGUID_GAMEOBJECT: + case HighGuid::Transport: + case HighGuid::Mo_Transport: + case HighGuid::GameObject: if (typemask & TYPEMASK_GAMEOBJECT) return GetGameObject(p, guid); break; - case HIGHGUID_UNIT: - case HIGHGUID_VEHICLE: + case HighGuid::Unit: + case HighGuid::Vehicle: if (typemask & TYPEMASK_UNIT) return GetCreature(p, guid); break; - case HIGHGUID_PET: + case HighGuid::Pet: if (typemask & TYPEMASK_UNIT) return GetPet(p, guid); break; - case HIGHGUID_DYNAMICOBJECT: + case HighGuid::DynamicObject: if (typemask & TYPEMASK_DYNAMICOBJECT) return GetDynamicObject(p, guid); break; - case HIGHGUID_CORPSE: - break; + default: + return nullptr; } return nullptr; } -Corpse* ObjectAccessor::GetCorpse(WorldObject const& u, uint64 guid) +Corpse* ObjectAccessor::GetCorpse(WorldObject const& u, ObjectGuid const guid) { - return GetObjectInMap(guid, u.GetMap(), (Corpse*)nullptr); + return u.GetMap()->GetCorpse(guid); } -GameObject* ObjectAccessor::GetGameObject(WorldObject const& u, uint64 guid) +GameObject* ObjectAccessor::GetGameObject(WorldObject const& u, ObjectGuid const guid) { - return GetObjectInMap(guid, u.GetMap(), (GameObject*)nullptr); + return u.GetMap()->GetGameObject(guid); } -Transport* ObjectAccessor::GetTransport(WorldObject const& u, uint64 guid) +Transport* ObjectAccessor::GetTransport(WorldObject const& u, ObjectGuid const guid) { - if (GUID_HIPART(guid) != HIGHGUID_MO_TRANSPORT && GUID_HIPART(guid) != HIGHGUID_TRANSPORT) - return nullptr; - - GameObject* go = GetGameObject(u, guid); - return go ? go->ToTransport() : nullptr; + return u.GetMap()->GetTransport(guid); } -DynamicObject* ObjectAccessor::GetDynamicObject(WorldObject const& u, uint64 guid) +DynamicObject* ObjectAccessor::GetDynamicObject(WorldObject const& u, ObjectGuid const guid) { - return GetObjectInMap(guid, u.GetMap(), (DynamicObject*)nullptr); + return u.GetMap()->GetDynamicObject(guid); } -Unit* ObjectAccessor::GetUnit(WorldObject const& u, uint64 guid) +Unit* ObjectAccessor::GetUnit(WorldObject const& u, ObjectGuid const guid) { - return GetObjectInMap(guid, u.GetMap(), (Unit*)nullptr); -} + if (guid.IsPlayer()) + return GetPlayer(u, guid); -Creature* ObjectAccessor::GetCreature(WorldObject const& u, uint64 guid) -{ - return GetObjectInMap(guid, u.GetMap(), (Creature*)nullptr); + if (guid.IsPet()) + return GetPet(u, guid); + + return GetCreature(u, guid); } -Pet* ObjectAccessor::GetPet(WorldObject const& u, uint64 guid) +Creature* ObjectAccessor::GetCreature(WorldObject const& u, ObjectGuid const guid) { - return GetObjectInMap(guid, u.GetMap(), (Pet*)nullptr); + return u.GetMap()->GetCreature(guid); } -Player* ObjectAccessor::GetPlayer(WorldObject const& u, uint64 guid) +Pet* ObjectAccessor::GetPet(WorldObject const& u, ObjectGuid const guid) { - return GetObjectInMap(guid, u.GetMap(), (Player*)nullptr); + return u.GetMap()->GetPet(guid); } -Creature* ObjectAccessor::GetCreatureOrPetOrVehicle(WorldObject const& u, uint64 guid) +Player* ObjectAccessor::GetPlayer(Map const* m, ObjectGuid const guid) { - if (IS_PET_GUID(guid)) - return GetPet(u, guid); - - if (IS_CRE_OR_VEH_GUID(guid)) - return GetCreature(u, guid); + if (Player * player = HashMapHolder<Player>::Find(guid)) + if (player->IsInWorld() && player->GetMap() == m) + return player; return nullptr; } -Pet* ObjectAccessor::FindPet(uint64 guid) +Player* ObjectAccessor::GetPlayer(WorldObject const& u, ObjectGuid const guid) { - return GetObjectInWorld(guid, (Pet*)nullptr); + return GetPlayer(u.GetMap(), guid); } -Player* ObjectAccessor::FindPlayer(uint64 guid) +Creature* ObjectAccessor::GetCreatureOrPetOrVehicle(WorldObject const& u, ObjectGuid const guid) { - return GetObjectInWorld(guid, (Player*)nullptr); -} + if (guid.IsPet()) + return GetPet(u, guid); -Player* ObjectAccessor::FindPlayerInOrOutOfWorld(uint64 guid) -{ - return GetObjectInOrOutOfWorld(guid, (Player*)nullptr); + if (guid.IsCreatureOrVehicle()) + return GetCreature(u, guid); + + return nullptr; } -Unit* ObjectAccessor::FindUnit(uint64 guid) +Player* ObjectAccessor::FindPlayer(ObjectGuid const guid) { - return GetObjectInWorld(guid, (Unit*)nullptr); + Player* player = HashMapHolder<Player>::Find(guid); + return player && player->IsInWorld() ? player : nullptr; } -Player* ObjectAccessor::FindConnectedPlayer(uint64 const& guid) +Player* ObjectAccessor::FindPlayerByLowGUID(ObjectGuid::LowType lowguid) { - return HashMapHolder<Player>::Find(guid); + ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(lowguid); + return ObjectAccessor::FindPlayer(guid); } -Player* ObjectAccessor::FindPlayerByName(std::string const& name, bool checkInWorld) +Player* ObjectAccessor::FindConnectedPlayer(ObjectGuid const guid) { - // pussywizard: optimization - std::string nameStr = name; - std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower); - std::map<std::string, Player*>::iterator itr = playerNameToPlayerPointer.find(nameStr); - if (itr != playerNameToPlayerPointer.end()) - if (!checkInWorld || itr->second->IsInWorld()) - return itr->second; - - return nullptr; + return HashMapHolder<Player>::Find(guid); } void ObjectAccessor::SaveAllPlayers() @@ -240,354 +261,25 @@ void ObjectAccessor::SaveAllPlayers() itr->second->SaveToDB(false, false); } -Corpse* ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid) -{ - std::shared_lock<std::shared_mutex> lock(i_corpseLock); - - Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid); - if (iter == i_player2corpse.end()) - return nullptr; - - ASSERT(iter->second->GetType() != CORPSE_BONES); - - return iter->second; -} - -void ObjectAccessor::RemoveCorpse(Corpse* corpse, bool final) -{ - ASSERT(corpse && corpse->GetType() != CORPSE_BONES); - - if (!final) - { - std::unique_lock<std::shared_mutex> guard(i_corpseLock); - Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGUID()); - if (iter == i_player2corpse.end()) - return; - i_player2corpse.erase(iter); - AddDelayedCorpseAction(corpse, 0); - return; - } - - //TODO: more works need to be done for corpse and other world object - if (Map* map = corpse->FindMap()) - { - // xinef: ok, should be called in both cases - corpse->DestroyForNearbyPlayers(); - if (corpse->IsInGrid()) - map->RemoveFromMap(corpse, false); - else - { - corpse->RemoveFromWorld(); - corpse->ResetMap(); - } - } - else - corpse->RemoveFromWorld(); - - // Critical section - { - std::unique_lock<std::shared_mutex> guard(i_corpseLock); - - // build mapid*cellid -> guid_set map - CellCoord cellCoord = acore::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY()); - sObjectMgr->DeleteCorpseCellData(corpse->GetMapId(), cellCoord.GetId(), GUID_LOPART(corpse->GetOwnerGUID())); - } - - delete corpse; // pussywizard: as it is delayed now, delete is moved here (previously in ConvertCorpseForPlayer) -} - -void ObjectAccessor::AddCorpse(Corpse* corpse) -{ - ASSERT(corpse && corpse->GetType() != CORPSE_BONES); - - // Critical section - { - std::unique_lock<std::shared_mutex> guard(i_corpseLock); - - ASSERT(i_player2corpse.find(corpse->GetOwnerGUID()) == i_player2corpse.end()); - i_player2corpse[corpse->GetOwnerGUID()] = corpse; - - // build mapid*cellid -> guid_set map - CellCoord cellCoord = acore::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY()); - sObjectMgr->AddCorpseCellData(corpse->GetMapId(), cellCoord.GetId(), GUID_LOPART(corpse->GetOwnerGUID()), corpse->GetInstanceId()); - } -} - -void ObjectAccessor::AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, Map* map) -{ - std::shared_lock<std::shared_mutex> guard(i_corpseLock); - - for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter) - { - // We need this check otherwise a corpose may be added to a grid twice - if (iter->second->IsInGrid()) - continue; - - if (iter->second->GetGridCoord() == gridpair) - { - // verify, if the corpse in our instance (add only corpses which are) - if (map->Instanceable()) - { - if (iter->second->GetInstanceId() == map->GetInstanceId()) - grid.AddWorldObject(iter->second); - } - else - grid.AddWorldObject(iter->second); - } - } -} - -Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia /*=false*/) -{ - Corpse* corpse = GetCorpseForPlayerGUID(player_guid); - if (!corpse) - { - //in fact this function is called from several places - //even when player doesn't have a corpse, not an error - return nullptr; - } - -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Deleting Corpse and spawned bones."); -#endif - - // Map can be nullptr - Map* map = corpse->FindMap(); - bool inWorld = corpse->IsInWorld(); - - // remove corpse from player_guid -> corpse map and from current map - RemoveCorpse(corpse); - - // remove corpse from DB - SQLTransaction trans = CharacterDatabase.BeginTransaction(); - corpse->DeleteFromDB(trans); - CharacterDatabase.CommitTransaction(trans); - - Corpse* bones = nullptr; - // create the bones only if the map and the grid is loaded at the corpse's location - // ignore bones creating option in case insignia - - if (map && corpse->IsPositionValid() && inWorld && (insignia || - (map->IsBattlegroundOrArena() ? sWorld->getBoolConfig(CONFIG_DEATH_BONES_BG_OR_ARENA) : sWorld->getBoolConfig(CONFIG_DEATH_BONES_WORLD))) && - !map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY())) - { - // Create bones, don't change Corpse - bones = new Corpse; - bones->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_CORPSE), map); - - for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type - bones->SetUInt32Value(i, corpse->GetUInt32Value(i)); - - bones->SetGridCoord(corpse->GetGridCoord()); - // bones->m_time = m_time; // don't overwrite time - // bones->m_type = m_type; // don't overwrite type - bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation()); - bones->SetPhaseMask(corpse->GetPhaseMask(), false); - - bones->SetUInt32Value(CORPSE_FIELD_FLAGS, CORPSE_FLAG_UNK2 | CORPSE_FLAG_BONES); - bones->SetUInt64Value(CORPSE_FIELD_OWNER, 0); - - for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i) - { - if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i)) - bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0); - } - - // add bones in grid store if grid loaded where corpse placed - if (insignia) // pussywizard: in case of insignia we need bones right now, map is the same so not a problem - map->AddToMap(bones); - else - { - bones->ResetMap(); - sObjectAccessor->AddDelayedCorpseAction(bones, 1, map->GetId(), map->GetInstanceId()); - } - - // pussywizard: for deleting bones - std::unique_lock<std::shared_mutex> guard(i_corpseLock); - i_playerBones.push_back(bones->GetGUID()); - } - - // all references to the corpse should be removed at this point - //delete corpse; // pussywizard: deleting corpse is delayed (crashfix) - - return bones; -} - -void ObjectAccessor::RemoveOldCorpses() -{ - time_t now = time(nullptr); - Player2CorpsesMapType::iterator next; - for (Player2CorpsesMapType::iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); itr = next) - { - next = itr; - ++next; - - if (!itr->second->IsExpired(now)) - continue; - - ConvertCorpseForPlayer(itr->first); - } - - // pussywizard: for deleting bones - std::list<uint64>::iterator next2; - std::unique_lock<std::shared_mutex> guard(i_corpseLock); - for (std::list<uint64>::iterator itr = i_playerBones.begin(); itr != i_playerBones.end(); itr = next2) - { - next2 = itr; - ++next2; - - Corpse* c = GetObjectInWorld((*itr), (Corpse*)nullptr); - if (c) - { - if (!c->IsExpired(now)) - continue; - - if (Map* map = c->FindMap()) - { - if (c->IsInGrid()) - map->RemoveFromMap(c, false); - else - { - c->DestroyForNearbyPlayers(); - c->RemoveFromWorld(); - c->ResetMap(); - } - } - else - c->RemoveFromWorld(); - } - - i_playerBones.erase(itr); - } -} - -void ObjectAccessor::AddDelayedCorpseAction(Corpse* corpse, uint8 action, uint32 mapId, uint32 instanceId) -{ - std::lock_guard<std::mutex> guard(DelayedCorpseLock); - i_delayedCorpseActions.push_back(DelayedCorpseAction(corpse, action, mapId, instanceId)); -} - -void ObjectAccessor::ProcessDelayedCorpseActions() -{ - std::lock_guard<std::mutex> guard(DelayedCorpseLock); - for (std::list<DelayedCorpseAction>::iterator itr = i_delayedCorpseActions.begin(); itr != i_delayedCorpseActions.end(); ++itr) - { - DelayedCorpseAction a = (*itr); - switch (a._action) - { - case 0: // remove corpse - RemoveCorpse(a._corpse, true); - break; - case 1: // add bones - if (Map* map = sMapMgr->FindMap(a._mapId, a._instanceId)) - if (!map->IsRemovalGrid(a._corpse->GetPositionX(), a._corpse->GetPositionY())) - { - a._corpse->SetMap(map); - map->AddToMap(a._corpse); - } - break; - } - } - i_delayedCorpseActions.clear(); -} - -void ObjectAccessor::Update(uint32 /*diff*/) -{ - UpdateDataMapType update_players; - UpdatePlayerSet player_set; - - while (!i_objects.empty()) - { - Object* obj = *i_objects.begin(); - ASSERT(obj && obj->IsInWorld()); - i_objects.erase(i_objects.begin()); - obj->BuildUpdate(update_players, player_set); - } - - WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 - for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) - { - iter->second.BuildPacket(&packet); - iter->first->GetSession()->SendPacket(&packet); - packet.clear(); // clean the string - } -} - -void Map::BuildAndSendUpdateForObjects() +Player* ObjectAccessor::FindPlayerByName(std::string const& name, bool checkInWorld) { - UpdateDataMapType update_players; - UpdatePlayerSet player_set; + if (Player* player = PlayerNameMapHolder::Find(name)) + if (!checkInWorld || player->IsInWorld()) + return player; - while (!i_objectsToUpdate.empty()) - { - Object* obj = *i_objectsToUpdate.begin(); - ASSERT(obj && obj->IsInWorld()); - i_objectsToUpdate.erase(i_objectsToUpdate.begin()); - obj->BuildUpdate(update_players, player_set); - } - - WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 - for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) - { - iter->second.BuildPacket(&packet); - iter->first->GetSession()->SendPacket(&packet); - packet.clear(); // clean the string - } + return nullptr; } -void ObjectAccessor::UnloadAll() +template<> +void ObjectAccessor::AddObject(Player* player) { - for (Player2CorpsesMapType::const_iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); ++itr) - { - itr->second->RemoveFromWorld(); - delete itr->second; - } + HashMapHolder<Player>::Insert(player); + PlayerNameMapHolder::Insert(player); } -template<class T> -/*static*/ T* ObjectAccessor::GetObjectInWorld(uint32 mapid, float x, float y, uint64 guid, T* /*fake*/) +template<> +void ObjectAccessor::RemoveObject(Player* player) { - T* obj = HashMapHolder<T>::Find(guid); - if (!obj || obj->GetMapId() != mapid) - return nullptr; - - CellCoord p = acore::ComputeCellCoord(x, y); - if (!p.IsCoordValid()) - { - LOG_ERROR("server", "ObjectAccessor::GetObjectInWorld: invalid coordinates supplied X:%f Y:%f grid cell [%u:%u]", x, y, p.x_coord, p.y_coord); - return nullptr; - } - - CellCoord q = acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); - if (!q.IsCoordValid()) - { - LOG_ERROR("server", "ObjectAccessor::GetObjecInWorld: object (GUID: %u TypeId: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), q.x_coord, q.y_coord); - return nullptr; - } - - int32 dx = int32(p.x_coord) - int32(q.x_coord); - int32 dy = int32(p.y_coord) - int32(q.y_coord); - - if (dx > -2 && dx < 2 && dy > -2 && dy < 2) - return obj; - - return nullptr; + HashMapHolder<Player>::Remove(player); + PlayerNameMapHolder::Remove(player); } - -std::map<std::string, Player*> ObjectAccessor::playerNameToPlayerPointer; - -/// Global definitions for the hashmap storage - -template class HashMapHolder<Player>; -template class HashMapHolder<Pet>; -template class HashMapHolder<GameObject>; -template class HashMapHolder<DynamicObject>; -template class HashMapHolder<Creature>; -template class HashMapHolder<Corpse>; - -template Player* ObjectAccessor::GetObjectInWorld<Player>(uint32 mapid, float x, float y, uint64 guid, Player* /*fake*/); -template Pet* ObjectAccessor::GetObjectInWorld<Pet>(uint32 mapid, float x, float y, uint64 guid, Pet* /*fake*/); -template Creature* ObjectAccessor::GetObjectInWorld<Creature>(uint32 mapid, float x, float y, uint64 guid, Creature* /*fake*/); -template Corpse* ObjectAccessor::GetObjectInWorld<Corpse>(uint32 mapid, float x, float y, uint64 guid, Corpse* /*fake*/); -template GameObject* ObjectAccessor::GetObjectInWorld<GameObject>(uint32 mapid, float x, float y, uint64 guid, GameObject* /*fake*/); -template DynamicObject* ObjectAccessor::GetObjectInWorld<DynamicObject>(uint32 mapid, float x, float y, uint64 guid, DynamicObject* /*fake*/); diff --git a/src/server/game/Globals/ObjectAccessor.h b/src/server/game/Globals/ObjectAccessor.h index ca66739165..1801dc116d 100644 --- a/src/server/game/Globals/ObjectAccessor.h +++ b/src/server/game/Globals/ObjectAccessor.h @@ -32,206 +32,69 @@ class MotionTransport; template <class T> class HashMapHolder { -public: - typedef std::unordered_map<uint64, T*> MapType; - - static void Insert(T* o); - static void Remove(T* o); - static T* Find(uint64 guid); - - static MapType& GetContainer() { return m_objectMap; } - static std::shared_mutex* GetLock(); - -private: //Non instanceable only static - HashMapHolder() = default; + HashMapHolder() { } - static MapType m_objectMap; -}; - -/// Define the static members of HashMapHolder - -template <class T> std::unordered_map< uint64, T* > HashMapHolder<T>::m_objectMap; - -// pussywizard: -class DelayedCorpseAction -{ public: - DelayedCorpseAction(Corpse* corpse, uint8 action, uint32 mapId, uint32 instanceId) : _corpse(corpse), _action(action), _mapId(mapId), _instanceId(instanceId) {} - Corpse* _corpse; - uint8 _action; - uint32 _mapId; - uint32 _instanceId; -}; -class ObjectAccessor -{ -private: - ObjectAccessor(); - ~ObjectAccessor(); - ObjectAccessor(const ObjectAccessor&); - ObjectAccessor& operator=(const ObjectAccessor&); + typedef std::unordered_map<ObjectGuid, T*> MapType; -public: - static ObjectAccessor* instance(); - // TODO: override these template functions for each holder type and add assertions - - template<class T> static T* GetObjectInOrOutOfWorld(uint64 guid, T* /*typeSpecifier*/) - { - return HashMapHolder<T>::Find(guid); - } - - static Unit* GetObjectInOrOutOfWorld(uint64 guid, Unit* /*typeSpecifier*/) - { - if (IS_PLAYER_GUID(guid)) - return (Unit*)GetObjectInOrOutOfWorld(guid, (Player*)nullptr); - - if (IS_PET_GUID(guid)) - return (Unit*)GetObjectInOrOutOfWorld(guid, (Pet*)nullptr); - - return (Unit*)GetObjectInOrOutOfWorld(guid, (Creature*)nullptr); - } - - // returns object if is in world - template<class T> static T* GetObjectInWorld(uint64 guid, T* /*typeSpecifier*/) - { - return HashMapHolder<T>::Find(guid); - } - - // Player may be not in world while in ObjectAccessor - static Player* GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/); - - static Unit* GetObjectInWorld(uint64 guid, Unit* /*typeSpecifier*/) - { - if (IS_PLAYER_GUID(guid)) - return (Unit*)GetObjectInWorld(guid, (Player*)nullptr); + static void Insert(T* o); - if (IS_PET_GUID(guid)) - return (Unit*)GetObjectInWorld(guid, (Pet*)nullptr); + static void Remove(T* o); - return (Unit*)GetObjectInWorld(guid, (Creature*)nullptr); - } + static T* Find(ObjectGuid guid); - // returns object if is in map - template<class T> static T* GetObjectInMap(uint64 guid, Map* map, T* /*typeSpecifier*/) - { - ASSERT(map); - if (T* obj = GetObjectInWorld(guid, (T*)nullptr)) - if (obj->GetMap() == map) - return obj; - return nullptr; - } + static MapType& GetContainer(); - template<class T> - static T* GetObjectInWorld(uint32 mapid, float x, float y, uint64 guid, T* /*fake*/); + static std::shared_mutex* GetLock(); +}; +namespace ObjectAccessor +{ // these functions return objects only if in map of specified object - static WorldObject* GetWorldObject(WorldObject const&, uint64); - static Object* GetObjectByTypeMask(WorldObject const&, uint64, uint32 typemask); - static Corpse* GetCorpse(WorldObject const& u, uint64 guid); - static GameObject* GetGameObject(WorldObject const& u, uint64 guid); - static Transport* GetTransport(WorldObject const& u, uint64 guid); - static DynamicObject* GetDynamicObject(WorldObject const& u, uint64 guid); - static Unit* GetUnit(WorldObject const&, uint64 guid); - static Creature* GetCreature(WorldObject const& u, uint64 guid); - static Pet* GetPet(WorldObject const&, uint64 guid); - static Player* GetPlayer(WorldObject const&, uint64 guid); - static Creature* GetCreatureOrPetOrVehicle(WorldObject const&, uint64); + WorldObject* GetWorldObject(WorldObject const&, ObjectGuid const guid); + Object* GetObjectByTypeMask(WorldObject const&, ObjectGuid const guid, uint32 typemask); + Corpse* GetCorpse(WorldObject const& u, ObjectGuid const guid); + GameObject* GetGameObject(WorldObject const& u, ObjectGuid const guid); + Transport* GetTransport(WorldObject const& u, ObjectGuid const guid); + DynamicObject* GetDynamicObject(WorldObject const& u, ObjectGuid const guid); + Unit* GetUnit(WorldObject const&, ObjectGuid const guid); + Creature* GetCreature(WorldObject const& u, ObjectGuid const guid); + Pet* GetPet(WorldObject const&, ObjectGuid const guid); + Player* GetPlayer(Map const*, ObjectGuid const guid); + Player* GetPlayer(WorldObject const&, ObjectGuid const guid); + Creature* GetCreatureOrPetOrVehicle(WorldObject const&, ObjectGuid const); // these functions return objects if found in whole world // ACCESS LIKE THAT IS NOT THREAD SAFE - static Pet* FindPet(uint64); - static Player* FindPlayer(uint64); - static Player* FindPlayerInOrOutOfWorld(uint64 m_guid); - - static Unit* FindUnit(uint64); - static Player* FindConnectedPlayer(uint64 const&); - static Player* FindPlayerByName(std::string const& name, bool checkInWorld = true); - static std::map<std::string, Player*> playerNameToPlayerPointer; // pussywizard: optimization - - // when using this, you must use the hashmapholder's lock - static HashMapHolder<Player>::MapType const& GetPlayers() - { - return HashMapHolder<Player>::GetContainer(); - } + Player* FindPlayer(ObjectGuid const guid); + Player* FindPlayerByLowGUID(ObjectGuid::LowType lowguid); + Player* FindConnectedPlayer(ObjectGuid const guid); + Player* FindPlayerByName(std::string const& name, bool checkInWorld = true); // when using this, you must use the hashmapholder's lock - static HashMapHolder<Creature>::MapType const& GetCreatures() - { - return HashMapHolder<Creature>::GetContainer(); - } + HashMapHolder<Player>::MapType const& GetPlayers(); - // when using this, you must use the hashmapholder's lock - static HashMapHolder<GameObject>::MapType const& GetGameObjects() - { - return HashMapHolder<GameObject>::GetContainer(); - } - - template<class T> static void AddObject(T* object) + template<class T> + void AddObject(T* object) { HashMapHolder<T>::Insert(object); } - template<class T> static void RemoveObject(T* object) + template<class T> + void RemoveObject(T* object) { HashMapHolder<T>::Remove(object); } - static void SaveAllPlayers(); + void SaveAllPlayers(); - //non-static functions - void AddUpdateObject(Object* obj) - { - std::lock_guard<std::mutex> guard(i_objectLock); - if (obj->GetTypeId() < TYPEID_UNIT) // these are not in map: TYPEID_OBJECT, TYPEID_ITEM, TYPEID_CONTAINER - i_objects.insert(obj); - else - ((WorldObject*)obj)->FindMap()->i_objectsToUpdate.insert(obj); - } + template<> + void AddObject(Player* player); - void RemoveUpdateObject(Object* obj) - { - std::lock_guard<std::mutex> guard(i_objectLock); - if (obj->GetTypeId() < TYPEID_UNIT) // these are not in map: TYPEID_OBJECT, TYPEID_ITEM, TYPEID_CONTAINER - i_objects.erase(obj); - else - ((WorldObject*)obj)->FindMap()->i_objectsToUpdate.erase(obj); - } - - //Thread safe - Corpse* GetCorpseForPlayerGUID(uint64 guid); - void RemoveCorpse(Corpse* corpse, bool final = false); - void AddCorpse(Corpse* corpse); - void AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, Map* map); - Corpse* ConvertCorpseForPlayer(uint64 player_guid, bool insignia = false); - - //Thread unsafe - void Update(uint32 diff); - void RemoveOldCorpses(); - void UnloadAll(); - - // pussywizard: crashfix for corpses - void AddDelayedCorpseAction(Corpse* corpse, uint8 action, uint32 mapId = 0, uint32 instanceId = 0); - void ProcessDelayedCorpseActions(); - -private: - static void _buildChangeObjectForPlayer(WorldObject*, UpdateDataMapType&); - static void _buildPacket(Player*, Object*, UpdateDataMapType&); - void _update(); - - typedef std::unordered_map<uint64, Corpse*> Player2CorpsesMapType; - typedef std::unordered_map<Player*, UpdateData>::value_type UpdateDataValueType; - - std::unordered_set<Object*> i_objects; - Player2CorpsesMapType i_player2corpse; - std::list<uint64> i_playerBones; - - std::mutex i_objectLock; - std::shared_mutex i_corpseLock; - std::list<DelayedCorpseAction> i_delayedCorpseActions; - mutable std::mutex DelayedCorpseLock; + template<> + void RemoveObject(Player* player); }; -#define sObjectAccessor ObjectAccessor::instance() - #endif diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index d26e777a83..759480b648 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -281,18 +281,10 @@ bool SpellClickInfo::IsFitToRequirements(Unit const* clicker, Unit const* clicke ObjectMgr::ObjectMgr(): _auctionId(1), _equipmentSetGuid(1), - _itemTextId(1), _mailId(1), _hiPetNumber(1), - _hiCharGuid(1), - _hiCreatureGuid(1), - _hiPetGuid(1), - _hiVehicleGuid(1), - _hiItemGuid(1), - _hiGoGuid(1), - _hiDoGuid(1), - _hiCorpseGuid(1), - _hiMoTransGuid(1), + _creatureSpawnId(1), + _gameObjectSpawnId(1), DBCLocaleIndex(LOCALE_enUS) { for (uint8 i = 0; i < MAX_CLASSES; ++i) @@ -1149,7 +1141,7 @@ void ObjectMgr::LoadCreatureAddons() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); CreatureData const* creData = GetCreatureData(guid); if (!creData) @@ -1228,7 +1220,7 @@ void ObjectMgr::LoadGameObjectAddons() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); const GameObjectData* goData = GetGOData(guid); if (!goData) @@ -1261,7 +1253,7 @@ void ObjectMgr::LoadGameObjectAddons() LOG_INFO("server", " "); } -GameObjectAddon const* ObjectMgr::GetGameObjectAddon(uint32 lowguid) +GameObjectAddon const* ObjectMgr::GetGameObjectAddon(ObjectGuid::LowType lowguid) { GameObjectAddonContainer::const_iterator itr = _gameObjectAddonStore.find(lowguid); if (itr != _gameObjectAddonStore.end()) @@ -1270,7 +1262,7 @@ GameObjectAddon const* ObjectMgr::GetGameObjectAddon(uint32 lowguid) return nullptr; } -CreatureAddon const* ObjectMgr::GetCreatureAddon(uint32 lowguid) +CreatureAddon const* ObjectMgr::GetCreatureAddon(ObjectGuid::LowType lowguid) { CreatureAddonContainer::const_iterator itr = _creatureAddonStore.find(lowguid); if (itr != _creatureAddonStore.end()) @@ -1528,11 +1520,11 @@ void ObjectMgr::LoadLinkedRespawn() { Field* fields = result->Fetch(); - uint32 guidLow = fields[0].GetUInt32(); - uint32 linkedGuidLow = fields[1].GetUInt32(); + ObjectGuid::LowType guidLow = fields[0].GetUInt32(); + ObjectGuid::LowType linkedGuidLow = fields[1].GetUInt32(); uint8 linkType = fields[2].GetUInt8(); - uint64 guid = 0, linkedGuid = 0; + ObjectGuid guid, linkedGuid; bool error = false; switch (linkType) { @@ -1569,8 +1561,8 @@ void ObjectMgr::LoadLinkedRespawn() break; } - guid = MAKE_NEW_GUID(guidLow, slave->id, HIGHGUID_UNIT); - linkedGuid = MAKE_NEW_GUID(linkedGuidLow, master->id, HIGHGUID_UNIT); + guid = ObjectGuid::Create<HighGuid::Unit>(slave->id, guidLow); + linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id, linkedGuidLow); break; } case CREATURE_TO_GO: @@ -1606,8 +1598,8 @@ void ObjectMgr::LoadLinkedRespawn() break; } - guid = MAKE_NEW_GUID(guidLow, slave->id, HIGHGUID_UNIT); - linkedGuid = MAKE_NEW_GUID(linkedGuidLow, master->id, HIGHGUID_GAMEOBJECT); + guid = ObjectGuid::Create<HighGuid::Unit>(slave->id, guidLow); + linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow); break; } case GO_TO_GO: @@ -1643,8 +1635,8 @@ void ObjectMgr::LoadLinkedRespawn() break; } - guid = MAKE_NEW_GUID(guidLow, slave->id, HIGHGUID_GAMEOBJECT); - linkedGuid = MAKE_NEW_GUID(linkedGuidLow, master->id, HIGHGUID_GAMEOBJECT); + guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow); + linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow); break; } case GO_TO_CREATURE: @@ -1680,8 +1672,8 @@ void ObjectMgr::LoadLinkedRespawn() break; } - guid = MAKE_NEW_GUID(guidLow, slave->id, HIGHGUID_GAMEOBJECT); - linkedGuid = MAKE_NEW_GUID(linkedGuidLow, master->id, HIGHGUID_UNIT); + guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow); + linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id, linkedGuidLow); break; } } @@ -1694,13 +1686,13 @@ void ObjectMgr::LoadLinkedRespawn() LOG_INFO("server", " "); } -bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow) +bool ObjectMgr::SetCreatureLinkedRespawn(ObjectGuid::LowType guidLow, ObjectGuid::LowType linkedGuidLow) { if (!guidLow) return false; - const CreatureData* master = GetCreatureData(guidLow); - uint64 guid = MAKE_NEW_GUID(guidLow, master->id, HIGHGUID_UNIT); + CreatureData const* master = GetCreatureData(guidLow); + ObjectGuid guid = ObjectGuid::Create<HighGuid::Unit>(master->id, guidLow); if (!linkedGuidLow) // we're removing the linking { @@ -1711,14 +1703,14 @@ bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow) return true; } - const CreatureData* slave = GetCreatureData(linkedGuidLow); + CreatureData const* slave = GetCreatureData(linkedGuidLow); if (!slave) { // LOG_ERROR("server", "sql.sql", "Creature '%u' linking to non-existent creature '%u'.", guidLow, linkedGuidLow); return false; } - const MapEntry* const map = sMapStore.LookupEntry(master->mapid); + MapEntry const* map = sMapStore.LookupEntry(master->mapid); if (!map || !map->Instanceable() || (master->mapid != slave->mapid)) { LOG_ERROR("sql.sql", "Creature '%u' linking to '%u' on an unpermitted map.", guidLow, linkedGuidLow); @@ -1731,7 +1723,7 @@ bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow) return false; } - uint64 linkedGuid = MAKE_NEW_GUID(linkedGuidLow, slave->id, HIGHGUID_UNIT); + ObjectGuid linkedGuid = ObjectGuid::Create<HighGuid::Unit>(slave->id, linkedGuidLow); _linkedRespawnStore[guid] = linkedGuid; PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_REP_CREATURE_LINKED_RESPAWN); @@ -1860,17 +1852,17 @@ void ObjectMgr::LoadCreatures() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - uint32 entry = fields[1].GetUInt32(); + ObjectGuid::LowType spawnId = fields[0].GetUInt32(); + uint32 entry = fields[1].GetUInt32(); CreatureTemplate const* cInfo = GetCreatureTemplate(entry); if (!cInfo) { - LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u) with non existing creature entry %u, skipped.", guid, entry); + LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: %u) with non existing creature entry %u, skipped.", spawnId, entry); continue; } - CreatureData& data = _creatureDataStore[guid]; + CreatureData& data = _creatureDataStore[spawnId]; data.id = entry; data.mapid = fields[2].GetUInt16(); data.displayid = fields[3].GetUInt32(); @@ -1896,7 +1888,7 @@ void ObjectMgr::LoadCreatures() MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid); if (!mapEntry) { - LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u) that spawned at not existed map (Id: %u), skipped.", guid, data.mapid); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: %u) that spawned at not existed map (Id: %u), skipped.", spawnId, data.mapid); continue; } @@ -1906,15 +1898,16 @@ void ObjectMgr::LoadCreatures() // Skip spawnMask check for transport maps if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid]) - LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).", guid, data.spawnMask, data.mapid); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).", + spawnId, data.spawnMask, data.mapid); bool ok = true; for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff) { if (_difficultyEntries[diff].find(data.id) != _difficultyEntries[diff].end()) { - LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u) that listed as difficulty %u template (entry: %u) in `creature_template`, skipped.", - guid, diff + 1, data.id); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: %u) that listed as difficulty %u template (entry: %u) in `creature_template`, skipped.", + spawnId, diff + 1, data.id); ok = false; } } @@ -1926,7 +1919,8 @@ void ObjectMgr::LoadCreatures() { if (!GetEquipmentInfo(data.id, data.equipmentId)) { - LOG_ERROR("sql.sql", "Table `creature` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", data.id, data.equipmentId); + LOG_ERROR("sql.sql", "Table `creature` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", + data.id, data.equipmentId); data.equipmentId = 0; } } @@ -1934,19 +1928,21 @@ void ObjectMgr::LoadCreatures() if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) { if (!mapEntry->IsDungeon()) - LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.", guid, data.id); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.", + spawnId, data.id); } if (data.wander_distance < 0.0f) { - LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) with `wander_distance`< 0, set to 0.", guid, data.id); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: %u Entry: %u) with `wander_distance`< 0, set to 0.", spawnId, data.id); data.wander_distance = 0.0f; } else if (data.movementType == RANDOM_MOTION_TYPE) { if (data.wander_distance == 0.0f) { - LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).", guid, data.id); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: %u Entry: %u) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).", + spawnId, data.id); data.movementType = IDLE_MOTION_TYPE; } } @@ -1954,14 +1950,14 @@ void ObjectMgr::LoadCreatures() { if (data.wander_distance != 0.0f) { - LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.", guid, data.id); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: %u Entry: %u) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.", spawnId, data.id); data.wander_distance = 0.0f; } } if (data.phaseMask == 0) { - LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.", spawnId, data.id); data.phaseMask = 1; } @@ -1974,14 +1970,14 @@ void ObjectMgr::LoadCreatures() stmt->setUInt32(0, zoneId); stmt->setUInt32(1, areaId); - stmt->setUInt64(2, guid); + stmt->setUInt32(2, spawnId); WorldDatabase.Execute(stmt); } // Add to grid if not managed by the game event or pool system if (gameEvent == 0 && PoolId == 0) - AddCreatureToGrid(guid, &data); + AddCreatureToGrid(spawnId, &data); ++count; } while (result->NextRow()); @@ -1990,7 +1986,7 @@ void ObjectMgr::LoadCreatures() LOG_INFO("server", " "); } -void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) +void ObjectMgr::AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -2004,7 +2000,7 @@ void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) } } -void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) +void ObjectMgr::RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -2028,8 +2024,9 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float if (!map) return 0; - uint32 guid = GenerateLowGuid(HIGHGUID_GAMEOBJECT); - GameObjectData& data = NewGOData(guid); + ObjectGuid::LowType spawnId = GenerateGameObjectSpawnId(); + + GameObjectData& data = NewGOData(spawnId); data.id = entry; data.mapid = mapId; data.posX = x; @@ -2048,14 +2045,14 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0; data.dbData = false; - AddGameobjectToGrid(guid, &data); + AddGameobjectToGrid(spawnId, &data); // Spawn if necessary (loaded grids only) // We use spawn coords to spawn if (!map->Instanceable() && map->IsGridLoaded(x, y)) { GameObject* go = sObjectMgr->IsGameObjectStaticTransport(data.id) ? new StaticTransport() : new GameObject(); - if (!go->LoadGameObjectFromDB(guid, map)) + if (!go->LoadGameObjectFromDB(spawnId, map)) { LOG_ERROR("server", "AddGOData: cannot add gameobject entry %u to map", entry); delete go; @@ -2064,43 +2061,10 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("maps", "AddGOData: dbguid %u entry %u map %u x %f y %f z %f o %f", guid, entry, mapId, x, y, z, o); + LOG_DEBUG("maps", "AddGOData: spawnId %u entry %u map %u x %f y %f z %f o %f", spawnId, entry, mapId, x, y, z, o); #endif - return guid; -} - -bool ObjectMgr::MoveCreData(uint32 guid, uint32 mapId, Position pos) -{ - CreatureData& data = NewOrExistCreatureData(guid); - if (!data.id) - return false; - - RemoveCreatureFromGrid(guid, &data); - if (data.posX == pos.GetPositionX() && data.posY == pos.GetPositionY() && data.posZ == pos.GetPositionZ()) - return true; - data.posX = pos.GetPositionX(); - data.posY = pos.GetPositionY(); - data.posZ = pos.GetPositionZ(); - data.orientation = pos.GetOrientation(); - AddCreatureToGrid(guid, &data); - - // Spawn if necessary (loaded grids only) - if (Map* map = sMapMgr->CreateBaseMap(mapId)) - { - // We use spawn coords to spawn - if (!map->Instanceable() && map->IsGridLoaded(data.posX, data.posY)) - { - Creature* creature = new Creature(); - if (!creature->LoadCreatureFromDB(guid, map)) - { - LOG_ERROR("server", "MoveCreData: Cannot add creature guid %u to map", guid); - delete creature; - return false; - } - } - } - return true; + return spawnId; } uint32 ObjectMgr::AddCreData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay) @@ -2111,9 +2075,13 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 mapId, float x, float y, float uint32 level = cInfo->minlevel == cInfo->maxlevel ? cInfo->minlevel : urand(cInfo->minlevel, cInfo->maxlevel); // Only used for extracting creature base stats CreatureBaseStats const* stats = GetCreatureBaseStats(level, cInfo->unit_class); + Map* map = sMapMgr->CreateBaseMap(mapId); + if (!map) + return 0; - uint32 guid = GenerateLowGuid(HIGHGUID_UNIT); - CreatureData& data = NewOrExistCreatureData(guid); + ObjectGuid::LowType spawnId = GenerateCreatureSpawnId(); + CreatureData& data = NewOrExistCreatureData(spawnId); + data.spawnMask = spawnId; data.id = entry; data.mapid = mapId; data.displayid = 0; @@ -2135,25 +2103,21 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 mapId, float x, float y, float data.unit_flags = cInfo->unit_flags; data.dynamicflags = cInfo->dynamicflags; - AddCreatureToGrid(guid, &data); + AddCreatureToGrid(spawnId, &data); // Spawn if necessary (loaded grids only) - if (Map* map = sMapMgr->CreateBaseMap(mapId)) + if (!map->Instanceable() && !map->IsRemovalGrid(x, y)) { - // We use spawn coords to spawn - if (!map->Instanceable() && !map->IsRemovalGrid(x, y)) + Creature* creature = new Creature(); + if (!creature->LoadCreatureFromDB(spawnId, map, true, false, true)) { - Creature* creature = new Creature(); - if (!creature->LoadCreatureFromDB(guid, map)) - { - LOG_ERROR("server", "AddCreature: Cannot add creature entry %u to map", entry); - delete creature; - return 0; - } + LOG_ERROR("server", "AddCreature: Cannot add creature entry %u to map", entry); + delete creature; + return 0; } } - return guid; + return spawnId; } void ObjectMgr::LoadGameobjects() @@ -2189,8 +2153,8 @@ void ObjectMgr::LoadGameobjects() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - uint32 entry = fields[1].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); + uint32 entry = fields[1].GetUInt32(); GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry); if (!gInfo) @@ -2309,7 +2273,7 @@ void ObjectMgr::LoadGameobjects() stmt->setUInt32(0, zoneId); stmt->setUInt32(1, areaId); - stmt->setUInt64(2, guid); + stmt->setUInt32(2, guid); WorldDatabase.Execute(stmt); } @@ -2323,7 +2287,7 @@ void ObjectMgr::LoadGameobjects() LOG_INFO("server", " "); } -void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) +void ObjectMgr::AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -2337,7 +2301,7 @@ void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) } } -void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data) +void ObjectMgr::RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -2351,20 +2315,20 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data } } -uint64 ObjectMgr::GetPlayerGUIDByName(std::string const& name) const +ObjectGuid ObjectMgr::GetPlayerGUIDByName(std::string const& name) const { // Get data from global storage - if (uint32 guidLow = sWorld->GetGlobalPlayerGUID(name)) - return MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER); + if (ObjectGuid guid = sWorld->GetGlobalPlayerGUID(name)) + return guid; // No player found - return 0; + return ObjectGuid::Empty; } -bool ObjectMgr::GetPlayerNameByGUID(uint64 guid, std::string& name) const +bool ObjectMgr::GetPlayerNameByGUID(ObjectGuid::LowType lowGuid, std::string& name) const { // Get data from global storage - if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid))) + if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(lowGuid)) { name = playerData->name; return true; @@ -2373,19 +2337,19 @@ bool ObjectMgr::GetPlayerNameByGUID(uint64 guid, std::string& name) const return false; } -TeamId ObjectMgr::GetPlayerTeamIdByGUID(uint64 guid) const +TeamId ObjectMgr::GetPlayerTeamIdByGUID(ObjectGuid::LowType guid) const { // xinef: Get data from global storage - if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid))) + if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid)) return Player::TeamIdForRace(playerData->race); return TEAM_NEUTRAL; } -uint32 ObjectMgr::GetPlayerAccountIdByGUID(uint64 guid) const +uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid::LowType guid) const { // xinef: Get data from global storage - if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid))) + if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid)) return playerData->accountId; return 0; @@ -2394,8 +2358,8 @@ uint32 ObjectMgr::GetPlayerAccountIdByGUID(uint64 guid) const uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(const std::string& name) const { // Get data from global storage - if (uint32 guidLow = sWorld->GetGlobalPlayerGUID(name)) - if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guidLow)) + if (ObjectGuid guid = sWorld->GetGlobalPlayerGUID(name)) + if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid.GetCounter())) return playerData->accountId; return 0; @@ -5713,7 +5677,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) Player* player = nullptr; if (serverUp) - player = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(m->receiver, 0, HIGHGUID_PLAYER)); + player = ObjectAccessor::FindPlayerByLowGUID(m->receiver); if (player) // don't modify mails of a logged in player { @@ -6418,39 +6382,21 @@ void ObjectMgr::SetHighestGuids() { QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters"); if (result) - _hiCharGuid = (*result)[0].GetUInt32() + 1; - - result = WorldDatabase.Query("SELECT MAX(guid) FROM creature"); - if (result) - { - _hiCreatureGuid = (*result)[0].GetUInt32() + 1; - _hiCreatureRecycledGuid = _hiCreatureGuid; - _hiCreatureRecycledGuidMax = _hiCreatureRecycledGuid + 10000; - _hiCreatureGuid = _hiCreatureRecycledGuidMax + 1; - } + GetGuidSequenceGenerator<HighGuid::Player>().Set((*result)[0].GetUInt32() + 1); result = CharacterDatabase.Query("SELECT MAX(guid) FROM item_instance"); if (result) - _hiItemGuid = (*result)[0].GetUInt32() + 1; + GetGuidSequenceGenerator<HighGuid::Item>().Set((*result)[0].GetUInt32() + 1); // Cleanup other tables from not existed guids ( >= _hiItemGuid) - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", _hiItemGuid); // One-time query - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", _hiItemGuid); // One-time query - CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", _hiItemGuid); // One-time query - CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", _hiItemGuid); // One-time query - - result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject"); - if (result) - { - _hiGoGuid = (*result)[0].GetUInt32() + 1; - _hiGoRecycledGuid = _hiGoGuid; - _hiGoRecycledGuidMax = _hiGoRecycledGuid + 1; - _hiGoGuid = _hiGoRecycledGuidMax + 1; - } + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query + CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query + CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query + CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query result = WorldDatabase.Query("SELECT MAX(guid) FROM transports"); if (result) - _hiMoTransGuid = (*result)[0].GetUInt32() + 1; + GetGuidSequenceGenerator<HighGuid::Mo_Transport>().Set((*result)[0].GetUInt32() + 1); result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse"); if (result) @@ -6460,10 +6406,6 @@ void ObjectMgr::SetHighestGuids() if (result) _mailId = (*result)[0].GetUInt32() + 1; - result = CharacterDatabase.Query("SELECT MAX(corpseGuid) FROM corpse"); - if (result) - _hiCorpseGuid = (*result)[0].GetUInt32() + 1; - result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team"); if (result) sArenaTeamMgr->SetNextArenaTeamId((*result)[0].GetUInt32() + 1); @@ -6479,6 +6421,14 @@ void ObjectMgr::SetHighestGuids() result = CharacterDatabase.Query("SELECT MAX(guildId) FROM guild"); if (result) sGuildMgr->SetNextGuildId((*result)[0].GetUInt32() + 1); + + result = WorldDatabase.Query("SELECT MAX(guid) FROM creature"); + if (result) + _creatureSpawnId = (*result)[0].GetUInt32() + 1; + + result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject"); + if (result) + _gameObjectSpawnId = (*result)[0].GetUInt32() + 1; } uint32 ObjectMgr::GenerateAuctionID() @@ -6512,92 +6462,24 @@ uint32 ObjectMgr::GenerateMailID() return _mailId++; } -uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh) +uint32 ObjectMgr::GenerateCreatureSpawnId() { - switch (guidhigh) + if (_creatureSpawnId >= uint32(0xFFFFFF)) { - case HIGHGUID_ITEM: - { - ASSERT(_hiItemGuid < 0xFFFFFFFE && "Item guid overflow!"); - std::lock_guard<std::mutex> guard(_hiItemGuidMutex); - return _hiItemGuid++; - } - case HIGHGUID_UNIT: - { - ASSERT(_hiCreatureGuid < 0x00FFFFFE && "Creature guid overflow!"); - std::lock_guard<std::mutex> guard(_hiCreatureGuidMutex); - return _hiCreatureGuid++; - } - case HIGHGUID_PET: - { - ASSERT(_hiPetGuid < 0x00FFFFFE && "Pet guid overflow!"); - std::lock_guard<std::mutex> guard(_hiPetGuidMutex); - return _hiPetGuid++; - } - case HIGHGUID_VEHICLE: - { - ASSERT(_hiVehicleGuid < 0x00FFFFFF && "Vehicle guid overflow!"); - std::lock_guard<std::mutex> guard(_hiVehicleGuidMutex); - return _hiVehicleGuid++; - } - case HIGHGUID_PLAYER: - { - ASSERT(_hiCharGuid < 0xFFFFFFFE && "Player guid overflow!"); - return _hiCharGuid++; - } - case HIGHGUID_GAMEOBJECT: - { - ASSERT(_hiGoGuid < 0x00FFFFFE && "Gameobject guid overflow!"); - std::lock_guard<std::mutex> guard(_hiGoGuidMutex); - return _hiGoGuid++; - } - case HIGHGUID_CORPSE: - { - ASSERT(_hiCorpseGuid < 0xFFFFFFFE && "Corpse guid overflow!"); - std::lock_guard<std::mutex> guard(_hiCorpseGuidMutex); - return _hiCorpseGuid++; - } - case HIGHGUID_DYNAMICOBJECT: - { - ASSERT(_hiDoGuid < 0xFFFFFFFE && "DynamicObject guid overflow!"); - std::lock_guard<std::mutex> guard(_hiDoGuidMutex); - return _hiDoGuid++; - } - case HIGHGUID_MO_TRANSPORT: - { - ASSERT(_hiMoTransGuid < 0xFFFFFFFE && "MO Transport guid overflow!"); - std::lock_guard<std::mutex> guard(_hiMoTransGuidMutex); - return _hiMoTransGuid++; - } - default: - ASSERT(false && "ObjectMgr::GenerateLowGuid - Unknown HIGHGUID type"); - return 0; + LOG_ERROR("server", "Creature spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info."); + World::StopNow(ERROR_EXIT_CODE); } + return _creatureSpawnId++; } -uint32 ObjectMgr::GenerateRecycledLowGuid(HighGuid guidHigh) +uint32 ObjectMgr::GenerateGameObjectSpawnId() { - switch (guidHigh) + if (_gameObjectSpawnId >= uint32(0xFFFFFF)) { - case HIGHGUID_UNIT: - { - ASSERT(_hiCreatureRecycledGuid < 0x00FFFFFE && "Creature recycled guid overflow!"); - if (_hiCreatureRecycledGuid < _hiCreatureRecycledGuidMax) - return _hiCreatureRecycledGuid++; - break; - } - case HIGHGUID_GAMEOBJECT: - { - ASSERT(_hiGoRecycledGuid < 0x00FFFFFE && "Gameobject recycled guid overflow!"); - if (_hiGoRecycledGuid < _hiGoRecycledGuidMax) - return _hiGoRecycledGuid++; - break; - } - default: // Default case is not handled by the recycler - break; + LOG_ERROR("server", "GameObject spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info. "); + World::StopNow(ERROR_EXIT_CODE); } - - return GenerateLowGuid(guidHigh); + return _gameObjectSpawnId++; } void ObjectMgr::LoadGameObjectLocales() @@ -7051,45 +6933,6 @@ uint32 ObjectMgr::GeneratePetNumber() return ++_hiPetNumber; } -void ObjectMgr::LoadCorpses() -{ - uint32 oldMSTime = getMSTime(); - - PreparedQueryResult result = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSES)); - if (!result) - { - LOG_INFO("server", ">> Loaded 0 corpses. DB table `corpse` is empty."); - LOG_INFO("server", " "); - return; - } - - uint32 count = 0; - do - { - Field* fields = result->Fetch(); - uint32 guid = fields[16].GetUInt32(); - CorpseType type = CorpseType(fields[13].GetUInt8()); - if (type >= MAX_CORPSE_TYPE) - { - LOG_ERROR("server", "Corpse (guid: %u) have wrong corpse type (%u), not loading.", guid, type); - continue; - } - - Corpse* corpse = new Corpse(type); - if (!corpse->LoadCorpseFromDB(guid, fields)) - { - delete corpse; - continue; - } - - sObjectAccessor->AddCorpse(corpse); - ++count; - } while (result->NextRow()); - - LOG_INFO("server", ">> Loaded %u corpses in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server", " "); -} - void ObjectMgr::LoadReputationRewardRate() { uint32 oldMSTime = getMSTime(); @@ -7554,7 +7397,7 @@ void ObjectMgr::LoadNPCSpellClickSpells() LOG_INFO("server", " "); } -void ObjectMgr::DeleteCreatureData(uint32 guid) +void ObjectMgr::DeleteCreatureData(ObjectGuid::LowType guid) { // remove mapid*cellid -> guid_set map CreatureData const* data = GetCreatureData(guid); @@ -7564,7 +7407,7 @@ void ObjectMgr::DeleteCreatureData(uint32 guid) _creatureDataStore.erase(guid); } -void ObjectMgr::DeleteGOData(uint32 guid) +void ObjectMgr::DeleteGOData(ObjectGuid::LowType guid) { // remove mapid*cellid -> guid_set map GameObjectData const* data = GetGOData(guid); @@ -7574,20 +7417,6 @@ void ObjectMgr::DeleteGOData(uint32 guid) _gameObjectDataStore.erase(guid); } -void ObjectMgr::AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance) -{ - // corpses are always added to spawn mode 0 and they are spawned by their instance id - CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(mapid, 0)][cellid]; - cell_guids.corpses[player_guid] = instance; -} - -void ObjectMgr::DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid) -{ - // corpses are always added to spawn mode 0 and they are spawned by their instance id - CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(mapid, 0)][cellid]; - cell_guids.corpses.erase(player_guid); -} - void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map, std::string const& table, bool starter, bool go) { uint32 oldMSTime = getMSTime(); @@ -9327,12 +9156,6 @@ GameObjectTemplate const* ObjectMgr::GetGameObjectTemplate(uint32 entry) return nullptr; } -Player* ObjectMgr::GetPlayerByLowGUID(uint32 lowguid) const -{ - uint64 guid = MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER); - return ObjectAccessor::FindPlayer(guid); -} - bool ObjectMgr::IsGameObjectStaticTransport(uint32 entry) { GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry); @@ -9358,7 +9181,7 @@ VehicleAccessoryList const* ObjectMgr::GetVehicleAccessoryList(Vehicle* veh) con if (Creature* cre = veh->GetBase()->ToCreature()) { // Give preference to GUID-based accessories - VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetDBTableGUIDLow()); + VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetSpawnId()); if (itr != _vehicleAccessoryStore.end()) return &itr->second; } diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 839821d8aa..68db40ae55 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -461,14 +461,12 @@ struct BroadcastText typedef std::unordered_map<uint32, BroadcastText> BroadcastTextContainer; -typedef std::set<uint32> CellGuidSet; -typedef std::unordered_map<uint32/*player guid*/, uint32/*instance*/> CellCorpseSet; +typedef std::set<ObjectGuid::LowType> CellGuidSet; struct CellObjectGuids { CellGuidSet creatures; CellGuidSet gameobjects; - CellCorpseSet corpses; }; typedef std::unordered_map<uint32/*cell_id*/, CellObjectGuids> CellObjectGuidsMap; @@ -488,9 +486,9 @@ struct AcoreString StringVector Content; }; -typedef std::map<uint64, uint64> LinkedRespawnContainer; -typedef std::unordered_map<uint32, CreatureData> CreatureDataContainer; -typedef std::unordered_map<uint32, GameObjectData> GameObjectDataContainer; +typedef std::map<ObjectGuid, ObjectGuid> LinkedRespawnContainer; +typedef std::unordered_map<ObjectGuid::LowType, CreatureData> CreatureDataContainer; +typedef std::unordered_map<ObjectGuid::LowType, GameObjectData> GameObjectDataContainer; typedef std::map<TempSummonGroupKey, std::vector<TempSummonData> > TempSummonDataContainer; typedef std::unordered_map<uint32, CreatureLocale> CreatureLocaleContainer; typedef std::unordered_map<uint32, GameObjectLocale> GameObjectLocaleContainer; @@ -716,8 +714,6 @@ public: typedef std::map<uint32, uint32> CharacterConversionMap; - [[nodiscard]] Player* GetPlayerByLowGUID(uint32 lowguid) const; - GameObjectTemplate const* GetGameObjectTemplate(uint32 entry); bool IsGameObjectStaticTransport(uint32 entry); [[nodiscard]] GameObjectTemplateContainer const* GetGameObjectTemplates() const { return &_gameObjectTemplateStore; } @@ -734,8 +730,8 @@ public: static uint32 ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData const* data = nullptr); static void ChooseCreatureFlags(CreatureTemplate const* cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, CreatureData const* data = nullptr); EquipmentInfo const* GetEquipmentInfo(uint32 entry, int8& id); - CreatureAddon const* GetCreatureAddon(uint32 lowguid); - GameObjectAddon const* GetGameObjectAddon(uint32 lowguid); + CreatureAddon const* GetCreatureAddon(ObjectGuid::LowType lowguid); + GameObjectAddon const* GetGameObjectAddon(ObjectGuid::LowType lowguid); [[nodiscard]] GameObjectTemplateAddon const* GetGameObjectTemplateAddon(uint32 entry) const; CreatureAddon const* GetCreatureTemplateAddon(uint32 entry); ItemTemplate const* GetItemTemplate(uint32 entry); @@ -766,10 +762,10 @@ public: void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const; - [[nodiscard]] uint64 GetPlayerGUIDByName(std::string const& name) const; - bool GetPlayerNameByGUID(uint64 guid, std::string& name) const; - [[nodiscard]] TeamId GetPlayerTeamIdByGUID(uint64 guid) const; - [[nodiscard]] uint32 GetPlayerAccountIdByGUID(uint64 guid) const; + [[nodiscard]] ObjectGuid GetPlayerGUIDByName(std::string const& name) const; + bool GetPlayerNameByGUID(ObjectGuid::LowType lowGuid, std::string& name) const; + [[nodiscard]] TeamId GetPlayerTeamIdByGUID(ObjectGuid::LowType guid) const; + [[nodiscard]] uint32 GetPlayerAccountIdByGUID(ObjectGuid::LowType guid) const; [[nodiscard]] uint32 GetPlayerAccountIdByPlayerName(std::string const& name) const; uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, uint32 teamId); @@ -988,7 +984,7 @@ public: void LoadTempSummons(); void LoadCreatures(); void LoadLinkedRespawn(); - bool SetCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid); + bool SetCreatureLinkedRespawn(ObjectGuid::LowType guid, ObjectGuid::LowType linkedGuid); void LoadCreatureAddons(); void LoadGameObjectAddons(); void LoadCreatureModelInfo(); @@ -1030,7 +1026,6 @@ public: void LoadExplorationBaseXP(); void LoadPetNames(); void LoadPetNumber(); - void LoadCorpses(); void LoadFishingBaseSkillLevel(); void ChangeFishingBaseSkillLevel(uint32 entry, int32 skill); @@ -1067,12 +1062,20 @@ public: CreatureBaseStats const* GetCreatureBaseStats(uint8 level, uint8 unitClass); void SetHighestGuids(); - uint32 GenerateLowGuid(HighGuid guidhigh); - uint32 GenerateRecycledLowGuid(HighGuid guidHigh); + + template<HighGuid type> + inline ObjectGuidGeneratorBase& GetGenerator() + { + static_assert(ObjectGuidTraits<type>::Global, "Only global guid can be generated in ObjectMgr context"); + return GetGuidSequenceGenerator<type>(); + } + uint32 GenerateAuctionID(); uint64 GenerateEquipmentSetGuid(); uint32 GenerateMailID(); uint32 GeneratePetNumber(); + ObjectGuid::LowType GenerateCreatureSpawnId(); + ObjectGuid::LowType GenerateGameObjectSpawnId(); typedef std::multimap<int32, uint32> ExclusiveQuestGroups; typedef std::pair<ExclusiveQuestGroups::const_iterator, ExclusiveQuestGroups::const_iterator> ExclusiveQuestGroupsBounds; @@ -1137,26 +1140,27 @@ public: return &itr->second; return nullptr; } - [[nodiscard]] CreatureData const* GetCreatureData(uint32 guid) const + [[nodiscard]] CreatureData const* GetCreatureData(ObjectGuid::LowType spawnId) const { - CreatureDataContainer::const_iterator itr = _creatureDataStore.find(guid); + CreatureDataContainer::const_iterator itr = _creatureDataStore.find(spawnId); if (itr == _creatureDataStore.end()) return nullptr; return &itr->second; } - CreatureData& NewOrExistCreatureData(uint32 guid) { return _creatureDataStore[guid]; } - void DeleteCreatureData(uint32 guid); - [[nodiscard]] uint64 GetLinkedRespawnGuid(uint64 guid) const + CreatureData& NewOrExistCreatureData(ObjectGuid::LowType spawnId) { return _creatureDataStore[spawnId]; } + void DeleteCreatureData(ObjectGuid::LowType spawnId); + [[nodiscard]] ObjectGuid GetLinkedRespawnGuid(ObjectGuid guid) const { LinkedRespawnContainer::const_iterator itr = _linkedRespawnStore.find(guid); - if (itr == _linkedRespawnStore.end()) return 0; + if (itr == _linkedRespawnStore.end()) + return ObjectGuid::Empty; return itr->second; } - [[nodiscard]] GameObjectData const* GetGOData(uint32 guid) const + [[nodiscard]] GameObjectData const* GetGOData(ObjectGuid::LowType spawnId) const { - GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(guid); + GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(spawnId); if (itr == _gameObjectDataStore.end()) return nullptr; - return &itr->second; + return &itr->second; } [[nodiscard]] CreatureLocale const* GetCreatureLocale(uint32 entry) const { @@ -1224,8 +1228,8 @@ public: if (itr == _npcTextLocaleStore.end()) return nullptr; return &itr->second; } - GameObjectData& NewGOData(uint32 guid) { return _gameObjectDataStore[guid]; } - void DeleteGOData(uint32 guid); + GameObjectData& NewGOData(ObjectGuid::LowType guid) { return _gameObjectDataStore[guid]; } + void DeleteGOData(ObjectGuid::LowType guid); [[nodiscard]] AcoreString const* GetAcoreString(uint32 entry) const { @@ -1240,17 +1244,13 @@ public: [[nodiscard]] LocaleConstant GetDBCLocaleIndex() const { return DBCLocaleIndex; } void SetDBCLocaleIndex(LocaleConstant locale) { DBCLocaleIndex = locale; } - void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance); - void DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid); - // grid objects - void AddCreatureToGrid(uint32 guid, CreatureData const* data); - void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data); - void AddGameobjectToGrid(uint32 guid, GameObjectData const* data); - void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data); + void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const* data); + void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data); + void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const* data); + void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const* data); uint32 AddGOData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); uint32 AddCreData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0); - bool MoveCreData(uint32 guid, uint32 map, Position pos); // reserved names void LoadReservedPlayersNames(); @@ -1351,35 +1351,26 @@ private: // first free id for selected id type uint32 _auctionId; // pussywizard: accessed by a single thread uint64 _equipmentSetGuid; // pussywizard: accessed by a single thread - uint32 _itemTextId; // pussywizard: unused? xD uint32 _mailId; std::mutex _mailIdMutex; uint32 _hiPetNumber; std::mutex _hiPetNumberMutex; + ObjectGuid::LowType _creatureSpawnId; + ObjectGuid::LowType _gameObjectSpawnId; + // first free low guid for selected guid type - uint32 _hiCharGuid; // pussywizard: accessed by a single thread - uint32 _hiCreatureGuid; - std::mutex _hiCreatureGuidMutex; - uint32 _hiPetGuid; - std::mutex _hiPetGuidMutex; - uint32 _hiVehicleGuid; - std::mutex _hiVehicleGuidMutex; - uint32 _hiItemGuid; - std::mutex _hiItemGuidMutex; - uint32 _hiGoGuid; - std::mutex _hiGoGuidMutex; - uint32 _hiDoGuid; - std::mutex _hiDoGuidMutex; - uint32 _hiCorpseGuid; - std::mutex _hiCorpseGuidMutex; - uint32 _hiMoTransGuid; - std::mutex _hiMoTransGuidMutex; - - uint32 _hiCreatureRecycledGuidMax; - uint32 _hiCreatureRecycledGuid; - uint32 _hiGoRecycledGuidMax; - uint32 _hiGoRecycledGuid; + template<HighGuid high> + inline ObjectGuidGeneratorBase& GetGuidSequenceGenerator() + { + auto itr = _guidGenerators.find(high); + if (itr == _guidGenerators.end()) + itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first; + + return *itr->second; + } + + std::map<HighGuid, std::unique_ptr<ObjectGuidGeneratorBase>> _guidGenerators; QuestMap _questTemplates; std::vector<Quest*> _questTemplatesFast; // pussywizard diff --git a/src/server/game/Grids/GridDefines.h b/src/server/game/Grids/GridDefines.h index d322b1c43b..deaf07835e 100644 --- a/src/server/game/Grids/GridDefines.h +++ b/src/server/game/Grids/GridDefines.h @@ -18,6 +18,7 @@ class DynamicObject; class GameObject; class Pet; class Player; +class ObjectGuid; #define MAX_NUMBER_OF_CELLS 8 @@ -46,6 +47,7 @@ class Player; // Creature used instead pet to simplify *::Visit templates (not required duplicate code for Creature->Pet case) typedef TYPELIST_5(GameObject, Player, Creature/*pets*/, Corpse/*resurrectable*/, DynamicObject/*farsight target*/) AllWorldObjectTypes; typedef TYPELIST_4(GameObject, Creature/*except pets*/, DynamicObject, Corpse/*Bones*/) AllGridObjectTypes; +typedef TYPELIST_5(Creature, GameObject, DynamicObject, Pet, Corpse) AllMapStoredObjectTypes; typedef GridRefManager<Corpse> CorpseMapType; typedef GridRefManager<Creature> CreatureMapType; @@ -68,6 +70,7 @@ typedef NGrid<MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTyp typedef TypeMapContainer<AllGridObjectTypes> GridTypeMapContainer; typedef TypeMapContainer<AllWorldObjectTypes> WorldTypeMapContainer; +typedef TypeUnorderedMapContainer<AllMapStoredObjectTypes, ObjectGuid> MapStoredObjectTypesContainer; template<uint32 LIMIT> struct CoordPair diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index 214da66fb7..b6eb5efb84 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -61,14 +61,14 @@ void VisibleNotifier::SendToSelf() } } - for (Player::ClientGUIDs::const_iterator it = vis_guids.begin(); it != vis_guids.end(); ++it) + for (GuidUnorderedSet::const_iterator it = vis_guids.begin(); it != vis_guids.end(); ++it) { if (WorldObject* obj = ObjectAccessor::GetWorldObject(i_player, *it)) if (i_largeOnly != obj->IsVisibilityOverridden()) continue; // pussywizard: static transports are removed only in RemovePlayerFromMap and here if can no longer detect (eg. phase changed) - if (IS_TRANSPORT_GUID(*it)) + if ((*it).IsTransport()) if (GameObject* staticTrans = i_player.GetMap()->GetGameObject(*it)) if (i_player.CanSeeOrDetect(staticTrans, false, true)) continue; @@ -76,7 +76,7 @@ void VisibleNotifier::SendToSelf() i_player.m_clientGUIDs.erase(*it); i_data.AddOutOfRangeGUID(*it); - if (IS_PLAYER_GUID(*it)) + if ((*it).IsPlayer()) { Player* player = ObjectAccessor::FindPlayer(*it); if (player && player->IsInMap(&i_player)) @@ -127,7 +127,7 @@ void VisibleChangesNotifier::Visit(CreatureMapType& m) void VisibleChangesNotifier::Visit(DynamicObjectMapType& m) { for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter) - if (IS_PLAYER_GUID(iter->GetSource()->GetCasterGUID())) + if (iter->GetSource()->GetCasterGUID().IsPlayer()) if (Unit* caster = iter->GetSource()->GetCaster()) if (Player* player = caster->ToPlayer()) if (player->m_seer == iter->GetSource()) @@ -245,7 +245,7 @@ void MessageDistDeliverer::Visit(DynamicObjectMapType& m) for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { DynamicObject* target = iter->GetSource(); - if (!IS_PLAYER_GUID(target->GetCasterGUID()) || !target->InSamePhase(i_phaseMask)) + if (!target->GetCasterGUID().IsPlayer() || !target->InSamePhase(i_phaseMask)) continue; // Xinef: Check whether the dynobject allows to see through it @@ -311,7 +311,7 @@ void MessageDistDelivererToHostile::Visit(DynamicObjectMapType& m) for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { DynamicObject* target = iter->GetSource(); - if (!IS_PLAYER_GUID(target->GetCasterGUID()) || !target->InSamePhase(i_phaseMask)) + if (!target->GetCasterGUID().IsPlayer() || !target->InSamePhase(i_phaseMask)) continue; if (target->GetExactDist2dSq(i_source) > i_distSq) diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 16a143fceb..84f4b27610 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -28,7 +28,7 @@ namespace acore struct VisibleNotifier { Player& i_player; - Player::ClientGUIDs vis_guids; + GuidUnorderedSet vis_guids; std::vector<Unit*>& i_visibleNow; bool i_gobjOnly; bool i_largeOnly; @@ -718,18 +718,6 @@ namespace acore NearestGameObjectTypeInObjectRangeCheck(NearestGameObjectTypeInObjectRangeCheck const&); }; - class GameObjectWithDbGUIDCheck - { - public: - GameObjectWithDbGUIDCheck(uint32 db_guid) : i_db_guid(db_guid) {} - bool operator()(GameObject const* go) const - { - return go->GetDBTableGUIDLow() == i_db_guid; - } - private: - uint32 i_db_guid; - }; - // Unit checks class MostHPMissingInRange @@ -859,18 +847,6 @@ namespace acore float i_range; }; - class CreatureWithDbGUIDCheck - { - public: - CreatureWithDbGUIDCheck(uint32 lowguid) : i_lowguid(lowguid) {} - bool operator()(Creature* u) - { - return u->GetDBTableGUIDLow() == i_lowguid; - } - private: - uint32 i_lowguid; - }; - class AnyFriendlyUnitInObjectRangeCheck { public: @@ -1402,21 +1378,21 @@ namespace acore class ObjectGUIDCheck { public: - ObjectGUIDCheck(uint64 GUID, bool equals) : _GUID(GUID), _equals(equals) {} + ObjectGUIDCheck(ObjectGuid GUID, bool equals) : _GUID(GUID), _equals(equals) {} bool operator()(WorldObject const* object) { return (object->GetGUID() == _GUID) == _equals; } private: - uint64 _GUID; + ObjectGuid _GUID; bool _equals; }; class UnitAuraCheck { public: - UnitAuraCheck(bool present, uint32 spellId, uint64 casterGUID = 0) : _present(present), _spellId(spellId), _casterGUID(casterGUID) {} + UnitAuraCheck(bool present, uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty) : _present(present), _spellId(spellId), _casterGUID(casterGUID) {} bool operator()(Unit const* unit) const { return unit->HasAura(_spellId, _casterGUID) == _present; @@ -1430,7 +1406,7 @@ namespace acore private: bool _present; uint32 _spellId; - uint64 _casterGUID; + ObjectGuid _casterGUID; }; class AllWorldObjectsInExactRange diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index d69f8d1fc1..dc2b3dbb19 100644 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -23,7 +23,7 @@ class ObjectWorldLoader { public: explicit ObjectWorldLoader(ObjectGridLoader& gloader) - : i_cell(gloader.i_cell), i_map(gloader.i_map), i_grid(gloader.i_grid), i_corpses (0) + : i_cell(gloader.i_cell), i_map(gloader.i_map), i_grid(gloader.i_grid), i_corpses(gloader.i_corpses) {} void Visit(CorpseMapType& m); @@ -33,9 +33,9 @@ public: private: Cell i_cell; Map* i_map; -public: NGridType& i_grid; - uint32 i_corpses; +public: + uint32& i_corpses; }; template<class T> void ObjectGridLoader::SetObjectCell(T* /*obj*/, CellCoord const& /*cellCoord*/) @@ -93,7 +93,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord& cell, GridRefManager<T>& for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid) { T* obj = new T; - uint32 guid = *i_guid; + ObjectGuid::LowType guid = *i_guid; //LOG_INFO("server", "DEBUG: LoadHelper from table: %s for (guid: %u) Loading", table, guid); if (!obj->LoadFromDB(guid, map)) { @@ -110,7 +110,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord& cell, GridRefManager<Gam { for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid) { - uint32 guid = *i_guid; + ObjectGuid::LowType guid = *i_guid; GameObjectData const* data = sObjectMgr->GetGOData(guid); GameObject* obj = data && sObjectMgr->IsGameObjectStaticTransport(data->id) ? new StaticTransport() : new GameObject(); //LOG_INFO("server", "DEBUG: LoadHelper from table: %s for (guid: %u) Loading", table, guid); @@ -124,38 +124,6 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord& cell, GridRefManager<Gam } } -void LoadHelper(CellCorpseSet const& cell_corpses, CellCoord& cell, CorpseMapType& m, uint32& count, Map* map) -{ - if (cell_corpses.empty()) - return; - - for (CellCorpseSet::const_iterator itr = cell_corpses.begin(); itr != cell_corpses.end(); ++itr) - { - if (itr->second != map->GetInstanceId()) - continue; - - uint32 player_guid = itr->first; - - Corpse* obj = sObjectAccessor->GetCorpseForPlayerGUID(player_guid); - if (!obj) - continue; - - // TODO: this is a hack - // corpse's map should be reset when the map is unloaded - // but it may still exist when the grid is unloaded but map is not - // in that case map == currMap - obj->SetMap(map); - - if (obj->IsInGrid()) - { - obj->AddToWorld(); - continue; - } - - AddObjectHelper(cell, m, count, map, obj); - } -} - void ObjectGridLoader::Visit(GameObjectMapType& m) { CellCoord cellCoord = i_cell.GetCellCoord(); @@ -170,12 +138,23 @@ void ObjectGridLoader::Visit(CreatureMapType& m) LoadHelper(cell_guids.creatures, cellCoord, m, i_creatures, i_map); } -void ObjectWorldLoader::Visit(CorpseMapType& m) +void ObjectWorldLoader::Visit(CorpseMapType& /*m*/) { CellCoord cellCoord = i_cell.GetCellCoord(); - // corpses are always added to spawn mode 0 and they are spawned by their instance id - CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), 0, cellCoord.GetId()); - LoadHelper(cell_guids.corpses, cellCoord, m, i_corpses, i_map); + if (std::unordered_set<Corpse*> const* corpses = i_map->GetCorpsesInCell(cellCoord.GetId())) + { + for (Corpse* corpse : *corpses) + { + corpse->AddToWorld(); + GridType& cell = i_grid.GetGridType(i_cell.CellX(), i_cell.CellY()); + if (corpse->IsWorldObject()) + cell.AddWorldObject(corpse); + else + cell.AddGridObject(corpse); + + ++i_corpses; + } + } } void ObjectGridLoader::LoadN(void) @@ -184,10 +163,10 @@ void ObjectGridLoader::LoadN(void) i_creatures = 0; i_corpses = 0; i_cell.data.Part.cell_y = 0; - for (unsigned int x = 0; x < MAX_NUMBER_OF_CELLS; ++x) + for (uint32 x = 0; x < MAX_NUMBER_OF_CELLS; ++x) { i_cell.data.Part.cell_x = x; - for (unsigned int y = 0; y < MAX_NUMBER_OF_CELLS; ++y) + for (uint32 y = 0; y < MAX_NUMBER_OF_CELLS; ++y) { i_cell.data.Part.cell_y = y; @@ -202,7 +181,6 @@ void ObjectGridLoader::LoadN(void) ObjectWorldLoader worker(*this); TypeContainerVisitor<ObjectWorldLoader, WorldTypeMapContainer> visitor(worker); i_grid.VisitGrid(x, y, visitor); - i_corpses += worker.i_corpses; } } } @@ -240,7 +218,7 @@ void ObjectGridCleaner::Visit(GridRefManager<T>& m) template void ObjectGridUnloader::Visit(CreatureMapType&); template void ObjectGridUnloader::Visit(GameObjectMapType&); template void ObjectGridUnloader::Visit(DynamicObjectMapType&); -template void ObjectGridUnloader::Visit(CorpseMapType&); + template void ObjectGridCleaner::Visit(CreatureMapType&); template void ObjectGridCleaner::Visit<GameObject>(GameObjectMapType&); template void ObjectGridCleaner::Visit<DynamicObject>(DynamicObjectMapType&); diff --git a/src/server/game/Grids/ObjectGridLoader.h b/src/server/game/Grids/ObjectGridLoader.h index a55825f19a..6deb7707be 100644 --- a/src/server/game/Grids/ObjectGridLoader.h +++ b/src/server/game/Grids/ObjectGridLoader.h @@ -53,6 +53,7 @@ public: class ObjectGridUnloader { public: + void Visit(CorpseMapType&) { } // corpses are deleted with Map template<class T> void Visit(GridRefManager<T>& m); }; #endif diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index f9ef31010a..bc4f39d9ac 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -30,7 +30,7 @@ #include "WorldPacket.h" #include "WorldSession.h" -Roll::Roll(uint64 _guid, LootItem const& li) : itemGUID(_guid), itemid(li.itemid), +Roll::Roll(ObjectGuid _guid, LootItem const& li) : itemGUID(_guid), itemid(li.itemid), itemRandomPropId(li.randomPropertyId), itemRandomSuffix(li.randomSuffix), itemCount(li.count), totalPlayersRolling(0), totalNeed(0), totalGreed(0), totalPass(0), itemSlot(0), rollVoteMask(ROLL_ALL_TYPE_NO_DISENCHANT) @@ -51,15 +51,13 @@ Loot* Roll::getLoot() return getTarget(); } -Group::Group() : m_leaderGuid(0), m_leaderName(""), m_groupType(GROUPTYPE_NORMAL), +Group::Group() : m_leaderName(""), m_groupType(GROUPTYPE_NORMAL), m_dungeonDifficulty(DUNGEON_DIFFICULTY_NORMAL), m_raidDifficulty(RAID_DIFFICULTY_10MAN_NORMAL), - m_bfGroup(nullptr), m_bgGroup(nullptr), m_lootMethod(FREE_FOR_ALL), m_lootThreshold(ITEM_QUALITY_UNCOMMON), m_looterGuid(0), - m_masterLooterGuid(0), m_subGroupsCounts(nullptr), m_guid(0), m_counter(0), m_maxEnchantingLevel(0), _difficultyChangePreventionTime(0), + m_bfGroup(nullptr), m_bgGroup(nullptr), m_lootMethod(FREE_FOR_ALL), m_lootThreshold(ITEM_QUALITY_UNCOMMON), + m_subGroupsCounts(nullptr), m_counter(0), m_maxEnchantingLevel(0), _difficultyChangePreventionTime(0), _difficultyChangePreventionType(DIFFICULTY_PREVENTION_CHANGE_NONE) { - for (uint8 i = 0; i < TARGETICONCOUNT; ++i) - m_targetIcons[i] = 0; - sScriptMgr->OnConstructGroup(this); + sScriptMgr->OnConstructGroup(this); } Group::~Group() @@ -90,10 +88,10 @@ Group::~Group() bool Group::Create(Player* leader) { - uint64 leaderGuid = leader->GetGUID(); - uint32 lowguid = sGroupMgr->GenerateGroupId(); + ObjectGuid leaderGuid = leader->GetGUID(); + ObjectGuid::LowType lowguid = sGroupMgr->GenerateGroupId(); - m_guid = MAKE_NEW_GUID(lowguid, 0, HIGHGUID_GROUP); + m_guid = ObjectGuid::Create<HighGuid::Group>(lowguid); m_leaderGuid = leaderGuid; m_leaderName = leader->GetName(); leader->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GROUP_LEADER); @@ -109,7 +107,7 @@ bool Group::Create(Player* leader) m_lootThreshold = ITEM_QUALITY_UNCOMMON; m_looterGuid = leaderGuid; - m_masterLooterGuid = 0; + m_masterLooterGuid.Clear(); m_dungeonDifficulty = DUNGEON_DIFFICULTY_NORMAL; m_raidDifficulty = RAID_DIFFICULTY_10MAN_NORMAL; @@ -125,22 +123,22 @@ bool Group::Create(Player* leader) uint8 index = 0; stmt->setUInt32(index++, lowguid); - stmt->setUInt32(index++, GUID_LOPART(m_leaderGuid)); + stmt->setUInt32(index++, m_leaderGuid.GetCounter()); stmt->setUInt8(index++, uint8(m_lootMethod)); - stmt->setUInt32(index++, GUID_LOPART(m_looterGuid)); + stmt->setUInt32(index++, m_looterGuid.GetCounter()); stmt->setUInt8(index++, uint8(m_lootThreshold)); - stmt->setUInt32(index++, uint32(m_targetIcons[0])); - stmt->setUInt32(index++, uint32(m_targetIcons[1])); - stmt->setUInt32(index++, uint32(m_targetIcons[2])); - stmt->setUInt32(index++, uint32(m_targetIcons[3])); - stmt->setUInt32(index++, uint32(m_targetIcons[4])); - stmt->setUInt32(index++, uint32(m_targetIcons[5])); - stmt->setUInt32(index++, uint32(m_targetIcons[6])); - stmt->setUInt32(index++, uint32(m_targetIcons[7])); + 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->setUInt8(index++, uint8(m_groupType)); stmt->setUInt32(index++, uint8(m_dungeonDifficulty)); stmt->setUInt32(index++, uint8(m_raidDifficulty)); - stmt->setUInt32(index++, GUID_LOPART(m_masterLooterGuid)); + stmt->setUInt32(index++, m_masterLooterGuid.GetCounter()); CharacterDatabase.Execute(stmt); @@ -156,13 +154,14 @@ bool Group::Create(Player* leader) bool Group::LoadGroupFromDB(Field* fields) { - m_guid = MAKE_NEW_GUID(fields[16].GetUInt32(), 0, HIGHGUID_GROUP); - m_leaderGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); + ObjectGuid::LowType groupLowGuid = fields[16].GetUInt32(); + m_guid = ObjectGuid::Create<HighGuid::Group>(groupLowGuid); + + m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()); // group leader not exist if (!sObjectMgr->GetPlayerNameByGUID(fields[0].GetUInt32(), m_leaderName)) { - uint32 groupLowGuid = fields[16].GetUInt32(); SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP); stmt->setUInt32(0, groupLowGuid); @@ -178,11 +177,11 @@ bool Group::LoadGroupFromDB(Field* fields) } m_lootMethod = LootMethod(fields[1].GetUInt8()); - m_looterGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER); + m_looterGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32()); m_lootThreshold = ItemQualities(fields[3].GetUInt8()); for (uint8 i = 0; i < TARGETICONCOUNT; ++i) - m_targetIcons[i] = fields[4 + i].GetUInt32(); + m_targetIcons[i].Set(fields[4 + i].GetUInt64()); m_groupType = GroupType(fields[12].GetUInt8()); if (m_groupType & GROUPTYPE_RAID) @@ -200,7 +199,7 @@ bool Group::LoadGroupFromDB(Field* fields) else m_raidDifficulty = Difficulty(r_diff); - m_masterLooterGuid = MAKE_NEW_GUID(fields[15].GetUInt32(), 0, HIGHGUID_PLAYER); + m_masterLooterGuid = ObjectGuid::Create<HighGuid::Player>(fields[15].GetUInt32()); if (m_groupType & GROUPTYPE_LFG) sLFGMgr->_LoadFromDB(fields, GetGUID()); @@ -208,17 +207,17 @@ bool Group::LoadGroupFromDB(Field* fields) return true; } -void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles) +void Group::LoadMemberFromDB(ObjectGuid::LowType guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles) { MemberSlot member; - member.guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER); + member.guid = ObjectGuid::Create<HighGuid::Player>(guidLow); // skip non-existed member - if (!sObjectMgr->GetPlayerNameByGUID(member.guid, member.name)) + if (!sObjectMgr->GetPlayerNameByGUID(member.guid.GetCounter(), member.name)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER); stmt->setUInt32(0, guidLow); - stmt->setUInt32(1, GetLowGUID()); + stmt->setUInt32(1, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); return; } @@ -229,7 +228,7 @@ void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, m_memberSlots.push_back(member); if (!isBGGroup() && !isBFGroup()) - sWorld->UpdateGlobalPlayerGroup(guidLow, GetLowGUID()); + sWorld->UpdateGlobalPlayerGroup(guidLow, GetGUID().GetCounter()); SubGroupCounterIncrease(subgroup); @@ -245,7 +244,7 @@ void Group::ConvertToLFG() PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_TYPE); stmt->setUInt8(0, uint8(m_groupType)); - stmt->setUInt32(1, GetLowGUID()); + stmt->setUInt32(1, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -264,7 +263,7 @@ void Group::ConvertToRaid() PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_TYPE); stmt->setUInt8(0, uint8(m_groupType)); - stmt->setUInt32(1, GetLowGUID()); + stmt->setUInt32(1, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -331,7 +330,7 @@ void Group::RemoveAllInvites() m_invitees.clear(); } -Player* Group::GetInvited(uint64 guid) const +Player* Group::GetInvited(ObjectGuid guid) const { for (InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr) { @@ -382,7 +381,7 @@ bool Group::AddMember(Player* player) member.roles = 0; m_memberSlots.push_back(member); if (!isBGGroup() && !isBFGroup()) - sWorld->UpdateGlobalPlayerGroup(player->GetGUIDLow(), GetLowGUID()); + sWorld->UpdateGlobalPlayerGroup(player->GetGUID().GetCounter(), GetGUID().GetCounter()); SubGroupCounterIncrease(subGroup); @@ -403,14 +402,14 @@ bool Group::AddMember(Player* player) if (!isRaidGroup()) // reset targetIcons for non-raid-groups { for (uint8 i = 0; i < TARGETICONCOUNT; ++i) - m_targetIcons[i] = 0; + m_targetIcons[i].Clear(); } if (!isBGGroup() && !isBFGroup()) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GROUP_MEMBER); - stmt->setUInt32(0, GetLowGUID()); - stmt->setUInt32(1, GUID_LOPART(member.guid)); + stmt->setUInt32(0, GetGUID().GetCounter()); + stmt->setUInt32(1, member.guid.GetCounter()); stmt->setUInt8(2, member.flags); stmt->setUInt8(3, member.group); stmt->setUInt8(4, member.roles); @@ -425,7 +424,7 @@ bool Group::AddMember(Player* player) if (!IsLeader(player->GetGUID()) && !isBGGroup() && !isBFGroup()) { - Player::ResetInstances(player->GetGUIDLow(), INSTANCE_RESET_GROUP_JOIN, false); + Player::ResetInstances(player->GetGUID(), INSTANCE_RESET_GROUP_JOIN, false); if (player->GetDungeonDifficulty() != GetDungeonDifficulty()) { @@ -440,7 +439,7 @@ bool Group::AddMember(Player* player) } else if (IsLeader(player->GetGUID()) && isLFGGroup()) // pussywizard { - Player::ResetInstances(player->GetGUIDLow(), INSTANCE_RESET_GROUP_JOIN, false); + Player::ResetInstances(player->GetGUID(), INSTANCE_RESET_GROUP_JOIN, false); } player->SetGroupUpdateFlag(GROUP_UPDATE_FULL); @@ -502,7 +501,7 @@ bool Group::AddMember(Player* player) return true; } -bool Group::RemoveMember(uint64 guid, const RemoveMethod& method /*= GROUP_REMOVEMETHOD_DEFAULT*/, uint64 kicker /*= 0*/, const char* reason /*= nullptr*/) +bool Group::RemoveMember(ObjectGuid guid, const RemoveMethod& method /*= GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /*= ObjectGuid::Empty*/, const char* reason /*= nullptr*/) { BroadcastGroupUpdate(); @@ -516,7 +515,7 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod& method /*= GROUP_REMOV // remove member and change leader (if need) only if strong more 2 members _before_ member remove (BG/BF allow 1 member group) if (GetMembersCount() > ((isBGGroup() || isLFGGroup() || isBFGroup()) ? 1u : 2u)) { - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* player = ObjectAccessor::FindConnectedPlayer(guid); if (player) { // Battleground group handling @@ -545,7 +544,7 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod& method /*= GROUP_REMOV // Do we really need to send this opcode? data.Initialize(SMSG_GROUP_LIST, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 8); data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0); - data << uint64(m_guid) << uint32(m_counter) << uint32(0) << uint64(0); + data << m_guid << uint32(m_counter) << uint32(0) << uint64(0); player->GetSession()->SendPacket(&data); } @@ -553,8 +552,8 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod& method /*= GROUP_REMOV if (!isBGGroup() && !isBFGroup()) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER); - stmt->setUInt32(0, GUID_LOPART(guid)); - stmt->setUInt32(1, GetLowGUID()); + stmt->setUInt32(0, guid.GetCounter()); + stmt->setUInt32(1, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -600,7 +599,7 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod& method /*= GROUP_REMOV SubGroupCounterDecrease(slot->group); m_memberSlots.erase(slot); if (!isBGGroup() && !isBFGroup()) - sWorld->UpdateGlobalPlayerGroup(GUID_LOPART(guid), 0); + sWorld->UpdateGlobalPlayerGroup(guid.GetCounter(), 0); } // Pick new leader if necessary @@ -610,7 +609,7 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod& method /*= GROUP_REMOV validLeader = false; for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) { - if (ObjectAccessor::FindPlayerInOrOutOfWorld(itr->guid)) + if (ObjectAccessor::FindConnectedPlayer(itr->guid)) { ChangeLeader(itr->guid); validLeader = true; @@ -636,7 +635,7 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod& method /*= GROUP_REMOV if (isLFGGroup() && GetMembersCount() == 1) { - Player* leader = ObjectAccessor::FindPlayerInOrOutOfWorld(GetLeaderGUID()); + Player* leader = ObjectAccessor::FindConnectedPlayer(GetLeaderGUID()); uint32 mapId = sLFGMgr->GetDungeonMapId(GetGUID()); lfg::LfgState state = sLFGMgr->GetState(GetGUID()); if (!mapId || !leader || (leader->IsAlive() && leader->GetMapId() != mapId) || state == lfg::LFG_STATE_NONE) @@ -663,14 +662,14 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod& method /*= GROUP_REMOV } } -void Group::ChangeLeader(uint64 newLeaderGuid) +void Group::ChangeLeader(ObjectGuid newLeaderGuid) { member_witerator slot = _getMemberWSlot(newLeaderGuid); if (slot == m_memberSlots.end()) return; - Player* newLeader = ObjectAccessor::FindPlayerInOrOutOfWorld(slot->guid); + Player* newLeader = ObjectAccessor::FindConnectedPlayer(slot->guid); // Don't allow switching leader to offline players if (!newLeader) @@ -681,15 +680,15 @@ void Group::ChangeLeader(uint64 newLeaderGuid) SQLTransaction trans = CharacterDatabase.BeginTransaction(); // Update the group leader PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_LEADER); - stmt->setUInt32(0, newLeader->GetGUIDLow()); - stmt->setUInt32(1, GetLowGUID()); + stmt->setUInt32(0, newLeader->GetGUID().GetCounter()); + stmt->setUInt32(1, GetGUID().GetCounter()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); sInstanceSaveMgr->CopyBinds(m_leaderGuid, newLeaderGuid, newLeader); } - if (Player* oldLeader = ObjectAccessor::FindPlayerInOrOutOfWorld(m_leaderGuid)) + if (Player* oldLeader = ObjectAccessor::FindConnectedPlayer(m_leaderGuid)) oldLeader->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GROUP_LEADER); newLeader->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GROUP_LEADER); @@ -712,9 +711,9 @@ void Group::Disband(bool hideDestroy /* = false */) for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) { if (!isBGGroup() && !isBFGroup()) - sWorld->UpdateGlobalPlayerGroup(GUID_LOPART(citr->guid), 0); + sWorld->UpdateGlobalPlayerGroup(citr->guid.GetCounter(), 0); - player = ObjectAccessor::FindPlayerInOrOutOfWorld(citr->guid); + player = ObjectAccessor::FindConnectedPlayer(citr->guid); _homebindIfInstance(player); if (!isBGGroup() && !isBFGroup()) @@ -756,7 +755,7 @@ void Group::Disband(bool hideDestroy /* = false */) { data.Initialize(SMSG_GROUP_LIST, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 8); data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0); - data << uint64(m_guid) << uint32(m_counter) << uint32(0) << uint64(0); + data << m_guid << uint32(m_counter) << uint32(0) << uint64(0); player->GetSession()->SendPacket(&data); } } @@ -770,17 +769,17 @@ void Group::Disband(bool hideDestroy /* = false */) SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP); - stmt->setUInt32(0, GetLowGUID()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER_ALL); - stmt->setUInt32(0, GetLowGUID()); + stmt->setUInt32(0, GetGUID().GetCounter()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA); - stmt->setUInt32(0, GetLowGUID()); + stmt->setUInt32(0, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -795,7 +794,7 @@ void Group::Disband(bool hideDestroy /* = false */) void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll& r) { WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1)); - data << uint64(r.itemGUID); // guid of rolled item + data << r.itemGUID; // guid of rolled item data << uint32(mapid); // 3.3.3 mapid data << uint32(r.itemSlot); // itemslot data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for @@ -807,7 +806,7 @@ void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll& r) for (Roll::PlayerVote::const_iterator itr = r.playerVote.begin(); itr != r.playerVote.end(); ++itr) { - Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->first); + Player* p = ObjectAccessor::FindConnectedPlayer(itr->first); if (!p) continue; @@ -822,7 +821,7 @@ void Group::SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player* p, return; WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1)); - data << uint64(r.itemGUID); // guid of rolled item + data << r.itemGUID; // guid of rolled item data << uint32(mapId); // 3.3.3 mapid data << uint32(r.itemSlot); // itemslot data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for @@ -838,12 +837,12 @@ void Group::SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player* p, p->GetSession()->SendPacket(&data); } -void Group::SendLootRoll(uint64 sourceGuid, uint64 targetGuid, uint8 rollNumber, uint8 rollType, Roll const& roll) +void Group::SendLootRoll(ObjectGuid sourceGuid, ObjectGuid targetGuid, uint8 rollNumber, uint8 rollType, Roll const& roll) { WorldPacket data(SMSG_LOOT_ROLL, (8 + 4 + 8 + 4 + 4 + 4 + 1 + 1 + 1)); - data << uint64(sourceGuid); // guid of the item rolled + data << sourceGuid; // guid of the item rolled data << uint32(roll.itemSlot); // slot - data << uint64(targetGuid); + data << targetGuid; data << uint32(roll.itemid); // the itemEntryId for the item that shall be rolled for data << uint32(roll.itemRandomSuffix); // randomSuffix data << uint32(roll.itemRandomPropId); // Item random property ID @@ -853,7 +852,7 @@ void Group::SendLootRoll(uint64 sourceGuid, uint64 targetGuid, uint8 rollNumber, for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr) { - Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->first); + Player* p = ObjectAccessor::FindConnectedPlayer(itr->first); if (!p) continue; @@ -862,21 +861,21 @@ void Group::SendLootRoll(uint64 sourceGuid, uint64 targetGuid, uint8 rollNumber, } } -void Group::SendLootRollWon(uint64 sourceGuid, uint64 targetGuid, uint8 rollNumber, uint8 rollType, Roll const& roll) +void Group::SendLootRollWon(ObjectGuid sourceGuid, ObjectGuid targetGuid, uint8 rollNumber, uint8 rollType, Roll const& roll) { WorldPacket data(SMSG_LOOT_ROLL_WON, (8 + 4 + 4 + 4 + 4 + 8 + 1 + 1)); - data << uint64(sourceGuid); // guid of the item rolled + data << sourceGuid; // guid of the item rolled data << uint32(roll.itemSlot); // slot data << uint32(roll.itemid); // the itemEntryId for the item that shall be rolled for data << uint32(roll.itemRandomSuffix); // randomSuffix data << uint32(roll.itemRandomPropId); // Item random property - data << uint64(targetGuid); // guid of the player who won. + data << targetGuid; // guid of the player who won. data << uint8(rollNumber); // rollnumber realted to SMSG_LOOT_ROLL data << uint8(rollType); // rollType related to SMSG_LOOT_ROLL for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr) { - Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->first); + Player* p = ObjectAccessor::FindConnectedPlayer(itr->first); if (!p) continue; @@ -888,7 +887,7 @@ void Group::SendLootRollWon(uint64 sourceGuid, uint64 targetGuid, uint8 rollNumb void Group::SendLootAllPassed(Roll const& roll) { WorldPacket data(SMSG_LOOT_ALL_PASSED, (8 + 4 + 4 + 4 + 4)); - data << uint64(roll.itemGUID); // Guid of the item rolled + data << roll.itemGUID; // Guid of the item rolled data << uint32(roll.itemSlot); // Item loot slot data << uint32(roll.itemid); // The itemEntryId for the item that shall be rolled for data << uint32(roll.itemRandomPropId); // Item random property ID @@ -896,7 +895,7 @@ void Group::SendLootAllPassed(Roll const& roll) for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr) { - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->first); + Player* player = ObjectAccessor::FindConnectedPlayer(itr->first); if (!player) continue; @@ -911,15 +910,15 @@ void Group::SendLooter(Creature* creature, Player* groupLooter) ASSERT(creature); WorldPacket data(SMSG_LOOT_LIST, (8 + 8)); - data << uint64(creature->GetGUID()); + data << creature->GetGUID(); if (GetLootMethod() == MASTER_LOOT && creature->loot.hasOverThresholdItem()) - data.appendPackGUID(GetMasterLooterGuid()); + data << GetMasterLooterGuid().WriteAsPacked(); else data << uint8(0); if (groupLooter) - data.append(groupLooter->GetPackGUID()); + data << groupLooter->GetPackGUID(); else data << uint8(0); @@ -943,10 +942,10 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject) continue; } - //roll for over-threshold item if it's one-player loot + // roll for over-threshold item if it's one-player loot if (item->Quality >= uint32(m_lootThreshold)) { - uint64 newitemGUID = MAKE_NEW_GUID(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), 0, HIGHGUID_ITEM); + ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate()); Roll* r = new Roll(newitemGUID, *i); //a vector is filled with only near party members @@ -1003,12 +1002,12 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject) if (Creature* creature = pLootedObject->ToCreature()) { creature->m_groupLootTimer = 60000; - creature->lootingGroupLowGUID = GetLowGUID(); + creature->lootingGroupLowGUID = GetGUID().GetCounter(); } else if (GameObject* go = pLootedObject->ToGameObject()) { go->m_groupLootTimer = 60000; - go->lootingGroupLowGUID = GetLowGUID(); + go->lootingGroupLowGUID = GetGUID().GetCounter(); } } else @@ -1029,7 +1028,7 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject) continue; } - uint64 newitemGUID = MAKE_NEW_GUID(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), 0, HIGHGUID_ITEM); + ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate()); Roll* r = new Roll(newitemGUID, *i); //a vector is filled with only near party members @@ -1063,12 +1062,12 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject) if (Creature* creature = pLootedObject->ToCreature()) { creature->m_groupLootTimer = 60000; - creature->lootingGroupLowGUID = GetLowGUID(); + creature->lootingGroupLowGUID = GetGUID().GetCounter(); } else if (GameObject* go = pLootedObject->ToGameObject()) { go->m_groupLootTimer = 60000; - go->lootingGroupLowGUID = GetLowGUID(); + go->lootingGroupLowGUID = GetGUID().GetCounter(); } } else @@ -1090,7 +1089,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject) //roll for over-threshold item if it's one-player loot if (item->Quality >= uint32(m_lootThreshold)) { - uint64 newitemGUID = MAKE_NEW_GUID(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), 0, HIGHGUID_ITEM); + ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate()); Roll* r = new Roll(newitemGUID, *i); for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) @@ -1143,12 +1142,12 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject) if (Creature* creature = lootedObject->ToCreature()) { creature->m_groupLootTimer = 60000; - creature->lootingGroupLowGUID = GetLowGUID(); + creature->lootingGroupLowGUID = GetGUID().GetCounter(); } else if (GameObject* go = lootedObject->ToGameObject()) { go->m_groupLootTimer = 60000; - go->lootingGroupLowGUID = GetLowGUID(); + go->lootingGroupLowGUID = GetGUID().GetCounter(); } } else @@ -1164,7 +1163,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject) continue; item = sObjectMgr->GetItemTemplate(i->itemid); - uint64 newitemGUID = MAKE_NEW_GUID(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), 0, HIGHGUID_ITEM); + ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate()); Roll* r = new Roll(newitemGUID, *i); for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) @@ -1205,12 +1204,12 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject) if (Creature* creature = lootedObject->ToCreature()) { creature->m_groupLootTimer = 60000; - creature->lootingGroupLowGUID = GetLowGUID(); + creature->lootingGroupLowGUID = GetGUID().GetCounter(); } else if (GameObject* go = lootedObject->ToGameObject()) { go->m_groupLootTimer = 60000; - go->lootingGroupLowGUID = GetLowGUID(); + go->lootingGroupLowGUID = GetGUID().GetCounter(); } } else @@ -1253,7 +1252,7 @@ void Group::MasterLoot(Loot* loot, WorldObject* pLootedObject) if (looter->IsAtGroupRewardDistance(pLootedObject)) { - data << uint64(looter->GetGUID()); + data << looter->GetGUID(); ++real_count; } } @@ -1268,7 +1267,7 @@ void Group::MasterLoot(Loot* loot, WorldObject* pLootedObject) } } -bool Group::CountRollVote(uint64 playerGUID, uint64 Guid, uint8 Choice) +bool Group::CountRollVote(ObjectGuid playerGUID, ObjectGuid Guid, uint8 Choice) { Rolls::iterator rollI = GetRoll(Guid); if (rollI == RollId.end()) @@ -1289,22 +1288,22 @@ bool Group::CountRollVote(uint64 playerGUID, uint64 Guid, uint8 Choice) switch (Choice) { case ROLL_PASS: // Player choose pass - SendLootRoll(0, playerGUID, 128, ROLL_PASS, *roll); + SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_PASS, *roll); ++roll->totalPass; itr->second = PASS; break; case ROLL_NEED: // player choose Need - SendLootRoll(0, playerGUID, 0, 0, *roll); + SendLootRoll(ObjectGuid::Empty, playerGUID, 0, 0, *roll); ++roll->totalNeed; itr->second = NEED; break; case ROLL_GREED: // player choose Greed - SendLootRoll(0, playerGUID, 128, ROLL_GREED, *roll); + SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_GREED, *roll); ++roll->totalGreed; itr->second = GREED; break; case ROLL_DISENCHANT: // player choose Disenchant - SendLootRoll(0, playerGUID, 128, ROLL_DISENCHANT, *roll); + SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_DISENCHANT, *roll); ++roll->totalGreed; itr->second = DISENCHANT; break; @@ -1349,7 +1348,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) if (!roll->playerVote.empty()) { uint8 maxresul = 0; - uint64 maxguid = 0; // pussywizard: start with 0 >_> + ObjectGuid maxguid; // pussywizard: start with 0 >_> Player* player = nullptr; for (Roll::PlayerVote::const_iterator itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr) @@ -1365,7 +1364,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) } uint8 randomN = urand(1, 100); - SendLootRoll(0, itr->first, randomN, ROLL_NEED, *roll); + SendLootRoll(ObjectGuid::Empty, itr->first, randomN, ROLL_NEED, *roll); if (maxresul < randomN) { maxguid = itr->first; @@ -1375,7 +1374,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) if (maxguid) // pussywizard: added condition { - SendLootRollWon(0, maxguid, maxresul, ROLL_NEED, *roll); + SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, ROLL_NEED, *roll); player = ObjectAccessor::FindPlayer(maxguid); if (player) @@ -1411,7 +1410,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) if (!roll->playerVote.empty()) { uint8 maxresul = 0; - uint64 maxguid = 0; // pussywizard: start with 0 + ObjectGuid maxguid; // pussywizard: start with 0 Player* player = nullptr; RollVote rollvote = NOT_VALID; @@ -1429,7 +1428,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) } uint8 randomN = urand(1, 100); - SendLootRoll(0, itr->first, randomN, itr->second, *roll); + SendLootRoll(ObjectGuid::Empty, itr->first, randomN, itr->second, *roll); if (maxresul < randomN) { maxguid = itr->first; @@ -1440,7 +1439,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) if (maxguid) // pussywizard: added condition { - SendLootRollWon(0, maxguid, maxresul, rollvote, *roll); + SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, rollvote, *roll); player = ObjectAccessor::FindPlayer(maxguid); if (player) @@ -1498,24 +1497,24 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) delete roll; } -void Group::SetTargetIcon(uint8 id, uint64 whoGuid, uint64 targetGuid) +void Group::SetTargetIcon(uint8 id, ObjectGuid whoGuid, ObjectGuid targetGuid) { if (id >= TARGETICONCOUNT) return; // clean other icons - if (targetGuid != 0) + if (targetGuid) for (int i = 0; i < TARGETICONCOUNT; ++i) if (m_targetIcons[i] == targetGuid) - SetTargetIcon(i, 0, 0); + SetTargetIcon(i, ObjectGuid::Empty, ObjectGuid::Empty); m_targetIcons[id] = targetGuid; WorldPacket data(MSG_RAID_TARGET_UPDATE, (1 + 8 + 1 + 8)); data << uint8(0); // set targets - data << uint64(whoGuid); + data << whoGuid; data << uint8(id); - data << uint64(targetGuid); + data << targetGuid; BroadcastPacket(&data, true); } @@ -1529,11 +1528,11 @@ void Group::SendTargetIconList(WorldSession* session) for (uint8 i = 0; i < TARGETICONCOUNT; ++i) { - if (m_targetIcons[i] == 0) + if (!m_targetIcons[i]) continue; data << uint8(i); - data << uint64(m_targetIcons[i]); + data << m_targetIcons[i]; } session->SendPacket(&data); @@ -1545,9 +1544,9 @@ void Group::SendUpdate() SendUpdateToPlayer(witr->guid, &(*witr)); } -void Group::SendUpdateToPlayer(uint64 playerGUID, MemberSlot* slot) +void Group::SendUpdateToPlayer(ObjectGuid playerGUID, MemberSlot* slot) { - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(playerGUID); + Player* player = ObjectAccessor::FindConnectedPlayer(playerGUID); if (!player || player->GetGroup() != this) return; @@ -1574,7 +1573,7 @@ void Group::SendUpdateToPlayer(uint64 playerGUID, MemberSlot* slot) data << uint32(sLFGMgr->GetDungeon(m_guid)); } - data << uint64(m_guid); + data << m_guid; data << uint32(m_counter++); // 3.3, value increases every time this packet gets sent data << uint32(GetMembersCount() - 1); for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) @@ -1582,27 +1581,27 @@ void Group::SendUpdateToPlayer(uint64 playerGUID, MemberSlot* slot) if (slot->guid == citr->guid) continue; - Player* member = ObjectAccessor::FindPlayerInOrOutOfWorld(citr->guid); + Player* member = ObjectAccessor::FindConnectedPlayer(citr->guid); uint8 onlineState = (member && !member->GetSession()->PlayerLogout()) ? MEMBER_STATUS_ONLINE : MEMBER_STATUS_OFFLINE; onlineState = onlineState | ((isBGGroup() || isBFGroup()) ? MEMBER_STATUS_PVP : 0); data << citr->name; - data << uint64(citr->guid); // guid + data << citr->guid; // guid data << uint8(onlineState); // online-state data << uint8(citr->group); // groupid data << uint8(citr->flags); // See enum GroupMemberFlags data << uint8(citr->roles); // Lfg Roles } - data << uint64(m_leaderGuid); // leader guid + data << m_leaderGuid; // leader guid if (GetMembersCount() - 1) { data << uint8(m_lootMethod); // loot method if (m_lootMethod == MASTER_LOOT) - data << uint64(m_masterLooterGuid); // master looter guid + data << m_masterLooterGuid; // master looter guid else data << uint64(0); // looter guid @@ -1632,12 +1631,12 @@ void Group::UpdatePlayerOutOfRange(Player* player) } } -void Group::BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group, uint64 ignore) +void Group::BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group, ObjectGuid ignore) { for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* player = itr->GetSource(); - if (!player || (ignore != 0 && player->GetGUID() == ignore) || (ignorePlayersInBGRaid && player->GetGroup() != this)) + if (!player || (ignore && player->GetGUID() == ignore) || (ignorePlayersInBGRaid && player->GetGroup() != this)) continue; if (group == -1 || itr->getSubGroup() == group) @@ -1660,11 +1659,11 @@ void Group::OfflineReadyCheck() { for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) { - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(citr->guid); + Player* player = ObjectAccessor::FindConnectedPlayer(citr->guid); if (!player) { WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9); - data << uint64(citr->guid); + data << citr->guid; data << uint8(0); BroadcastReadyCheck(&data); } @@ -1683,7 +1682,7 @@ bool Group::SameSubGroup(Player const* member1, Player const* member2) const } // Allows setting sub groups both for online or offline members -void Group::ChangeMembersGroup(uint64 guid, uint8 group) +void Group::ChangeMembersGroup(ObjectGuid guid, uint8 group) { // Only raid groups have sub groups if (!isRaidGroup()) @@ -1714,13 +1713,13 @@ void Group::ChangeMembersGroup(uint64 guid, uint8 group) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_MEMBER_SUBGROUP); stmt->setUInt8(0, group); - stmt->setUInt32(1, GUID_LOPART(guid)); + stmt->setUInt32(1, guid.GetCounter()); CharacterDatabase.Execute(stmt); } // In case the moved player is online, update the player object with the new sub group references - if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) { if (player->GetGroup() == this) player->GetGroupRef().setSubGroup(group); @@ -1750,7 +1749,7 @@ void Group::UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed) if (GetLootMethod() == FREE_FOR_ALL) return; - uint64 oldLooterGUID = GetLooterGuid(); + ObjectGuid oldLooterGUID = GetLooterGuid(); member_citerator guid_itr = _getMemberCSlot(oldLooterGUID); if (guid_itr != m_memberSlots.end()) { @@ -1800,7 +1799,7 @@ void Group::UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed) } else { - SetLooterGuid(0); + SetLooterGuid(ObjectGuid::Empty); SendUpdate(); } } @@ -1913,7 +1912,7 @@ void Group::SetDungeonDifficulty(Difficulty difficulty) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_DIFFICULTY); stmt->setUInt8(0, uint8(m_dungeonDifficulty)); - stmt->setUInt32(1, GetLowGUID()); + stmt->setUInt32(1, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -1934,7 +1933,7 @@ void Group::SetRaidDifficulty(Difficulty difficulty) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_RAID_DIFFICULTY); stmt->setUInt8(0, uint8(m_raidDifficulty)); - stmt->setUInt32(1, GetLowGUID()); + stmt->setUInt32(1, GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -1959,7 +1958,7 @@ void Group::ResetInstances(uint8 method, bool isRaid, Player* leader) if (leader->GetDifficulty(false) != DUNGEON_DIFFICULTY_NORMAL) break; std::vector<InstanceSave*> toUnbind; - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUIDLow(), Difficulty(DUNGEON_DIFFICULTY_NORMAL)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUID(), Difficulty(DUNGEON_DIFFICULTY_NORMAL)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { InstanceSave* instanceSave = itr->second.save; @@ -1983,7 +1982,7 @@ void Group::ResetInstances(uint8 method, bool isRaid, Player* leader) case INSTANCE_RESET_CHANGE_DIFFICULTY: { std::vector<InstanceSave*> toUnbind; - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUIDLow(), leader->GetDifficulty(isRaid)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUID(), leader->GetDifficulty(isRaid)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { InstanceSave* instanceSave = itr->second.save; @@ -2018,7 +2017,7 @@ void Group::_cancelHomebindIfInstance(Player* player) // if player is reinvited to group and in the instance - cancel homebind timer if (!player->FindMap() || !player->FindMap()->IsDungeon()) return; - InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(player->GetGUIDLow(), player->FindMap()->GetId(), player->GetDifficulty(player->FindMap()->IsRaid())); + InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(player->GetGUID(), player->FindMap()->GetId(), player->GetDifficulty(player->FindMap()->IsRaid())); if (bind && bind->save->GetInstanceId() == player->GetInstanceId()) player->m_InstanceValid = true; } @@ -2058,12 +2057,12 @@ void Group::SetLootMethod(LootMethod method) m_lootMethod = method; } -void Group::SetLooterGuid(uint64 guid) +void Group::SetLooterGuid(ObjectGuid guid) { m_looterGuid = guid; } -void Group::SetMasterLooterGuid(uint64 guid) +void Group::SetMasterLooterGuid(ObjectGuid guid) { m_masterLooterGuid = guid; } @@ -2073,7 +2072,7 @@ void Group::SetLootThreshold(ItemQualities threshold) m_lootThreshold = threshold; } -void Group::SetLfgRoles(uint64 guid, const uint8 roles) +void Group::SetLfgRoles(ObjectGuid guid, const uint8 roles) { member_witerator slot = _getMemberWSlot(guid); if (slot == m_memberSlots.end()) @@ -2113,21 +2112,16 @@ bool Group::IsCreated() const return GetMembersCount() > 0; } -uint64 Group::GetLeaderGUID() const +ObjectGuid Group::GetLeaderGUID() const { return m_leaderGuid; } -uint64 Group::GetGUID() const +ObjectGuid Group::GetGUID() const { return m_guid; } -uint32 Group::GetLowGUID() const -{ - return GUID_LOPART(m_guid); -} - const char* Group::GetLeaderName() const { return m_leaderName.c_str(); @@ -2138,12 +2132,12 @@ LootMethod Group::GetLootMethod() const return m_lootMethod; } -uint64 Group::GetLooterGuid() const +ObjectGuid Group::GetLooterGuid() const { return m_looterGuid; } -uint64 Group::GetMasterLooterGuid() const +ObjectGuid Group::GetMasterLooterGuid() const { return m_masterLooterGuid; } @@ -2153,25 +2147,26 @@ ItemQualities Group::GetLootThreshold() const return m_lootThreshold; } -bool Group::IsMember(uint64 guid) const +bool Group::IsMember(ObjectGuid guid) const { return _getMemberCSlot(guid) != m_memberSlots.end(); } -bool Group::IsLeader(uint64 guid) const +bool Group::IsLeader(ObjectGuid guid) const { return (GetLeaderGUID() == guid); } -uint64 Group::GetMemberGUID(const std::string& name) +ObjectGuid Group::GetMemberGUID(const std::string& name) { for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) if (itr->name == name) return itr->guid; - return 0; + + return ObjectGuid::Empty; } -bool Group::IsAssistant(uint64 guid) const +bool Group::IsAssistant(ObjectGuid guid) const { member_citerator mslot = _getMemberCSlot(guid); if (mslot == m_memberSlots.end()) @@ -2179,7 +2174,7 @@ bool Group::IsAssistant(uint64 guid) const return mslot->flags & MEMBER_FLAG_ASSISTANT; } -bool Group::SameSubGroup(uint64 guid1, uint64 guid2) const +bool Group::SameSubGroup(ObjectGuid guid1, ObjectGuid guid2) const { member_citerator mslot2 = _getMemberCSlot(guid2); if (mslot2 == m_memberSlots.end()) @@ -2187,7 +2182,7 @@ bool Group::SameSubGroup(uint64 guid1, uint64 guid2) const return SameSubGroup(guid1, &*mslot2); } -bool Group::SameSubGroup(uint64 guid1, MemberSlot const* slot2) const +bool Group::SameSubGroup(ObjectGuid guid1, MemberSlot const* slot2) const { member_citerator mslot1 = _getMemberCSlot(guid1); if (mslot1 == m_memberSlots.end() || !slot2) @@ -2200,7 +2195,7 @@ bool Group::HasFreeSlotSubGroup(uint8 subgroup) const return (m_subGroupsCounts && m_subGroupsCounts[subgroup] < MAXGROUPSIZE); } -uint8 Group::GetMemberGroup(uint64 guid) const +uint8 Group::GetMemberGroup(ObjectGuid guid) const { member_citerator mslot = _getMemberCSlot(guid); if (mslot == m_memberSlots.end()) @@ -2218,7 +2213,7 @@ void Group::SetBattlefieldGroup(Battlefield* bg) m_bfGroup = bg; } -void Group::SetGroupMemberFlag(uint64 guid, bool apply, GroupMemberFlags flag) +void Group::SetGroupMemberFlag(ObjectGuid guid, bool apply, GroupMemberFlags flag) { // Assistants, main assistants and main tanks are only available in raid groups if (!isRaidGroup()) @@ -2251,7 +2246,7 @@ void Group::SetGroupMemberFlag(uint64 guid, bool apply, GroupMemberFlags flag) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_MEMBER_FLAG); stmt->setUInt8(0, slot->flags); - stmt->setUInt32(1, GUID_LOPART(guid)); + stmt->setUInt32(1, guid.GetCounter()); CharacterDatabase.Execute(stmt); @@ -2279,7 +2274,7 @@ bool Group::isRollLootActive() const return !RollId.empty(); } -Group::Rolls::iterator Group::GetRoll(uint64 Guid) +Group::Rolls::iterator Group::GetRoll(ObjectGuid Guid) { Rolls::iterator iter; for (iter = RollId.begin(); iter != RollId.end(); ++iter) @@ -2305,7 +2300,7 @@ void Group::_initRaidSubGroupsCounter() ++m_subGroupsCounts[itr->group]; } -Group::member_citerator Group::_getMemberCSlot(uint64 Guid) const +Group::member_citerator Group::_getMemberCSlot(ObjectGuid Guid) const { for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) if (itr->guid == Guid) @@ -2313,7 +2308,7 @@ Group::member_citerator Group::_getMemberCSlot(uint64 Guid) const return m_memberSlots.end(); } -Group::member_witerator Group::_getMemberWSlot(uint64 Guid) +Group::member_witerator Group::_getMemberWSlot(ObjectGuid Guid) { for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) if (itr->guid == Guid) diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index bdd8e00708..59515bdf1f 100644 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -129,18 +129,18 @@ static const uint8 GroupUpdateLength[GROUP_UPDATE_FLAGS_COUNT] = { 0, 2, 2, 2, 1 class Roll : public LootValidatorRef { public: - Roll(uint64 _guid, LootItem const& li); + Roll(ObjectGuid _guid, LootItem const& li); ~Roll(); void setLoot(Loot* pLoot); Loot* getLoot(); void targetObjectBuildLink(); - uint64 itemGUID; + ObjectGuid itemGUID; uint32 itemid; int32 itemRandomPropId; uint32 itemRandomSuffix; uint8 itemCount; - typedef std::map<uint64, RollVote> PlayerVote; + typedef std::map<ObjectGuid, RollVote> PlayerVote; PlayerVote playerVote; //vote position correspond with player position (in group) uint8 totalPlayersRolling; uint8 totalNeed; @@ -157,7 +157,7 @@ class Group public: struct MemberSlot { - uint64 guid; + ObjectGuid guid; std::string name; uint8 group; uint8 flags; @@ -179,21 +179,21 @@ public: // group manipulation methods bool Create(Player* leader); bool LoadGroupFromDB(Field* field); - void LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles); + void LoadMemberFromDB(ObjectGuid::LowType guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles); bool AddInvite(Player* player); void RemoveInvite(Player* player); void RemoveAllInvites(); bool AddLeaderInvite(Player* player); bool AddMember(Player* player); - bool RemoveMember(uint64 guid, const RemoveMethod& method = GROUP_REMOVEMETHOD_DEFAULT, uint64 kicker = 0, const char* reason = nullptr); - void ChangeLeader(uint64 guid); + bool RemoveMember(ObjectGuid guid, const RemoveMethod& method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, const char* reason = nullptr); + void ChangeLeader(ObjectGuid guid); void SetLootMethod(LootMethod method); - void SetLooterGuid(uint64 guid); - void SetMasterLooterGuid(uint64 guid); + void SetLooterGuid(ObjectGuid guid); + void SetMasterLooterGuid(ObjectGuid guid); void UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed = false); void SetLootThreshold(ItemQualities threshold); void Disband(bool hideDestroy = false); - void SetLfgRoles(uint64 guid, const uint8 roles); + void SetLfgRoles(ObjectGuid guid, const uint8 roles); // properties accessories bool IsFull() const; @@ -202,26 +202,25 @@ public: bool isBFGroup() const; bool isBGGroup() const; bool IsCreated() const; - uint64 GetLeaderGUID() const; - uint64 GetGUID() const; - uint32 GetLowGUID() const; + ObjectGuid GetLeaderGUID() const; + ObjectGuid GetGUID() const; const char* GetLeaderName() const; LootMethod GetLootMethod() const; - uint64 GetLooterGuid() const; - uint64 GetMasterLooterGuid() const; + ObjectGuid GetLooterGuid() const; + ObjectGuid GetMasterLooterGuid() const; ItemQualities GetLootThreshold() const; // member manipulation methods - bool IsMember(uint64 guid) const; - bool IsLeader(uint64 guid) const; - uint64 GetMemberGUID(const std::string& name); - bool IsAssistant(uint64 guid) const; + bool IsMember(ObjectGuid guid) const; + bool IsLeader(ObjectGuid guid) const; + ObjectGuid GetMemberGUID(const std::string& name); + bool IsAssistant(ObjectGuid guid) const; - Player* GetInvited(uint64 guid) const; + Player* GetInvited(ObjectGuid guid) const; Player* GetInvited(const std::string& name) const; - bool SameSubGroup(uint64 guid1, uint64 guid2) const; - bool SameSubGroup(uint64 guid1, MemberSlot const* slot2) const; + bool SameSubGroup(ObjectGuid guid1, ObjectGuid guid2) const; + bool SameSubGroup(ObjectGuid guid1, MemberSlot const* slot2) const; bool SameSubGroup(Player const* member1, Player const* member2) const; bool HasFreeSlotSubGroup(uint8 subgroup) const; @@ -230,7 +229,7 @@ public: GroupReference const* GetFirstMember() const { return m_memberMgr.getFirst(); } uint32 GetMembersCount() const { return m_memberSlots.size(); } - uint8 GetMemberGroup(uint64 guid) const; + uint8 GetMemberGroup(ObjectGuid guid) const; void ConvertToLFG(); void ConvertToRaid(); @@ -239,9 +238,9 @@ public: void SetBattlefieldGroup(Battlefield* bf); GroupJoinBattlegroundResult CanJoinBattlegroundQueue(Battleground const* bgTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot); - void ChangeMembersGroup(uint64 guid, uint8 group); - void SetTargetIcon(uint8 id, uint64 whoGuid, uint64 targetGuid); - void SetGroupMemberFlag(uint64 guid, bool apply, GroupMemberFlags flag); + void ChangeMembersGroup(ObjectGuid guid, uint8 group); + void SetTargetIcon(uint8 id, ObjectGuid whoGuid, ObjectGuid targetGuid); + void SetGroupMemberFlag(ObjectGuid guid, bool apply, GroupMemberFlags flag); void RemoveUniqueGroupMemberFlag(GroupMemberFlags flag); Difficulty GetDifficulty(bool isRaid) const; @@ -256,10 +255,10 @@ public: //void SendInit(WorldSession* session); void SendTargetIconList(WorldSession* session); void SendUpdate(); - void SendUpdateToPlayer(uint64 playerGUID, MemberSlot* slot = nullptr); + void SendUpdateToPlayer(ObjectGuid playerGUID, MemberSlot* slot = nullptr); void UpdatePlayerOutOfRange(Player* player); // ignore: GUID of player that will be ignored - void BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group = -1, uint64 ignore = 0); + void BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group = -1, ObjectGuid ignore = ObjectGuid::Empty); void BroadcastReadyCheck(WorldPacket* packet); void OfflineReadyCheck(); @@ -270,16 +269,16 @@ public: bool isRollLootActive() const; void SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll& r); void SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player* p, bool canNeed, Roll const& r); - void SendLootRoll(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll& r); - void SendLootRollWon(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll& r); + void SendLootRoll(ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, const Roll& r); + void SendLootRollWon(ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, const Roll& r); void SendLootAllPassed(Roll const& roll); void SendLooter(Creature* creature, Player* pLooter); void GroupLoot(Loot* loot, WorldObject* pLootedObject); void NeedBeforeGreed(Loot* loot, WorldObject* pLootedObject); void MasterLoot(Loot* loot, WorldObject* pLootedObject); - Rolls::iterator GetRoll(uint64 Guid); + Rolls::iterator GetRoll(ObjectGuid Guid); void CountTheRoll(Rolls::iterator roll, Map* allowedMap); - bool CountRollVote(uint64 playerGUID, uint64 Guid, uint8 Choise); + bool CountRollVote(ObjectGuid playerGUID, ObjectGuid Guid, uint8 Choise); void EndRoll(Loot* loot, Map* allowedMap); // related to disenchant rolls @@ -312,8 +311,8 @@ protected: void _cancelHomebindIfInstance(Player* player); void _initRaidSubGroupsCounter(); - member_citerator _getMemberCSlot(uint64 Guid) const; - member_witerator _getMemberWSlot(uint64 Guid); + member_citerator _getMemberCSlot(ObjectGuid Guid) const; + member_witerator _getMemberWSlot(ObjectGuid Guid); void SubGroupCounterIncrease(uint8 subgroup); void SubGroupCounterDecrease(uint8 subgroup); void ToggleGroupMemberFlag(member_witerator slot, uint8 flag, bool apply); @@ -321,21 +320,21 @@ protected: MemberSlotList m_memberSlots; GroupRefManager m_memberMgr; InvitesList m_invitees; - uint64 m_leaderGuid; + ObjectGuid m_leaderGuid; std::string m_leaderName; GroupType m_groupType; Difficulty m_dungeonDifficulty; Difficulty m_raidDifficulty; Battlefield* m_bfGroup; Battleground* m_bgGroup; - uint64 m_targetIcons[TARGETICONCOUNT]; + ObjectGuid m_targetIcons[TARGETICONCOUNT]; LootMethod m_lootMethod; ItemQualities m_lootThreshold; - uint64 m_looterGuid; - uint64 m_masterLooterGuid; + ObjectGuid m_looterGuid; + ObjectGuid m_masterLooterGuid; Rolls RollId; uint8* m_subGroupsCounts; - uint64 m_guid; + ObjectGuid m_guid; uint32 m_counter; // used only in SMSG_GROUP_LIST uint32 m_maxEnchantingLevel; uint8 m_lfgGroupFlags; diff --git a/src/server/game/Groups/GroupMgr.cpp b/src/server/game/Groups/GroupMgr.cpp index 8e97adea6a..3a3035845d 100644 --- a/src/server/game/Groups/GroupMgr.cpp +++ b/src/server/game/Groups/GroupMgr.cpp @@ -50,9 +50,9 @@ void GroupMgr::RegisterGroupId(uint32 groupId) ++_nextGroupId; } -uint32 GroupMgr::GenerateGroupId() +ObjectGuid::LowType GroupMgr::GenerateGroupId() { - uint32 newGroupId = _nextGroupId; + ObjectGuid::LowType newGroupId = _nextGroupId; // find the lowest available id starting from the current _nextGroupId while (_nextGroupId < 0xFFFFFFFF && ++_nextGroupId < _groupIds.size() && _groupIds[_nextGroupId]); @@ -66,7 +66,7 @@ uint32 GroupMgr::GenerateGroupId() return newGroupId; } -Group* GroupMgr::GetGroupByGUID(uint32 groupId) const +Group* GroupMgr::GetGroupByGUID(ObjectGuid::LowType groupId) const { GroupContainer::const_iterator itr = GroupStore.find(groupId); if (itr != GroupStore.end()) @@ -77,12 +77,12 @@ Group* GroupMgr::GetGroupByGUID(uint32 groupId) const void GroupMgr::AddGroup(Group* group) { - GroupStore[group->GetLowGUID()] = group; + GroupStore[group->GetGUID().GetCounter()] = group; } void GroupMgr::RemoveGroup(Group* group) { - GroupStore.erase(group->GetLowGUID()); + GroupStore.erase(group->GetGUID().GetCounter()); } void GroupMgr::LoadGroups() @@ -126,7 +126,7 @@ void GroupMgr::LoadGroups() } AddGroup(group); - RegisterGroupId(group->GetLowGUID()); + RegisterGroupId(group->GetGUID().GetCounter()); ++count; } while (result->NextRow()); diff --git a/src/server/game/Groups/GroupMgr.h b/src/server/game/Groups/GroupMgr.h index 9f450c7b8a..1a22dba6db 100644 --- a/src/server/game/Groups/GroupMgr.h +++ b/src/server/game/Groups/GroupMgr.h @@ -20,11 +20,11 @@ public: typedef std::map<uint32, Group*> GroupContainer; - Group* GetGroupByGUID(uint32 guid) const; + Group* GetGroupByGUID(ObjectGuid::LowType guid) const; void InitGroupIds(); - void RegisterGroupId(uint32 groupId); - uint32 GenerateGroupId(); + void RegisterGroupId(ObjectGuid::LowType groupId); + ObjectGuid::LowType GenerateGroupId(); void LoadGroups(); void AddGroup(Group* group); @@ -32,9 +32,9 @@ public: protected: typedef std::vector<bool> GroupIds; - GroupIds _groupIds; - uint32 _nextGroupId; - GroupContainer GroupStore; + GroupIds _groupIds; + ObjectGuid::LowType _nextGroupId; + GroupContainer GroupStore; }; #define sGroupMgr GroupMgr::instance() diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 31ced0df17..41b03c6a1c 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -164,6 +164,7 @@ inline uint32 Guild::LogHolder::GetNextGUID() m_nextGUID = 0; else m_nextGUID = (m_nextGUID + 1) % m_maxRecords; + return m_nextGUID; } @@ -180,8 +181,8 @@ void Guild::EventLogEntry::SaveToDB(SQLTransaction& trans) const stmt->setUInt32( index, m_guildId); stmt->setUInt32(++index, m_guid); stmt->setUInt8 (++index, uint8(m_eventType)); - stmt->setUInt32(++index, m_playerGuid1); - stmt->setUInt32(++index, m_playerGuid2); + stmt->setUInt32(++index, m_playerGuid1.GetCounter()); + stmt->setUInt32(++index, m_playerGuid2.GetCounter()); stmt->setUInt8 (++index, m_newRank); stmt->setUInt64(++index, m_timestamp); CharacterDatabase.ExecuteOrAppend(trans, stmt); @@ -192,10 +193,10 @@ void Guild::EventLogEntry::WritePacket(WorldPacket& data) const // Event type data << uint8(m_eventType); // Player 1 - data << uint64(MAKE_NEW_GUID(m_playerGuid1, 0, HIGHGUID_PLAYER)); + data << m_playerGuid1; // Player 2 not for left/join guild events if (m_eventType != GUILD_EVENT_LOG_JOIN_GUILD && m_eventType != GUILD_EVENT_LOG_LEAVE_GUILD) - data << uint64(MAKE_NEW_GUID(m_playerGuid2, 0, HIGHGUID_PLAYER)); + data << m_playerGuid2; // New Rank - only for promote/demote guild events if (m_eventType == GUILD_EVENT_LOG_PROMOTE_PLAYER || m_eventType == GUILD_EVENT_LOG_DEMOTE_PLAYER) data << uint8(m_newRank); @@ -220,7 +221,7 @@ void Guild::BankEventLogEntry::SaveToDB(SQLTransaction& trans) const stmt->setUInt32(++index, m_guid); stmt->setUInt8 (++index, m_bankTabId); stmt->setUInt8 (++index, uint8(m_eventType)); - stmt->setUInt32(++index, m_playerGuid); + stmt->setUInt32(++index, m_playerGuid.GetCounter()); stmt->setUInt32(++index, m_itemOrMoney); stmt->setUInt16(++index, m_itemStackCount); stmt->setUInt8 (++index, m_destTabId); @@ -231,7 +232,7 @@ void Guild::BankEventLogEntry::SaveToDB(SQLTransaction& trans) const void Guild::BankEventLogEntry::WritePacket(WorldPacket& data) const { data << uint8(m_eventType); - data << uint64(MAKE_NEW_GUID(m_playerGuid, 0, HIGHGUID_PLAYER)); + data << m_playerGuid; switch(m_eventType) { @@ -393,7 +394,7 @@ void Guild::BankTab::LoadFromDB(Field* fields) bool Guild::BankTab::LoadItemFromDB(Field* fields) { uint8 slotId = fields[13].GetUInt8(); - uint32 itemGuid = fields[14].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[14].GetUInt32(); uint32 itemEntry = fields[15].GetUInt32(); if (slotId >= GUILD_BANK_MAX_SLOTS) { @@ -409,7 +410,7 @@ bool Guild::BankTab::LoadItemFromDB(Field* fields) } Item* pItem = NewItemOrBag(proto); - if (!pItem->LoadFromDB(itemGuid, 0, fields, itemEntry)) + if (!pItem->LoadFromDB(itemGuid, ObjectGuid::Empty, fields, itemEntry)) { LOG_ERROR("server", "Item (GUID %u, id: %u) not found in item_instance, deleting from guild bank!", itemGuid, itemEntry); @@ -551,11 +552,11 @@ bool Guild::BankTab::SetItem(SQLTransaction& trans, uint8 slotId, Item* item) stmt->setUInt32(0, m_guildId); stmt->setUInt8 (1, m_tabId); stmt->setUInt8 (2, slotId); - stmt->setUInt32(3, item->GetGUIDLow()); + stmt->setUInt32(3, item->GetGUID().GetCounter()); CharacterDatabase.ExecuteOrAppend(trans, stmt); - item->SetUInt64Value(ITEM_FIELD_CONTAINED, 0); - item->SetUInt64Value(ITEM_FIELD_OWNER, 0); + item->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid::Empty); + item->SetGuidValue(ITEM_FIELD_OWNER, ObjectGuid::Empty); item->FSetState(ITEM_NEW); item->SaveToDB(trans); // Not in inventory and can be saved standalone } @@ -615,7 +616,7 @@ void Guild::Member::SetPublicNote(std::string const& publicNote) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_MEMBER_PNOTE); stmt->setString(0, publicNote); - stmt->setUInt32(1, GUID_LOPART(m_guid)); + stmt->setUInt32(1, m_guid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -628,7 +629,7 @@ void Guild::Member::SetOfficerNote(std::string const& officerNote) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_MEMBER_OFFNOTE); stmt->setString(0, officerNote); - stmt->setUInt32(1, GUID_LOPART(m_guid)); + stmt->setUInt32(1, m_guid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -642,7 +643,7 @@ void Guild::Member::ChangeRank(uint8 newRank) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_MEMBER_RANK); stmt->setUInt8 (0, newRank); - stmt->setUInt32(1, GUID_LOPART(m_guid)); + stmt->setUInt32(1, m_guid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -650,7 +651,7 @@ void Guild::Member::SaveToDB(SQLTransaction& trans) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_MEMBER); stmt->setUInt32(0, m_guildId); - stmt->setUInt32(1, GUID_LOPART(m_guid)); + stmt->setUInt32(1, m_guid.GetCounter()); stmt->setUInt8 (2, m_rankId); stmt->setString(3, m_publicNote); stmt->setString(4, m_officerNote); @@ -681,7 +682,7 @@ bool Guild::Member::LoadFromDB(Field* fields) if (!m_zoneId) { - LOG_ERROR("server", "Player (GUID: %u) has broken zone-data", GUID_LOPART(m_guid)); + LOG_ERROR("server", "Player (%s) has broken zone-data", m_guid.ToString().c_str()); m_zoneId = Player::GetZoneIdFromDB(m_guid); } ResetFlags(); @@ -693,13 +694,13 @@ bool Guild::Member::CheckStats() const { if (m_level < 1) { - LOG_ERROR("server", "Player (GUID: %u) has a broken data in field `characters`.`level`, deleting him from guild!", GUID_LOPART(m_guid)); + LOG_ERROR("server", "Player (%s) has a broken data in field `characters`.`level`, deleting him from guild!", m_guid.ToString().c_str()); return false; } if (m_class < CLASS_WARRIOR || m_class >= MAX_CLASSES) { - LOG_ERROR("server", "Player (GUID: %u) has a broken data in field `characters`.`class`, deleting him from guild!", GUID_LOPART(m_guid)); + LOG_ERROR("server", "Player (%s) has a broken data in field `characters`.`class`, deleting him from guild!", m_guid.ToString().c_str()); return false; } return true; @@ -707,7 +708,7 @@ bool Guild::Member::CheckStats() const void Guild::Member::WritePacket(WorldPacket& data, bool sendOfficerNote) const { - data << uint64(m_guid) + data << m_guid << uint8(m_flags) << m_name << uint32(m_rankId) @@ -735,7 +736,7 @@ void Guild::Member::UpdateBankWithdrawValue(SQLTransaction& trans, uint8 tabId, m_bankWithdraw[tabId] += amount; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_MEMBER_WITHDRAW); - stmt->setUInt32(0, GUID_LOPART(m_guid)); + stmt->setUInt32(0, m_guid.GetCounter()); for (uint8 i = 0; i <= GUILD_BANK_MAX_TABS;) { uint32 withdraw = m_bankWithdraw[i++]; @@ -896,7 +897,7 @@ void Guild::PlayerMoveItemData::LogBankEvent(SQLTransaction& trans, MoveItemData { ASSERT(pFrom); // Bank -> Char - m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_WITHDRAW_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUIDLow(), + m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_WITHDRAW_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUID(), pFrom->GetItem()->GetEntry(), count); } @@ -983,11 +984,11 @@ void Guild::BankMoveItemData::LogBankEvent(SQLTransaction& trans, MoveItemData* ASSERT(pFrom->GetItem()); if (pFrom->IsBank()) // Bank -> Bank - m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_MOVE_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUIDLow(), + m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_MOVE_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUID(), pFrom->GetItem()->GetEntry(), count, m_container); else // Char -> Bank - m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_ITEM, m_container, m_pPlayer->GetGUIDLow(), + m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_ITEM, m_container, m_pPlayer->GetGUID(), pFrom->GetItem()->GetEntry(), count); } @@ -1122,7 +1123,6 @@ InventoryResult Guild::BankMoveItemData::CanStore(Item* pItem, bool swap) // Guild Guild::Guild(): m_id(0), - m_leaderGuid(0), m_createdDate(0), m_accountsNumber(0), m_bankMoney(0), @@ -1174,8 +1174,8 @@ bool Guild::Create(Player* pLeader, std::string const& name) _CreateLogHolders(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("guild", "GUILD: creating guild [%s] for leader %s (%u)", - name.c_str(), pLeader->GetName().c_str(), GUID_LOPART(m_leaderGuid)); + LOG_DEBUG("guild", "GUILD: creating guild [%s] for leader %s (%s)", + name.c_str(), pLeader->GetName().c_str(), m_leaderGuid.ToString().c_str()); #endif SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -1187,7 +1187,7 @@ bool Guild::Create(Player* pLeader, std::string const& name) stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD); stmt->setUInt32( index, m_id); stmt->setString(++index, name); - stmt->setUInt32(++index, GUID_LOPART(m_leaderGuid)); + stmt->setUInt32(++index, m_leaderGuid.GetCounter()); stmt->setString(++index, m_info); stmt->setString(++index, m_motd); stmt->setUInt64(++index, uint32(m_createdDate)); @@ -1220,7 +1220,7 @@ void Guild::Disband() // Call scripts before guild data removed from database sScriptMgr->OnGuildDisband(this); - _BroadcastEvent(GE_DISBANDED, 0); + _BroadcastEvent(GE_DISBANDED); // Remove all members while (!m_members.empty()) { @@ -1359,7 +1359,7 @@ void Guild::HandleSetMOTD(WorldSession* session, std::string const& motd) stmt->setUInt32(1, m_id); CharacterDatabase.Execute(stmt); - _BroadcastEvent(GE_MOTD, 0, motd.c_str()); + _BroadcastEvent(GE_MOTD, ObjectGuid::Empty, motd.c_str()); } } @@ -1416,7 +1416,7 @@ void Guild::HandleSetLeader(WorldSession* session, std::string const& name) { _SetLeaderGUID(pNewLeader); pOldLeader->ChangeRank(GR_OFFICER); - _BroadcastEvent(GE_LEADER_CHANGED, 0, player->GetName().c_str(), name.c_str()); + _BroadcastEvent(GE_LEADER_CHANGED, ObjectGuid::Empty, player->GetName().c_str(), name.c_str()); } } } @@ -1432,7 +1432,7 @@ void Guild::HandleSetBankTabInfo(WorldSession* session, uint8 tabId, std::string } tab->SetInfo(name, icon); - _BroadcastEvent(GE_BANK_TAB_UPDATED, 0, std::to_string(tabId).c_str(), name.c_str(), icon.c_str()); + _BroadcastEvent(GE_BANK_TAB_UPDATED, ObjectGuid::Empty, std::to_string(tabId).c_str(), name.c_str(), icon.c_str()); } void Guild::HandleSetMemberNote(WorldSession* session, std::string const& name, std::string const& note, bool isPublic) @@ -1469,7 +1469,7 @@ void Guild::HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string c for (GuildBankRightsAndSlotsVec::const_iterator itr = rightsAndSlots.begin(); itr != rightsAndSlots.end(); ++itr) _SetRankBankTabRightsAndSlots(rankId, *itr); - _BroadcastEvent(GE_RANK_UPDATED, 0, std::to_string(rankId).c_str(), name.c_str()); + _BroadcastEvent(GE_RANK_UPDATED, ObjectGuid::Empty, std::to_string(rankId).c_str(), name.c_str()); } } @@ -1499,7 +1499,7 @@ void Guild::HandleBuyBankTab(WorldSession* session, uint8 tabId) player->ModifyMoney(-int32(tabCost)); _CreateNewBankTab(); - _BroadcastEvent(GE_BANK_TAB_PURCHASED, 0); + _BroadcastEvent(GE_BANK_TAB_PURCHASED); SendPermissions(session); /// Hack to force client to update permissions } @@ -1514,7 +1514,7 @@ void Guild::HandleInviteMember(WorldSession* session, std::string const& name) Player* player = session->GetPlayer(); // Do not show invitations from ignored players - if (pInvitee->GetSocial()->HasIgnore(player->GetGUIDLow())) + if (pInvitee->GetSocial()->HasIgnore(player->GetGUID())) return; if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && pInvitee->GetTeamId() != player->GetTeamId()) @@ -1549,7 +1549,7 @@ void Guild::HandleInviteMember(WorldSession* session, std::string const& name) #endif pInvitee->SetGuildIdInvited(m_id); - _LogEvent(GUILD_EVENT_LOG_INVITE_PLAYER, player->GetGUIDLow(), pInvitee->GetGUIDLow()); + _LogEvent(GUILD_EVENT_LOG_INVITE_PLAYER, player->GetGUID(), pInvitee->GetGUID()); WorldPacket data(SMSG_GUILD_INVITE, 8 + 10); // Guess size data << player->GetName(); @@ -1564,7 +1564,7 @@ void Guild::HandleAcceptMember(WorldSession* session) { Player* player = session->GetPlayer(); if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && - player->GetTeamId() != sObjectMgr->GetPlayerTeamIdByGUID(GetLeaderGUID())) + player->GetTeamId() != sObjectMgr->GetPlayerTeamIdByGUID(GetLeaderGUID().GetCounter())) return; AddMember(player->GetGUID()); @@ -1592,7 +1592,7 @@ void Guild::HandleLeaveMember(WorldSession* session) { DeleteMember(player->GetGUID(), false, false); - _LogEvent(GUILD_EVENT_LOG_LEAVE_GUILD, player->GetGUIDLow()); + _LogEvent(GUILD_EVENT_LOG_LEAVE_GUILD, player->GetGUID()); _BroadcastEvent(GE_LEFT, player->GetGUID(), player->GetName().c_str()); SendCommandResult(session, GUILD_COMMAND_QUIT, ERR_GUILD_COMMAND_SUCCESS, m_name); @@ -1623,11 +1623,11 @@ void Guild::HandleRemoveMember(WorldSession* session, std::string const& name) SendCommandResult(session, GUILD_COMMAND_REMOVE, ERR_GUILD_RANK_TOO_HIGH_S, name); else { - uint64 guid = member->GetGUID(); + ObjectGuid guid = member->GetGUID(); // After call to DeleteMember pointer to member becomes invalid DeleteMember(guid, false, true); - _LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUIDLow(), GUID_LOPART(guid)); - _BroadcastEvent(GE_REMOVED, 0, name.c_str(), player->GetName().c_str()); + _LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUID(), guid); + _BroadcastEvent(GE_REMOVED, ObjectGuid::Empty, name.c_str(), player->GetName().c_str()); } } } @@ -1680,8 +1680,8 @@ void Guild::HandleUpdateMemberRank(WorldSession* session, std::string const& nam uint32 newRankId = member->GetRankId() + (demote ? 1 : -1); member->ChangeRank(newRankId); - _LogEvent(demote ? GUILD_EVENT_LOG_DEMOTE_PLAYER : GUILD_EVENT_LOG_PROMOTE_PLAYER, player->GetGUIDLow(), GUID_LOPART(member->GetGUID()), newRankId); - _BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, 0, player->GetName().c_str(), name.c_str(), _GetRankName(newRankId).c_str()); + _LogEvent(demote ? GUILD_EVENT_LOG_DEMOTE_PLAYER : GUILD_EVENT_LOG_PROMOTE_PLAYER, player->GetGUID(), member->GetGUID(), newRankId); + _BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, ObjectGuid::Empty, player->GetName().c_str(), name.c_str(), _GetRankName(newRankId).c_str()); } } @@ -1694,7 +1694,7 @@ void Guild::HandleAddNewRank(WorldSession* session, std::string const& name) // Only leader can add new rank if (_IsLeader(session->GetPlayer())) if (_CreateRank(name, GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK)) - _BroadcastEvent(GE_RANK_UPDATED, 0, std::to_string(size).c_str(), name.c_str()); + _BroadcastEvent(GE_RANK_UPDATED, ObjectGuid::Empty, std::to_string(size).c_str(), name.c_str()); } void Guild::HandleRemoveLowestRank(WorldSession* session) @@ -1721,7 +1721,7 @@ void Guild::HandleRemoveRank(WorldSession* session, uint8 rankId) m_ranks.pop_back(); - _BroadcastEvent(GE_RANK_DELETED, 0); + _BroadcastEvent(GE_RANK_DELETED); } void Guild::HandleMemberDepositMoney(WorldSession* session, uint32 amount) @@ -1736,15 +1736,16 @@ void Guild::HandleMemberDepositMoney(WorldSession* session, uint32 amount) player->ModifyMoney(-int32(amount)); player->SaveGoldToDB(trans); - _LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), player->GetGUIDLow(), amount); + _LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), player->GetGUID(), amount); CharacterDatabase.CommitTransaction(trans); std::string aux = acore::Impl::ByteArrayToHexStr(reinterpret_cast<uint8*>(&m_bankMoney), 8, true); - _BroadcastEvent(GE_BANK_MONEY_SET, 0, aux.c_str()); + _BroadcastEvent(GE_BANK_MONEY_SET, ObjectGuid::Empty, aux.c_str()); if (amount > 10 * GOLD) - CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<GB DEPOSIT> %s (guild id: %u, members: %u, new amount: %u, leader guid low: %u, char level: %u)\", NOW())", session->GetAccountId(), player->GetGUIDLow(), player->GetName().c_str(), session->GetRemoteAddress().c_str(), 0, "", amount, GetName().c_str(), GetId(), GetMemberCount(), GetTotalBankMoney(), (uint32)(GetLeaderGUID() & 0xFFFFFFFF), player->getLevel()); + CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<GB DEPOSIT> %s (guild id: %u, members: %u, new amount: %u, leader guid low: %u, char level: %u)\", NOW())", + session->GetAccountId(), player->GetGUID().GetCounter(), player->GetName().c_str(), session->GetRemoteAddress().c_str(), 0, "", amount, GetName().c_str(), GetId(), GetMemberCount(), GetTotalBankMoney(), GetLeaderGUID().GetCounter(), player->getLevel()); } bool Guild::HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool repair) @@ -1783,14 +1784,15 @@ bool Guild::HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool _ModifyBankMoney(trans, amount, false); // Log guild bank event - _LogBankEvent(trans, repair ? GUILD_BANK_LOG_REPAIR_MONEY : GUILD_BANK_LOG_WITHDRAW_MONEY, uint8(0), player->GetGUIDLow(), amount); + _LogBankEvent(trans, repair ? GUILD_BANK_LOG_REPAIR_MONEY : GUILD_BANK_LOG_WITHDRAW_MONEY, uint8(0), player->GetGUID(), amount); CharacterDatabase.CommitTransaction(trans); if (amount > 10 * GOLD) - CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<GB WITHDRAW> %s (guild id: %u, members: %u, new amount: %u, leader guid low: %u, char level: %u)\", NOW())", session->GetAccountId(), player->GetGUIDLow(), player->GetName().c_str(), session->GetRemoteAddress().c_str(), 0, "", amount, GetName().c_str(), GetId(), GetMemberCount(), GetTotalBankMoney(), (uint32)(GetLeaderGUID() & 0xFFFFFFFF), player->getLevel()); + CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<GB WITHDRAW> %s (guild id: %u, members: %u, new amount: %u, leader guid low: %u, char level: %u)\", NOW())", + session->GetAccountId(), player->GetGUID().GetCounter(), player->GetName().c_str(), session->GetRemoteAddress().c_str(), 0, "", amount, GetName().c_str(), GetId(), GetMemberCount(), GetTotalBankMoney(), GetLeaderGUID().GetCounter(), player->getLevel()); std::string aux = acore::Impl::ByteArrayToHexStr(reinterpret_cast<uint8*>(&m_bankMoney), 8, true); - _BroadcastEvent(GE_BANK_MONEY_SET, 0, aux.c_str()); + _BroadcastEvent(GE_BANK_MONEY_SET, ObjectGuid::Empty, aux.c_str()); return true; } @@ -1948,7 +1950,7 @@ bool Guild::LoadFromDB(Field* fields) { m_id = fields[0].GetUInt32(); m_name = fields[1].GetString(); - m_leaderGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER); + m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32()); m_emblemInfo.LoadFromDB(fields); m_info = fields[8].GetString(); m_motd = fields[9].GetString(); @@ -1978,16 +1980,17 @@ void Guild::LoadRankFromDB(Field* fields) bool Guild::LoadMemberFromDB(Field* fields) { - uint32 lowguid = fields[1].GetUInt32(); - Member* member = new Member(m_id, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER), fields[2].GetUInt8()); + ObjectGuid memberGUID = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32()); + + Member* member = new Member(m_id, memberGUID, fields[2].GetUInt8()); if (!member->LoadFromDB(fields)) { - _DeleteMemberFromDB(lowguid); + _DeleteMemberFromDB(memberGUID.GetCounter()); delete member; return false; } - m_members[lowguid] = member; - sWorld->UpdateGlobalPlayerGuild(lowguid, GetId()); + m_members[memberGUID] = member; + sWorld->UpdateGlobalPlayerGuild(memberGUID.GetCounter(), GetId()); return true; } @@ -2004,13 +2007,13 @@ bool Guild::LoadEventLogFromDB(Field* fields) if (m_eventLog->CanInsert()) { m_eventLog->LoadEvent(new EventLogEntry( - m_id, // guild id - fields[1].GetUInt32(), // guid - time_t(fields[6].GetUInt32()), // timestamp - GuildEventLogTypes(fields[2].GetUInt8()), // event type - fields[3].GetUInt32(), // player guid 1 - fields[4].GetUInt32(), // player guid 2 - fields[5].GetUInt8())); // rank + m_id, // guild id + fields[1].GetUInt32(), // guid + time_t(fields[6].GetUInt32()), // timestamp + GuildEventLogTypes(fields[2].GetUInt8()), // event type + ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt32()), // player guid 1 + ObjectGuid::Create<HighGuid::Player>(fields[4].GetUInt32()), // player guid 2 + fields[5].GetUInt8())); // rank return true; } return false; @@ -2026,7 +2029,7 @@ bool Guild::LoadBankEventLogFromDB(Field* fields) LogHolder* pLog = m_bankEventLog[tabId]; if (pLog->CanInsert()) { - uint32 guid = fields[2].GetUInt32(); + ObjectGuid::LowType guid = fields[2].GetUInt32(); GuildBankEventLogTypes eventType = GuildBankEventLogTypes(fields[3].GetUInt8()); if (BankEventLogEntry::IsMoneyEvent(eventType)) { @@ -2042,15 +2045,15 @@ bool Guild::LoadBankEventLogFromDB(Field* fields) return false; } pLog->LoadEvent(new BankEventLogEntry( - m_id, // guild id - guid, // guid - time_t(fields[8].GetUInt32()), // timestamp - dbTabId, // tab id - eventType, // event type - fields[4].GetUInt32(), // player guid - fields[5].GetUInt32(), // item or money - fields[6].GetUInt16(), // itam stack count - fields[7].GetUInt8())); // dest tab id + m_id, // guild id + guid, // guid + time_t(fields[8].GetUInt32()), // timestamp + dbTabId, // tab id + eventType, // event type + ObjectGuid::Create<HighGuid::Player>(fields[4].GetUInt32()), // player guid + fields[5].GetUInt32(), // item or money + fields[6].GetUInt16(), // itam stack count + fields[7].GetUInt8())); // dest tab id } } return true; @@ -2158,7 +2161,7 @@ void Guild::BroadcastToGuild(WorldSession* session, bool officerOnly, std::strin ChatHandler::BuildChatPacket(data, officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, Language(language), session->GetPlayer(), nullptr, msg); for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) if (Player* player = itr->second->FindPlayer()) - if (_HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) && !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUIDLow())) + if (_HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) && !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID())) player->GetSession()->SendPacket(&data); } } @@ -2196,11 +2199,11 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max } Member* member = itr->second; - uint32 level = Player::GetLevelFromStorage(member->GetGUID()); + uint32 level = Player::GetLevelFromStorage(member->GetGUID().GetCounter()); if (member->GetGUID() != session->GetPlayer()->GetGUID() && level >= minLevel && level <= maxLevel && member->IsRankNotLower(minRank)) { - data.appendPackGUID(member->GetGUID()); + data.appendPackGUID(member->GetGUID().GetRawValue()); data << uint8(0); // unk ++count; } @@ -2212,24 +2215,22 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max } // Members handling -bool Guild::AddMember(uint64 guid, uint8 rankId) +bool Guild::AddMember(ObjectGuid guid, uint8 rankId) { - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* player = ObjectAccessor::FindConnectedPlayer(guid); // Player cannot be in guild if (player) { if (player->GetGuildId() != 0) return false; } - else if (Player::GetGuildIdFromStorage(GUID_LOPART(guid)) != 0) + else if (Player::GetGuildIdFromStorage(guid.GetCounter()) != 0) return false; // Remove all player signs from another petitions // This will be prevent attempt to join many guilds and corrupt guild data integrity Player::RemovePetitionsAndSigns(guid, GUILD_CHARTER_TYPE); - uint32 lowguid = GUID_LOPART(guid); - // If rank was not passed, assign lowest possible rank if (rankId == GUILD_RANK_NONE) rankId = _GetLowestRankId(); @@ -2238,7 +2239,7 @@ bool Guild::AddMember(uint64 guid, uint8 rankId) std::string name; if (player) { - m_members[lowguid] = member; + m_members[guid] = member; player->SetInGuild(m_id); player->SetGuildIdInvited(0); player->SetRank(rankId); @@ -2254,7 +2255,7 @@ bool Guild::AddMember(uint64 guid, uint8 rankId) // xinef: zomg! sync query // Player must exist PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DATA_FOR_GUILD); - stmt->setUInt32(0, lowguid); + stmt->setUInt32(0, guid.GetCounter()); if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) { Field* fields = result->Fetch(); @@ -2274,15 +2275,15 @@ bool Guild::AddMember(uint64 guid, uint8 rankId) delete member; return false; } - m_members[lowguid] = member; - sWorld->UpdateGlobalPlayerGuild(lowguid, m_id); + m_members[guid] = member; + sWorld->UpdateGlobalPlayerGuild(guid.GetCounter(), m_id); } SQLTransaction trans(nullptr); member->SaveToDB(trans); _UpdateAccountsNumber(); - _LogEvent(GUILD_EVENT_LOG_JOIN_GUILD, lowguid); + _LogEvent(GUILD_EVENT_LOG_JOIN_GUILD, guid); _BroadcastEvent(GE_JOINED, guid, name.c_str()); // Call scripts if member was succesfully added (and stored to database) @@ -2291,10 +2292,9 @@ bool Guild::AddMember(uint64 guid, uint8 rankId) return true; } -void Guild::DeleteMember(uint64 guid, bool isDisbanding, bool isKicked, bool canDeleteGuild) +void Guild::DeleteMember(ObjectGuid guid, bool isDisbanding, bool isKicked, bool canDeleteGuild) { - uint32 lowguid = GUID_LOPART(guid); - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* player = ObjectAccessor::FindConnectedPlayer(guid); // Guild master can be deleted when loading guild and guid doesn't exist in characters table // or when he is removed from guild by gm command @@ -2304,7 +2304,7 @@ void Guild::DeleteMember(uint64 guid, bool isDisbanding, bool isKicked, bool can Member* newLeader = nullptr; for (Guild::Members::iterator i = m_members.begin(); i != m_members.end(); ++i) { - if (i->first == lowguid) + if (i->first == guid) oldLeader = i->second; else if (!newLeader || newLeader->GetRankId() > i->second->GetRankId()) newLeader = i->second; @@ -2327,14 +2327,14 @@ void Guild::DeleteMember(uint64 guid, bool isDisbanding, bool isKicked, bool can // If leader does not exist (at guild loading with deleted leader) do not send broadcasts if (oldLeader) { - _BroadcastEvent(GE_LEADER_CHANGED, 0, oldLeader->GetName().c_str(), newLeader->GetName().c_str()); + _BroadcastEvent(GE_LEADER_CHANGED, ObjectGuid::Empty, oldLeader->GetName().c_str(), newLeader->GetName().c_str()); _BroadcastEvent(GE_LEFT, guid, oldLeader->GetName().c_str()); } } // Call script on remove before member is actually removed from guild (and database) sScriptMgr->OnGuildRemoveMember(this, player, isDisbanding, isKicked); - auto memberItr = m_members.find(lowguid); + auto memberItr = m_members.find(guid); if (memberItr != m_members.end()) { delete memberItr->second; @@ -2348,14 +2348,14 @@ void Guild::DeleteMember(uint64 guid, bool isDisbanding, bool isKicked, bool can player->SetRank(0); } else - sWorld->UpdateGlobalPlayerGuild(lowguid, 0); + sWorld->UpdateGlobalPlayerGuild(guid.GetCounter(), 0); - _DeleteMemberFromDB(lowguid); + _DeleteMemberFromDB(guid.GetCounter()); if (!isDisbanding) _UpdateAccountsNumber(); } -bool Guild::ChangeMemberRank(uint64 guid, uint8 newRank) +bool Guild::ChangeMemberRank(ObjectGuid guid, uint8 newRank) { if (newRank <= _GetLowestRankId()) // Validate rank (allow only existing ranks) if (Member* member = GetMember(guid)) @@ -2534,7 +2534,7 @@ void Guild::_SetLeaderGUID(Member* pLeader) pLeader->ChangeRank(GR_GUILDMASTER); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_LEADER); - stmt->setUInt32(0, GUID_LOPART(m_leaderGuid)); + stmt->setUInt32(0, m_leaderGuid.GetCounter()); stmt->setUInt32(1, m_id); CharacterDatabase.Execute(stmt); } @@ -2625,7 +2625,7 @@ inline int32 Guild::_GetMemberRemainingMoney(Member const* member) const return 0; } -inline void Guild::_UpdateMemberWithdrawSlots(SQLTransaction& trans, uint64 guid, uint8 tabId) +inline void Guild::_UpdateMemberWithdrawSlots(SQLTransaction& trans, ObjectGuid guid, uint8 tabId) { if (Member* member = GetMember(guid)) { @@ -2636,7 +2636,7 @@ inline void Guild::_UpdateMemberWithdrawSlots(SQLTransaction& trans, uint64 guid } } -inline bool Guild::_MemberHasTabRights(uint64 guid, uint8 tabId, uint32 rights) const +inline bool Guild::_MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 rights) const { if (const Member* member = GetMember(guid)) { @@ -2649,17 +2649,17 @@ inline bool Guild::_MemberHasTabRights(uint64 guid, uint8 tabId, uint32 rights) } // Add new event log record -inline void Guild::_LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) +inline void Guild::_LogEvent(GuildEventLogTypes eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2, uint8 newRank) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); m_eventLog->AddEvent(trans, new EventLogEntry(m_id, m_eventLog->GetNextGUID(), eventType, playerGuid1, playerGuid2, newRank)); CharacterDatabase.CommitTransaction(trans); - sScriptMgr->OnGuildEvent(this, uint8(eventType), playerGuid1, playerGuid2, newRank); + sScriptMgr->OnGuildEvent(this, uint8(eventType), playerGuid1.GetCounter(), playerGuid2.GetCounter(), newRank); } // Add new bank event log record -void Guild::_LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, uint32 lowguid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) +void Guild::_LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid guid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) { if (tabId > GUILD_BANK_MAX_TABS) return; @@ -2675,9 +2675,9 @@ void Guild::_LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventTyp dbTabId = GUILD_BANK_MONEY_LOGS_TAB; } LogHolder* pLog = m_bankEventLog[tabId]; - pLog->AddEvent(trans, new BankEventLogEntry(m_id, pLog->GetNextGUID(), eventType, dbTabId, lowguid, itemOrMoney, itemStackCount, destTabId)); + pLog->AddEvent(trans, new BankEventLogEntry(m_id, pLog->GetNextGUID(), eventType, dbTabId, guid, itemOrMoney, itemStackCount, destTabId)); - sScriptMgr->OnGuildBankEvent(this, uint8(eventType), tabId, lowguid, itemOrMoney, itemStackCount, destTabId); + sScriptMgr->OnGuildBankEvent(this, uint8(eventType), tabId, guid.GetCounter(), itemOrMoney, itemStackCount, destTabId); } inline Item* Guild::_GetItem(uint8 tabId, uint8 slotId) const @@ -2792,7 +2792,7 @@ bool Guild::_DoItemsMove(MoveItemData* pSrc, MoveItemData* pDest, bool sendError void Guild::_SendBankContent(WorldSession* session, uint8 tabId) const { - uint64 guid = session->GetPlayer()->GetGUID(); + ObjectGuid guid = session->GetPlayer()->GetGUID(); if (!_MemberHasTabRights(guid, tabId, GUILD_BANK_RIGHT_VIEW_TAB)) return; @@ -2841,7 +2841,7 @@ void Guild::_SendBankContentUpdate(uint8 tabId, SlotIds slots) const _SendBankList(nullptr, tabId, false, &slots); } -void Guild::_BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* param1, const char* param2, const char* param3) const +void Guild::_BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, const char* param1, const char* param2, const char* param3) const { uint8 count = !param3 ? (!param2 ? (!param1 ? 0 : 1) : 2) : 3; @@ -2857,7 +2857,7 @@ void Guild::_BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* par data << param1; if (guid) - data << uint64(guid); + data << guid; BroadcastPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) @@ -2936,5 +2936,5 @@ void Guild::ResetTimes() for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) itr->second->ResetValues(); - _BroadcastEvent(GE_BANK_TAB_AND_MONEY_UPDATED, 0); + _BroadcastEvent(GE_BANK_TAB_AND_MONEY_UPDATED); } diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index 4fb8426ce2..7968522d1b 100644 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -274,7 +274,7 @@ public: // pussywizard: public class Member class Member { public: - Member(uint32 guildId, uint64 guid, uint8 rankId): + Member(uint32 guildId, ObjectGuid guid, uint8 rankId): m_guildId(guildId), m_guid(guid), m_zoneId(0), @@ -305,7 +305,7 @@ public: // pussywizard: public class Member void SaveToDB(SQLTransaction& trans) const; void WritePacket(WorldPacket& data, bool sendOfficerNote) const; - uint64 GetGUID() const { return m_guid; } + ObjectGuid GetGUID() const { return m_guid; } std::string const& GetName() const { return m_name; } uint32 GetAccountId() const { return m_accountId; } uint8 GetRankId() const { return m_rankId; } @@ -324,18 +324,18 @@ public: // pussywizard: public class Member inline void UpdateLogoutTime() { m_logoutTime = ::time(nullptr); } inline bool IsRank(uint8 rankId) const { return m_rankId == rankId; } inline bool IsRankNotLower(uint8 rankId) const { return m_rankId <= rankId; } - inline bool IsSamePlayer(uint64 guid) const { return m_guid == guid; } + inline bool IsSamePlayer(ObjectGuid guid) const { return m_guid == guid; } void UpdateBankWithdrawValue(SQLTransaction& trans, uint8 tabId, uint32 amount); int32 GetBankWithdrawValue(uint8 tabId) const; void ResetValues(); - inline Player* FindPlayer() const { return ObjectAccessor::GetObjectInOrOutOfWorld(m_guid, (Player*)nullptr); } + inline Player* FindPlayer() const { return ObjectAccessor::FindConnectedPlayer(m_guid); } private: uint32 m_guildId; // Fields from characters table - uint64 m_guid; + ObjectGuid m_guid; std::string m_name; uint32 m_zoneId; uint8 m_level; @@ -353,14 +353,14 @@ public: // pussywizard: public class Member }; // pussywizard: public GetMember - inline const Member* GetMember(uint64 guid) const + inline const Member* GetMember(ObjectGuid guid) const { - Members::const_iterator itr = m_members.find(GUID_LOPART(guid)); + Members::const_iterator itr = m_members.find(guid); return itr != m_members.end() ? itr->second : nullptr; } - inline Member* GetMember(uint64 guid) + inline Member* GetMember(ObjectGuid guid) { - Members::iterator itr = m_members.find(GUID_LOPART(guid)); + Members::iterator itr = m_members.find(guid); return itr != m_members.end() ? itr->second : nullptr; } inline Member* GetMember(std::string const& name) @@ -377,11 +377,11 @@ private: class LogEntry { public: - LogEntry(uint32 guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(nullptr)) { } - LogEntry(uint32 guildId, uint32 guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { } + LogEntry(uint32 guildId, ObjectGuid::LowType guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(nullptr)) { } + LogEntry(uint32 guildId, ObjectGuid::LowType guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { } virtual ~LogEntry() { } - uint32 GetGUID() const { return m_guid; } + ObjectGuid::LowType GetGUID() const { return m_guid; } uint64 GetTimestamp() const { return m_timestamp; } virtual void SaveToDB(SQLTransaction& trans) const = 0; @@ -389,7 +389,7 @@ private: protected: uint32 m_guildId; - uint32 m_guid; + ObjectGuid::LowType m_guid; uint64 m_timestamp; }; @@ -397,10 +397,10 @@ private: class EventLogEntry : public LogEntry { public: - EventLogEntry(uint32 guildId, uint32 guid, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) : + EventLogEntry(uint32 guildId, ObjectGuid::LowType guid, GuildEventLogTypes eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2, uint8 newRank) : LogEntry(guildId, guid), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { } - EventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) : + EventLogEntry(uint32 guildId, ObjectGuid::LowType guid, time_t timestamp, GuildEventLogTypes eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2, uint8 newRank) : LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { } ~EventLogEntry() override { } @@ -410,8 +410,8 @@ private: private: GuildEventLogTypes m_eventType; - uint32 m_playerGuid1; - uint32 m_playerGuid2; + ObjectGuid m_playerGuid1; + ObjectGuid m_playerGuid2; uint8 m_newRank; }; @@ -427,11 +427,11 @@ private: eventType == GUILD_BANK_LOG_REPAIR_MONEY; } - BankEventLogEntry(uint32 guildId, uint32 guid, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : + BankEventLogEntry(uint32 guildId, ObjectGuid::LowType guid, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : LogEntry(guildId, guid), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid), m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { } - BankEventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : + BankEventLogEntry(uint32 guildId, ObjectGuid::LowType guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, ObjectGuid playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid), m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { } @@ -443,7 +443,7 @@ private: private: GuildBankEventLogTypes m_eventType; uint8 m_bankTabId; - uint32 m_playerGuid; + ObjectGuid m_playerGuid; uint32 m_itemOrMoney; uint16 m_itemStackCount; uint8 m_destTabId; @@ -650,7 +650,7 @@ private: void CanStoreItemInTab(Item* pItem, uint8 skipSlotId, bool merge, uint32& count); }; - typedef std::unordered_map<uint32, Member*> Members; + typedef std::unordered_map<ObjectGuid, Member*> Members; typedef std::vector<RankInfo> Ranks; typedef std::vector<BankTab*> BankTabs; @@ -666,7 +666,7 @@ public: // Getters uint32 GetId() const { return m_id; } - uint64 GetLeaderGUID() const { return m_leaderGuid; } + ObjectGuid GetLeaderGUID() const { return m_leaderGuid; } std::string const& GetName() const { return m_name; } std::string const& GetMOTD() const { return m_motd; } std::string const& GetInfo() const { return m_info; } @@ -738,9 +738,9 @@ public: // Members // Adds member to guild. If rankId == GUILD_RANK_NONE, lowest rank is assigned. - bool AddMember(uint64 guid, uint8 rankId = GUILD_RANK_NONE); - void DeleteMember(uint64 guid, bool isDisbanding = false, bool isKicked = false, bool canDeleteGuild = false); - bool ChangeMemberRank(uint64 guid, uint8 newRank); + bool AddMember(ObjectGuid guid, uint8 rankId = GUILD_RANK_NONE); + void DeleteMember(ObjectGuid guid, bool isDisbanding = false, bool isKicked = false, bool canDeleteGuild = false); + bool ChangeMemberRank(ObjectGuid guid, uint8 newRank); // Bank void SwapItems(Player* player, uint8 tabId, uint8 slotId, uint8 destTabId, uint8 destSlotId, uint32 splitedAmount); @@ -762,7 +762,7 @@ public: protected: uint32 m_id; std::string m_name; - uint64 m_leaderGuid; + ObjectGuid m_leaderGuid; std::string m_motd; std::string m_info; time_t m_createdDate; @@ -797,7 +797,7 @@ private: inline BankTab* GetBankTab(uint8 tabId) { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : nullptr; } inline const BankTab* GetBankTab(uint8 tabId) const { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : nullptr; } - inline void _DeleteMemberFromDB(uint32 lowguid) const + inline void _DeleteMemberFromDB(ObjectGuid::LowType lowguid) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBER); stmt->setUInt32(0, lowguid); @@ -829,11 +829,11 @@ private: int32 _GetMemberRemainingSlots(Member const* member, uint8 tabId) const; int32 _GetMemberRemainingMoney(Member const* member) const; - void _UpdateMemberWithdrawSlots(SQLTransaction& trans, uint64 guid, uint8 tabId); - bool _MemberHasTabRights(uint64 guid, uint8 tabId, uint32 rights) const; + void _UpdateMemberWithdrawSlots(SQLTransaction& trans, ObjectGuid guid, uint8 tabId); + bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 rights) const; - void _LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2 = 0, uint8 newRank = 0); - void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0); + void _LogEvent(GuildEventLogTypes eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2 = ObjectGuid::Empty, uint8 newRank = 0); + void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0); Item* _GetItem(uint8 tabId, uint8 slotId) const; void _RemoveItem(SQLTransaction& trans, uint8 tabId, uint8 slotId); @@ -846,6 +846,6 @@ private: void _SendBankContentUpdate(uint8 tabId, SlotIds slots) const; void _SendBankList(WorldSession* session = nullptr, uint8 tabId = 0, bool sendFullSlots = false, SlotIds* slots = nullptr) const; - void _BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* param1 = nullptr, const char* param2 = nullptr, const char* param3 = nullptr) const; + void _BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid = ObjectGuid::Empty, const char* param1 = nullptr, const char* param2 = nullptr, const char* param3 = nullptr) const; }; #endif diff --git a/src/server/game/Guilds/GuildMgr.cpp b/src/server/game/Guilds/GuildMgr.cpp index 223143ca2c..3fb16fe083 100644 --- a/src/server/game/Guilds/GuildMgr.cpp +++ b/src/server/game/Guilds/GuildMgr.cpp @@ -74,7 +74,7 @@ std::string GuildMgr::GetGuildNameById(uint32 guildId) const return ""; } -Guild* GuildMgr::GetGuildByLeader(uint64 guid) const +Guild* GuildMgr::GetGuildByLeader(ObjectGuid guid) const { for (GuildContainer::const_iterator itr = GuildStore.begin(); itr != GuildStore.end(); ++itr) if (itr->second->GetLeaderGUID() == guid) diff --git a/src/server/game/Guilds/GuildMgr.h b/src/server/game/Guilds/GuildMgr.h index 23a1bde91b..399474ff75 100644 --- a/src/server/game/Guilds/GuildMgr.h +++ b/src/server/game/Guilds/GuildMgr.h @@ -18,7 +18,7 @@ private: public: static GuildMgr* instance(); - Guild* GetGuildByLeader(uint64 guid) const; + Guild* GetGuildByLeader(ObjectGuid guid) const; Guild* GetGuildById(uint32 guildId) const; Guild* GetGuildByName(std::string const& guildName) const; std::string GetGuildNameById(uint32 guildId) const; diff --git a/src/server/game/Handlers/ArenaTeamHandler.cpp b/src/server/game/Handlers/ArenaTeamHandler.cpp index f99139d1a1..90da4814a3 100644 --- a/src/server/game/Handlers/ArenaTeamHandler.cpp +++ b/src/server/game/Handlers/ArenaTeamHandler.cpp @@ -23,10 +23,10 @@ void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket& recvData) LOG_DEBUG("network", "MSG_INSPECT_ARENA_TEAMS"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "Inspect Arena stats (GUID: %u TypeId: %u)", GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid))); + LOG_DEBUG("network", "Inspect Arena stats (%s)", guid.ToString().c_str()); #endif if (Player* player = ObjectAccessor::FindPlayer(guid)) @@ -118,7 +118,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket& recvData) } // OK result but don't send invite - if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) + if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUID())) return; if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeamId() != GetPlayer()->GetTeamId()) @@ -179,7 +179,7 @@ void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket& /*recvData*/) } // Only allow members of the other faction to join the team if cross faction interaction is enabled - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && _player->GetTeamId() != sObjectMgr->GetPlayerTeamIdByGUID(arenaTeam->GetCaptain())) + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && _player->GetTeamId() != sObjectMgr->GetPlayerTeamIdByGUID(arenaTeam->GetCaptain().GetCounter())) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_NOT_ALLIED); return; @@ -363,7 +363,7 @@ void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket& recvData) arenaTeam->DelMember(member->Guid, true); // Broadcast event - arenaTeam->BroadcastEvent(ERR_ARENA_TEAM_REMOVE_SSS, 0, 3, name, arenaTeam->GetName(), _player->GetName()); + arenaTeam->BroadcastEvent(ERR_ARENA_TEAM_REMOVE_SSS, ObjectGuid::Empty, 3, name, arenaTeam->GetName(), _player->GetName()); } void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket& recvData) @@ -408,7 +408,7 @@ void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket& recvData) arenaTeam->SetCaptain(member->Guid); // Broadcast event - arenaTeam->BroadcastEvent(ERR_ARENA_TEAM_LEADER_CHANGED_SSS, 0, 3, _player->GetName().c_str(), name, arenaTeam->GetName()); + arenaTeam->BroadcastEvent(ERR_ARENA_TEAM_LEADER_CHANGED_SSS, ObjectGuid::Empty, 3, _player->GetName().c_str(), name, arenaTeam->GetName()); } void WorldSession::SendArenaTeamCommandResult(uint32 teamAction, const std::string& team, const std::string& player, uint32 errorId) diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 6a9848ee5b..86c8880b58 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -23,14 +23,14 @@ //void called when player click on auctioneer npc void WorldSession::HandleAuctionHelloOpcode(WorldPacket& recvData) { - uint64 guid; //NPC guid + ObjectGuid guid; //NPC guid recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER); if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleAuctionHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleAuctionHelloOpcode - Unit (%s) not found or you can't interact with him.", guid.ToString().c_str()); #endif return; } @@ -43,7 +43,7 @@ void WorldSession::HandleAuctionHelloOpcode(WorldPacket& recvData) } //this void causes that auction window is opened -void WorldSession::SendAuctionHello(uint64 guid, Creature* unit) +void WorldSession::SendAuctionHello(ObjectGuid guid, Creature* unit) { if (GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_AUCTION_LEVEL_REQ)) { @@ -59,7 +59,7 @@ void WorldSession::SendAuctionHello(uint64 guid, Creature* unit) return; WorldPacket data(MSG_AUCTION_HELLO, 12); - data << uint64(guid); + data << guid; data << uint32(ahEntry->houseId); data << uint8(1); // 3.3.3: 1 - AH enabled, 0 - AH disabled SendPacket(&data); @@ -78,12 +78,12 @@ void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uin } //this function sends notification, if bidder is online -void WorldSession::SendAuctionBidderNotification(uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template) +void WorldSession::SendAuctionBidderNotification(uint32 location, uint32 auctionId, ObjectGuid bidder, uint32 bidSum, uint32 diff, uint32 item_template) { WorldPacket data(SMSG_AUCTION_BIDDER_NOTIFICATION, (8 * 4)); data << uint32(location); data << uint32(auctionId); - data << uint64(bidder); + data << bidder; data << uint32(bidSum); data << uint32(diff); data << uint32(item_template); @@ -108,13 +108,12 @@ void WorldSession::SendAuctionOwnerNotification(AuctionEntry* auction) //this void creates new auction and adds auction to some auctionhouse void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) { - uint64 auctioneer; + ObjectGuid auctioneer; uint32 itemsCount, etime, bid, buyout; recvData >> auctioneer; recvData >> itemsCount; - uint64 itemGUIDs[MAX_AUCTION_ITEMS]; // 160 slot = 4x 36 slot bag + backpack 16 slot - memset(itemGUIDs, 0, sizeof(itemGUIDs)); + ObjectGuid itemGUIDs[MAX_AUCTION_ITEMS]; // 160 slot = 4x 36 slot bag + backpack 16 slot uint32 count[MAX_AUCTION_ITEMS]; memset(count, 0, sizeof(count)); @@ -147,7 +146,8 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) if (bid > MAX_MONEY_AMOUNT || buyout > MAX_MONEY_AMOUNT) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Player %s (GUID %u) attempted to sell item with higher price than max gold amount.", _player->GetName().c_str(), _player->GetGUIDLow()); + LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Player %s (%s) attempted to sell item with higher price than max gold amount.", + _player->GetName().c_str(), _player->GetGUID().ToString().c_str()); #endif SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR); return; @@ -157,7 +157,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (GUID: %u) not found or you can't interact with him.", GUID_LOPART(auctioneer)); + LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (%s) not found or you can't interact with him.", auctioneer.ToString().c_str()); #endif return; } @@ -166,7 +166,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) if (!auctionHouseEntry) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", GUID_LOPART(auctioneer)); + LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (%s) has wrong faction.", auctioneer.ToString().c_str()); #endif return; } @@ -204,7 +204,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) if (itemEntry == 0) itemEntry = item->GetTemplate()->ItemId; - if (sAuctionMgr->GetAItem(item->GetGUIDLow()) || !item->CanBeTraded() || item->IsNotEmptyBag() || + if (sAuctionMgr->GetAItem(item->GetGUID()) || !item->CanBeTraded() || item->IsNotEmptyBag() || item->GetTemplate()->Flags & ITEM_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION) || item->GetCount() < count[i] || itemEntry != item->GetTemplate()->ItemId) { @@ -266,19 +266,36 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) AH->Id = sObjectMgr->GenerateAuctionID(); if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) - AH->auctioneer = 23442; + AH->houseId = AUCTIONHOUSE_NEUTRAL; else - AH->auctioneer = GUID_LOPART(auctioneer); + { + CreatureData const* auctioneerData = sObjectMgr->GetCreatureData(creature->GetSpawnId()); + if (!auctioneerData) + { + LOG_ERROR("server", "Data for auctioneer not found (%s)", auctioneer.ToString().c_str()); + return; + } + + CreatureTemplate const* auctioneerInfo = sObjectMgr->GetCreatureTemplate(auctioneerData->id); + if (!auctioneerInfo) + { + LOG_ERROR("server", "Non existing auctioneer (%s)", auctioneer.ToString().c_str()); + return; + } + + const AuctionHouseEntry* AHEntry = sAuctionMgr->GetAuctionHouseEntry(auctioneerInfo->faction); + AH->houseId = AHEntry->houseId; + } // Required stack size of auction matches to current item stack size, just move item to auctionhouse if (itemsCount == 1 && item->GetCount() == count[i]) { - AH->item_guidlow = item->GetGUIDLow(); + AH->item_guid = item->GetGUID(); AH->item_template = item->GetEntry(); AH->itemCount = item->GetCount(); - AH->owner = _player->GetGUIDLow(); + AH->owner = _player->GetGUID(); AH->startbid = bid; - AH->bidder = 0; + AH->bidder = ObjectGuid::Empty; AH->bid = 0; AH->buyout = buyout; AH->expire_time = time(nullptr) + auctionTime; @@ -286,7 +303,8 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) AH->auctionHouseEntry = auctionHouseEntry; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) to auctioneer %u with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", _player->GetName().c_str(), _player->GetGUIDLow(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUIDLow(), AH->auctioneer, item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId()); + LOG_DEBUG("server", "CMSG_AUCTION_SELL_ITEM: Player %s (%s) is selling item %s entry %u (%s) with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", + _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUID().ToString().c_str(), item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId()); #endif sAuctionMgr->AddAItem(item); auctionHouse->AddAuction(AH); @@ -315,12 +333,12 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) return; } - AH->item_guidlow = newItem->GetGUIDLow(); + AH->item_guid = newItem->GetGUID(); AH->item_template = newItem->GetEntry(); AH->itemCount = newItem->GetCount(); - AH->owner = _player->GetGUIDLow(); + AH->owner = _player->GetGUID(); AH->startbid = bid; - AH->bidder = 0; + AH->bidder = ObjectGuid::Empty; AH->bid = 0; AH->buyout = buyout; AH->expire_time = time(nullptr) + auctionTime; @@ -328,7 +346,8 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) AH->auctionHouseEntry = auctionHouseEntry; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) to auctioneer %u with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", _player->GetName().c_str(), _player->GetGUIDLow(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), newItem->GetGUIDLow(), AH->auctioneer, newItem->GetCount(), bid, buyout, auctionTime, AH->GetHouseId()); + LOG_DEBUG("server", "CMSG_AUCTION_SELL_ITEM: Player %s (%s) is selling item %s entry %u (%s) with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", + _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), newItem->GetGUID().ToString().c_str(), newItem->GetCount(), bid, buyout, auctionTime, AH->GetHouseId()); #endif sAuctionMgr->AddAItem(newItem); auctionHouse->AddAuction(AH); @@ -382,7 +401,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_PLACE_BID"); #endif - uint64 auctioneer; + ObjectGuid auctioneer; uint32 auctionId; uint32 price; recvData >> auctioneer; @@ -395,7 +414,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData) if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleAuctionPlaceBid - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer))); + LOG_DEBUG("network", "WORLD: HandleAuctionPlaceBid - Unit (%s) not found or you can't interact with him.", auctioneer.ToString().c_str()); #endif return; } @@ -409,7 +428,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData) AuctionEntry* auction = auctionHouse->GetAuction(auctionId); Player* player = GetPlayer(); - if (!auction || auction->owner == player->GetGUIDLow()) + if (!auction || auction->owner == player->GetGUID()) { //you cannot bid your own auction: SendAuctionCommandResult(0, AUCTION_PLACE_BID, ERR_AUCTION_BID_OWN); @@ -417,8 +436,8 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData) } // impossible have online own another character (use this for speedup check in case online owner) - Player* auction_owner = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)); - if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == GetAccountId()) + Player* auction_owner = ObjectAccessor::FindConnectedPlayer(auction->owner); + if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(auction->owner.GetCounter()) == GetAccountId()) { //you cannot bid your another character auction: SendAuctionCommandResult(0, AUCTION_PLACE_BID, ERR_AUCTION_BID_OWN); @@ -448,9 +467,9 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData) if (price < auction->buyout || auction->buyout == 0) { - if (auction->bidder > 0) + if (auction->bidder) { - if (auction->bidder == player->GetGUIDLow()) + if (auction->bidder == player->GetGUID()) player->ModifyMoney(-int32(price - auction->bid)); else { @@ -462,12 +481,12 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData) else player->ModifyMoney(-int32(price)); - auction->bidder = player->GetGUIDLow(); + auction->bidder = player->GetGUID(); auction->bid = price; GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_AUCTION_BID); - stmt->setUInt32(0, auction->bidder); + stmt->setUInt32(0, auction->bidder.GetCounter()); stmt->setUInt32(1, auction->bid); stmt->setUInt32(2, auction->Id); trans->Append(stmt); @@ -477,7 +496,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData) else { //buyout: - if (player->GetGUIDLow() == auction->bidder) + if (player->GetGUID() == auction->bidder) player->ModifyMoney(-int32(auction->buyout - auction->bid)); else { @@ -485,7 +504,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData) if (auction->bidder) //buyout for bidded auction .. sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, GetPlayer(), trans); } - auction->bidder = player->GetGUIDLow(); + auction->bidder = player->GetGUID(); auction->bid = auction->buyout; GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, auction->buyout); @@ -498,7 +517,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData) auction->DeleteFromDB(trans); - sAuctionMgr->RemoveAItem(auction->item_guidlow); + sAuctionMgr->RemoveAItem(auction->item_guid); auctionHouse->RemoveAuction(auction); } player->SaveInventoryAndGoldToDB(trans); @@ -512,7 +531,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_REMOVE_ITEM"); #endif - uint64 auctioneer; + ObjectGuid auctioneer; uint32 auctionId; recvData >> auctioneer; recvData >> auctionId; @@ -521,7 +540,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recvData) if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleAuctionRemoveItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer))); + LOG_DEBUG("network", "WORLD: HandleAuctionRemoveItem - Unit (%s) not found or you can't interact with him.", auctioneer.ToString().c_str()); #endif return; } @@ -536,12 +555,12 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recvData) Player* player = GetPlayer(); SQLTransaction trans = CharacterDatabase.BeginTransaction(); - if (auction && auction->owner == player->GetGUIDLow()) + if (auction && auction->owner == player->GetGUID()) { - Item* pItem = sAuctionMgr->GetAItem(auction->item_guidlow); + Item* pItem = sAuctionMgr->GetAItem(auction->item_guid); if (pItem) { - if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid + if (auction->bidder) // If we have a bidder, we have to send him the money he paid { uint32 auctionCut = auction->GetAuctionCut(); if (!player->HasEnoughMoney(auctionCut)) //player doesn't have enough money, maybe message needed @@ -552,13 +571,13 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recvData) } // item will deleted or added to received mail list - MailDraft(auction->BuildAuctionMailSubject(AUCTION_CANCELED), AuctionEntry::BuildAuctionMailBody(0, 0, auction->buyout, auction->deposit, 0)) + MailDraft(auction->BuildAuctionMailSubject(AUCTION_CANCELED), AuctionEntry::BuildAuctionMailBody(ObjectGuid::Empty, 0, auction->buyout, auction->deposit, 0)) .AddItem(pItem) .SendMailTo(trans, player, auction, MAIL_CHECK_MASK_COPIED); } else { - LOG_ERROR("server", "Auction id: %u has non-existed item (item guid : %u)!!!", auction->Id, auction->item_guidlow); + LOG_ERROR("server", "Auction id: %u has non-existed item (item: %s)!!!", auction->Id, auction->item_guid.ToString().c_str()); SendAuctionCommandResult(0, AUCTION_CANCEL, ERR_AUCTION_DATABASE_ERROR); return; } @@ -567,7 +586,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recvData) { SendAuctionCommandResult(0, AUCTION_CANCEL, ERR_AUCTION_DATABASE_ERROR); //this code isn't possible ... maybe there should be assert - LOG_ERROR("server", "CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is nullptr", player->GetGUIDLow(), auctionId); + LOG_ERROR("server", "CHEATER : %s, he tried to cancel auction (id: %u) of another player, or auction is nullptr", player->GetGUID().ToString().c_str(), auctionId); return; } @@ -580,7 +599,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recvData) auction->DeleteFromDB(trans); CharacterDatabase.CommitTransaction(trans); - sAuctionMgr->RemoveAItem(auction->item_guidlow); + sAuctionMgr->RemoveAItem(auction->item_guid); auctionHouse->RemoveAuction(auction); } @@ -591,7 +610,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_LIST_BIDDER_ITEMS"); #endif - uint64 guid; //NPC guid + ObjectGuid guid; //NPC guid uint32 listfrom; //page of auctions uint32 outbiddedCount; //count of outbidded auctions @@ -608,7 +627,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket& recvData) if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleAuctionListBidderItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleAuctionListBidderItems - Unit (%s) not found or you can't interact with him.", guid.ToString().c_str()); #endif recvData.rfinish(); return; @@ -649,7 +668,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket& recvData) void WorldSession::HandleAuctionListOwnerItems(WorldPacket& recvData) { // prevent crash caused by malformed packet - uint64 guid; + ObjectGuid guid; uint32 listfrom; recvData >> guid; @@ -668,7 +687,7 @@ void WorldSession::HandleAuctionListOwnerItems(WorldPacket& recvData) _player->m_Events.AddEvent(new AuctionListOwnerItemsDelayEvent(guid, _player->GetGUID(), true), _player->m_Events.CalculateTime(delay - diff)); } -void WorldSession::HandleAuctionListOwnerItemsEvent(uint64 creatureGuid) +void WorldSession::HandleAuctionListOwnerItemsEvent(ObjectGuid creatureGuid) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_LIST_OWNER_ITEMS"); @@ -680,7 +699,7 @@ void WorldSession::HandleAuctionListOwnerItemsEvent(uint64 creatureGuid) if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleAuctionListOwnerItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(creatureGuid))); + LOG_DEBUG("network", "WORLD: HandleAuctionListOwnerItems - Unit (%s) not found or you can't interact with him.", creatureGuid.ToString().c_str()); #endif return; } @@ -714,7 +733,7 @@ void WorldSession::HandleAuctionListItems(WorldPacket& recvData) std::string searchedname; uint8 levelmin, levelmax, usable; uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality; - uint64 guid; + ObjectGuid guid; recvData >> guid; recvData >> listfrom; // start, used for page control listing by 50 elements diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index 705310fdc1..563677be94 100644 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -25,10 +25,10 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid))); + LOG_DEBUG("network", "WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from (%s)", guid.ToString().c_str()); #endif Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); @@ -53,7 +53,7 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recvData) SendBattleGroundList(guid, bgTypeId); } -void WorldSession::SendBattleGroundList(uint64 guid, BattlegroundTypeId bgTypeId) +void WorldSession::SendBattleGroundList(ObjectGuid guid, BattlegroundTypeId bgTypeId) { WorldPacket data; sBattlegroundMgr->BuildBattlegroundListPacket(&data, guid, _player, bgTypeId, 0); @@ -62,7 +62,7 @@ void WorldSession::SendBattleGroundList(uint64 guid, BattlegroundTypeId bgTypeId void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; uint32 bgTypeId_; uint32 instanceId; // sent to queue for particular bg from battlemaster's list, currently not used uint8 joinAsGroup; @@ -279,14 +279,14 @@ void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket& /*recvDa Player* allianceFlagCarrier = nullptr; Player* hordeFlagCarrier = nullptr; - if (uint64 guid = bg->GetFlagPickerGUID(TEAM_ALLIANCE)) + if (ObjectGuid guid = bg->GetFlagPickerGUID(TEAM_ALLIANCE)) { allianceFlagCarrier = ObjectAccessor::FindPlayer(guid); if (allianceFlagCarrier) ++flagCarrierCount; } - if (uint64 guid = bg->GetFlagPickerGUID(TEAM_HORDE)) + if (ObjectGuid guid = bg->GetFlagPickerGUID(TEAM_HORDE)) { hordeFlagCarrier = ObjectAccessor::FindPlayer(guid); if (hordeFlagCarrier) @@ -303,14 +303,14 @@ void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket& /*recvDa data << flagCarrierCount; if (allianceFlagCarrier) { - data << uint64(allianceFlagCarrier->GetGUID()); + data << allianceFlagCarrier->GetGUID(); data << float(allianceFlagCarrier->GetPositionX()); data << float(allianceFlagCarrier->GetPositionY()); } if (hordeFlagCarrier) { - data << uint64(hordeFlagCarrier->GetGUID()); + data << hordeFlagCarrier->GetGUID(); data << float(hordeFlagCarrier->GetPositionX()); data << float(hordeFlagCarrier->GetPositionY()); } @@ -361,7 +361,7 @@ void WorldSession::HandleBattlefieldListOpcode(WorldPacket& recvData) return; WorldPacket data; - sBattlegroundMgr->BuildBattlegroundListPacket(&data, 0, _player, BattlegroundTypeId(bgTypeId), fromWhere); + sBattlegroundMgr->BuildBattlegroundListPacket(&data, ObjectGuid::Empty, _player, BattlegroundTypeId(bgTypeId), fromWhere); SendPacket(&data); } @@ -479,7 +479,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recvData) if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK); - stmt->setUInt32(0, _player->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_QUEUE); CharacterDatabase.Execute(stmt); } @@ -576,7 +576,7 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket& /*recvData*/) void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData) { - uint64 guid; // arena Battlemaster guid + ObjectGuid guid; // arena Battlemaster guid uint8 arenaslot; // 2v2, 3v3 or 5v5 uint8 asGroup; // asGroup uint8 isRated; // isRated @@ -801,7 +801,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData) void WorldSession::HandleReportPvPAFK(WorldPacket& recvData) { - uint64 playerGuid; + ObjectGuid playerGuid; recvData >> playerGuid; Player* reportedPlayer = ObjectAccessor::FindPlayer(playerGuid); diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 6d2c40c369..569e1a7e6c 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -38,8 +38,8 @@ Copied events should probably have a new owner void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) { - uint64 guid = _player->GetGUID(); - LOG_DEBUG("network", "CMSG_CALENDAR_GET_CALENDAR [" UI64FMTD "]", guid); + ObjectGuid guid = _player->GetGUID(); + LOG_DEBUG("network", "CMSG_CALENDAR_GET_CALENDAR [%s]", guid.ToString().c_str()); time_t currTime = time(nullptr); @@ -57,12 +57,12 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent((*itr)->GetEventId())) { data << uint8(calendarEvent->IsGuildEvent()); - data.appendPackGUID(calendarEvent->GetCreatorGUID()); + data << calendarEvent->GetCreatorGUID().WriteAsPacked(); } else { data << uint8(0); - data.appendPackGUID((*itr)->GetSenderGUID()); + data << (*itr)->GetSenderGUID().WriteAsPacked(); } } @@ -78,7 +78,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) data.AppendPackedTime(calendarEvent->GetEventTime()); data << uint32(calendarEvent->GetFlags()); data << int32(calendarEvent->GetDungeonId()); - data.appendPackGUID(calendarEvent->GetCreatorGUID()); + data << calendarEvent->GetCreatorGUID().WriteAsPacked(); } data << uint32(currTime); // server time @@ -88,7 +88,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) uint32 boundCounter = 0; for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(_player->GetGUIDLow(), Difficulty(i)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(_player->GetGUID(), Difficulty(i)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { if (itr->second.perm) @@ -98,7 +98,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) dataBuffer << uint32(save->GetMapId()); dataBuffer << uint32(save->GetDifficulty()); dataBuffer << uint32(resetTime >= currTime ? resetTime - currTime : 0); - dataBuffer << uint64(MAKE_NEW_GUID(save->GetInstanceId(), 0, HIGHGUID_INSTANCE)); // instance save id as unique instance copy id + dataBuffer << ObjectGuid::Create<HighGuid::Instance>(save->GetInstanceId()); // instance save id as unique instance copy id ++boundCounter; } } @@ -171,8 +171,7 @@ void WorldSession::HandleCalendarGetEvent(WorldPacket& recvData) uint64 eventId; recvData >> eventId; - LOG_DEBUG("network", "CMSG_CALENDAR_GET_EVENT. Player [" - UI64FMTD "] Event [" UI64FMTD "]", _player->GetGUID(), eventId); + LOG_DEBUG("network", "CMSG_CALENDAR_GET_EVENT. Player [%s] Event [" UI64FMTD "]", _player->GetGUID().ToString().c_str(), eventId); if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) sCalendarMgr->SendCalendarEvent(_player->GetGUID(), *calendarEvent, CALENDAR_SENDTYPE_GET); @@ -182,7 +181,7 @@ void WorldSession::HandleCalendarGetEvent(WorldPacket& recvData) void WorldSession::HandleCalendarGuildFilter(WorldPacket& recvData) { - LOG_DEBUG("network", "CMSG_CALENDAR_GUILD_FILTER [" UI64FMTD "]", _player->GetGUID()); + LOG_DEBUG("network", "CMSG_CALENDAR_GUILD_FILTER [%s]", _player->GetGUID().ToString().c_str()); uint32 minLevel; uint32 maxLevel; @@ -198,7 +197,7 @@ void WorldSession::HandleCalendarGuildFilter(WorldPacket& recvData) void WorldSession::HandleCalendarArenaTeam(WorldPacket& recvData) { - LOG_DEBUG("network", "CMSG_CALENDAR_ARENA_TEAM [" UI64FMTD "]", _player->GetGUID()); + LOG_DEBUG("network", "CMSG_CALENDAR_ARENA_TEAM [%s]", _player->GetGUID().ToString().c_str()); uint32 arenaTeamId; recvData >> arenaTeamId; @@ -207,11 +206,12 @@ void WorldSession::HandleCalendarArenaTeam(WorldPacket& recvData) team->MassInviteToEvent(this); } -bool validUtf8String(WorldPacket& recvData, std::string& s, std::string action, uint64 playerGUID) +bool validUtf8String(WorldPacket& recvData, std::string& s, std::string action, ObjectGuid playerGUID) { if (!utf8::is_valid(s.begin(), s.end())) { - LOG_INFO("server", "CalendarHandler: Player with guid %llu attempt to %s an event with invalid name or description (packet modification)", (unsigned long long)playerGUID, action.c_str()); + LOG_INFO("server", "CalendarHandler: Player (%s) attempt to %s an event with invalid name or description (packet modification)", + playerGUID.ToString().c_str(), action.c_str()); recvData.rfinish(); return false; } @@ -220,7 +220,7 @@ bool validUtf8String(WorldPacket& recvData, std::string& s, std::string action, void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); + ObjectGuid guid = _player->GetGUID(); std::string title; std::string description; @@ -293,23 +293,22 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) time_t(eventPackedTime), flags, time_t(unkPackedTime), title, description); if (calendarEvent->IsGuildEvent() || calendarEvent->IsGuildAnnouncement()) - if (Player* creator = ObjectAccessor::FindPlayerInOrOutOfWorld(guid)) + if (Player* creator = ObjectAccessor::FindConnectedPlayer(guid)) calendarEvent->SetGuildId(creator->GetGuildId()); if (calendarEvent->IsGuildAnnouncement()) { // 946684800 is 01/01/2000 00:00:00 - default response time - CalendarInvite* invite = new CalendarInvite(0, calendarEvent->GetEventId(), 0, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, ""); + CalendarInvite* invite = new CalendarInvite(0, calendarEvent->GetEventId(), ObjectGuid::Empty, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, ""); sCalendarMgr->AddInvite(calendarEvent, invite); } else { uint32 inviteCount; - uint64 invitee[CALENDAR_MAX_INVITES]; + ObjectGuid invitee[CALENDAR_MAX_INVITES]; uint8 status[CALENDAR_MAX_INVITES]; uint8 rank[CALENDAR_MAX_INVITES]; - memset(invitee, 0, sizeof(invitee)); memset(status, 0, sizeof(status)); memset(rank, 0, sizeof(rank)); @@ -319,7 +318,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) for (uint32 i = 0; i < inviteCount && i < CALENDAR_MAX_INVITES; ++i) { - recvData.readPackGUID(invitee[i]); + recvData >> invitee[i].ReadAsPacked(); recvData >> status[i] >> rank[i]; } } @@ -350,7 +349,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); + ObjectGuid guid = _player->GetGUID(); time_t oldEventTime; uint64 eventId; @@ -382,10 +381,10 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) return; } - LOG_DEBUG("network", "CMSG_CALENDAR_UPDATE_EVENT [" UI64FMTD "] EventId [" UI64FMTD + LOG_DEBUG("network", "CMSG_CALENDAR_UPDATE_EVENT [%s] EventId [" UI64FMTD "], InviteId [" UI64FMTD "] Title %s, Description %s, type %u " "Repeatable %u, MaxInvites %u, Dungeon ID %d, Time %u " - "Time2 %u, Flags %u", guid, eventId, inviteId, title.c_str(), + "Time2 %u, Flags %u", guid.ToString().c_str(), eventId, inviteId, title.c_str(), description.c_str(), type, repetitionType, maxInvites, dungeonId, eventPackedTime, timeZoneTime, flags); @@ -410,7 +409,7 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); + ObjectGuid guid = _player->GetGUID(); uint64 eventId; recvData >> eventId; @@ -421,15 +420,15 @@ void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recvData) void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); + ObjectGuid guid = _player->GetGUID(); uint64 eventId; uint64 inviteId; uint32 eventTime; recvData >> eventId >> inviteId; recvData.ReadPackedTime(eventTime); - LOG_DEBUG("network", "CMSG_CALENDAR_COPY_EVENT [" UI64FMTD "], EventId [" UI64FMTD - "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, eventTime); + LOG_DEBUG("network", "CMSG_CALENDAR_COPY_EVENT [%s], EventId [" UI64FMTD + "] inviteId [" UI64FMTD "] Time: %u", guid.ToString().c_str(), eventId, inviteId, eventTime); // prevent events in the past // To Do: properly handle timezones and remove the "- time_t(86400L)" hack @@ -509,7 +508,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) { LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_INVITE"); - uint64 playerGuid = _player->GetGUID(); + ObjectGuid playerGuid = _player->GetGUID(); uint64 eventId; uint64 inviteId; @@ -517,7 +516,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) bool isPreInvite; bool isGuildEvent; - uint64 inviteeGuid = 0; + ObjectGuid inviteeGuid; uint32 inviteeTeamId = TEAM_NEUTRAL; uint32 inviteeGuildId = 0; @@ -533,11 +532,11 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) else { // xinef: Get Data From global storage - if (uint32 guidLow = sWorld->GetGlobalPlayerGUID(name)) + if (ObjectGuid guid = sWorld->GetGlobalPlayerGUID(name)) { - if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guidLow)) + if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid.GetCounter())) { - inviteeGuid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER); + inviteeGuid = guid; inviteeTeamId = Player::TeamIdForRace(playerData->race); inviteeGuildId = playerData->guildId; } @@ -557,7 +556,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) } // xinef: zomg! sync query - if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = " UI64FMTD " AND friend = " UI64FMTD, inviteeGuid, playerGuid)) + if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = %u AND friend = %u", inviteeGuid.GetCounter(), playerGuid.GetCounter())) { Field* fields = result->Fetch(); if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED) @@ -601,12 +600,12 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) void WorldSession::HandleCalendarEventSignup(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); + ObjectGuid guid = _player->GetGUID(); uint64 eventId; bool tentative; recvData >> eventId >> tentative; - LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_SIGNUP [" UI64FMTD "] EventId [" UI64FMTD "] Tentative %u", guid, eventId, tentative); + LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_SIGNUP [%s] EventId [" UI64FMTD "] Tentative %u", guid.ToString().c_str(), eventId, tentative); if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) { @@ -627,14 +626,14 @@ void WorldSession::HandleCalendarEventSignup(WorldPacket& recvData) void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); + ObjectGuid guid = _player->GetGUID(); uint64 eventId; uint64 inviteId; uint32 status; recvData >> eventId >> inviteId >> status; - LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_RSVP [" UI64FMTD"] EventId [" - UI64FMTD "], InviteId [" UI64FMTD "], status %u", guid, eventId, + LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_RSVP [%s] EventId [" + UI64FMTD "], InviteId [" UI64FMTD "], status %u", guid.ToString().c_str(), eventId, inviteId, status); if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) @@ -664,19 +663,17 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData) void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); - uint64 invitee; + ObjectGuid guid = _player->GetGUID(); + ObjectGuid invitee; uint64 eventId; uint64 ownerInviteId; // isn't it sender's inviteId? uint64 inviteId; - recvData.readPackGUID(invitee); + recvData>> invitee.ReadAsPacked(); recvData >> inviteId >> ownerInviteId >> eventId; - LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_REMOVE_INVITE [" - UI64FMTD "] EventId [" UI64FMTD "], ownerInviteId [" - UI64FMTD "], Invitee ([" UI64FMTD "] id: [" UI64FMTD "])", - guid, eventId, ownerInviteId, invitee, inviteId); + LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_REMOVE_INVITE [%s] EventId [" UI64FMTD "], ownerInviteId [" UI64FMTD "], Invitee ([%s] id: [" UI64FMTD "])", + guid.ToString().c_str(), eventId, ownerInviteId, invitee.ToString().c_str(), inviteId); if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) { @@ -694,18 +691,17 @@ void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recvData) void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); - uint64 invitee; + ObjectGuid guid = _player->GetGUID(); + ObjectGuid invitee; uint64 eventId; uint64 inviteId; uint64 ownerInviteId; // isn't it sender's inviteId? uint8 status; - recvData.readPackGUID(invitee); + recvData >> invitee.ReadAsPacked(); recvData >> eventId >> inviteId >> ownerInviteId >> status; - LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_STATUS [" UI64FMTD"] EventId [" - UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" - UI64FMTD "], status %u", guid, eventId, ownerInviteId, invitee, inviteId, status); + LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_STATUS [%s] EventId [" UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee (%s) id: [" UI64FMTD "], status %u", + guid.ToString().c_str(), eventId, ownerInviteId, invitee.ToString().c_str(), inviteId, status); if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) { @@ -728,18 +724,18 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData) void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); - uint64 invitee; + ObjectGuid guid = _player->GetGUID(); + ObjectGuid invitee; uint64 eventId; uint64 inviteId; uint64 ownerInviteId; // isn't it sender's inviteId? uint8 rank; - recvData.readPackGUID(invitee); + recvData>> invitee.ReadAsPacked(); recvData >> eventId >> inviteId >> ownerInviteId >> rank; - LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_MODERATOR_STATUS [" UI64FMTD "] EventId [" - UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" - UI64FMTD "], rank %u", guid, eventId, ownerInviteId, invitee, inviteId, rank); + LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_MODERATOR_STATUS [%s] EventId [" + UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([%s] id: [" + UI64FMTD "], rank %u", guid.ToString().c_str(), eventId, ownerInviteId, invitee.ToString().c_str(), inviteId, rank); if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) { @@ -758,24 +754,23 @@ void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recvData) void WorldSession::HandleCalendarComplain(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); + ObjectGuid guid = _player->GetGUID(); uint64 eventId; - uint64 complainGUID; + ObjectGuid complainGUID; recvData >> eventId >> complainGUID; - LOG_DEBUG("network", "CMSG_CALENDAR_COMPLAIN [" UI64FMTD "] EventId [" - UI64FMTD "] guid [" UI64FMTD "]", guid, eventId, complainGUID); + LOG_DEBUG("network", "CMSG_CALENDAR_COMPLAIN [%s] EventId [" + UI64FMTD "] guid [%s]", guid.ToString().c_str(), eventId, complainGUID.ToString().c_str()); // what to do with complains? } void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recvData*/) { - uint64 guid = _player->GetGUID(); + ObjectGuid guid = _player->GetGUID(); uint32 pending = sCalendarMgr->GetPlayerNumPending(guid); - LOG_DEBUG("network", "CMSG_CALENDAR_GET_NUM_PENDING: [" UI64FMTD - "] Pending: %u", guid, pending); + LOG_DEBUG("network", "CMSG_CALENDAR_GET_NUM_PENDING: [%s] Pending: %u", guid.ToString().c_str(), pending); WorldPacket data(SMSG_CALENDAR_SEND_NUM_PENDING, 4); data << uint32(pending); @@ -792,7 +787,7 @@ void WorldSession::HandleSetSavedInstanceExtend(WorldPacket& recvData) if (!entry || !entry->IsRaid()) return; - InstancePlayerBind* instanceBind = sInstanceSaveMgr->PlayerGetBoundInstance(GetPlayer()->GetGUIDLow(), mapId, Difficulty(difficulty)); + InstancePlayerBind* instanceBind = sInstanceSaveMgr->PlayerGetBoundInstance(GetPlayer()->GetGUID(), mapId, Difficulty(difficulty)); if (!instanceBind || !instanceBind->perm || (bool)toggleExtendOn == instanceBind->extended) return; @@ -801,7 +796,7 @@ void WorldSession::HandleSetSavedInstanceExtend(WorldPacket& recvData) // update in db PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INSTANCE_EXTENDED); stmt->setUInt8(0, toggleExtendOn ? 1 : 0); - stmt->setUInt32(1, GetPlayer()->GetGUIDLow()); + stmt->setUInt32(1, GetPlayer()->GetGUID().GetCounter()); stmt->setUInt32(2, instanceBind->save->GetInstanceId()); CharacterDatabase.Execute(stmt); @@ -825,7 +820,7 @@ void WorldSession::SendCalendarRaidLockout(InstanceSave const* save, bool add) data << uint32(save->GetMapId()); data << uint32(save->GetDifficulty()); data << uint32(save->GetResetTime() >= currTime ? save->GetResetTime() - currTime : 0); - data << uint64(MAKE_NEW_GUID(save->GetInstanceId(), 0, HIGHGUID_INSTANCE)); + data << ObjectGuid::Create<HighGuid::Instance>(save->GetInstanceId()); SendPacket(&data); } diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 2346dd793f..c2d0dbdf4e 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -48,11 +48,11 @@ class LoginQueryHolder : public SQLQueryHolder { private: uint32 m_accountId; - uint64 m_guid; + ObjectGuid m_guid; public: - LoginQueryHolder(uint32 accountId, uint64 guid) + LoginQueryHolder(uint32 accountId, ObjectGuid guid) : m_accountId(accountId), m_guid(guid) { } - uint64 GetGuid() const { return m_guid; } + ObjectGuid GetGuid() const { return m_guid; } uint32 GetAccountId() const { return m_accountId; } bool Initialize(); }; @@ -62,7 +62,7 @@ bool LoginQueryHolder::Initialize() SetSize(MAX_PLAYER_LOGIN_QUERY); bool res = true; - uint32 lowGuid = GUID_LOPART(m_guid); + ObjectGuid::LowType lowGuid = m_guid.GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER); stmt->setUInt32(0, lowGuid); @@ -193,6 +193,10 @@ bool LoginQueryHolder::Initialize() stmt->setUInt32(0, m_accountId); res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_INSTANCE_LOCK_TIMES, stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSE_LOCATION); + stmt->setUInt64(0, lowGuid); + res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_CORPSE_LOCATION, stmt); + return res; } @@ -209,13 +213,13 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result) { do { - uint32 guidlow = (*result)[0].GetUInt32(); + ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].GetUInt32()); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Loading char guid %u from account %u.", guidlow, GetAccountId()); + LOG_DEBUG("server", "Loading char %s from account %u.", guid.ToString().c_str(), GetAccountId()); #endif if (Player::BuildEnumData(result, &data)) { - _legitCharacters.insert(guidlow); + _legitCharacters.insert(guid); ++num; } } while (result->NextRow()); @@ -617,7 +621,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte Player newChar(this); newChar.GetMotionMaster()->Initialize(); - if (!newChar.Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PLAYER), createInfo)) + if (!newChar.Create(sObjectMgr->GetGenerator<HighGuid::Player>().Generate(), createInfo)) { // Player not create (race/class/etc problem?) newChar.CleanupsBeforeDelete(); @@ -660,11 +664,11 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte std::string IP_str = GetRemoteAddress(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow()); + LOG_DEBUG("server", "Account: %d (IP: %s) Create Character:[%s] (%s)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUID().ToString().c_str()); #endif - LOG_INFO("entities.player", "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow()); + LOG_INFO("entities.player", "Account: %d (IP: %s) Create Character:[%s] (%s)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUID().ToString().c_str()); sScriptMgr->OnPlayerCreate(&newChar); - sWorld->AddGlobalPlayerData(newChar.GetGUIDLow(), GetAccountId(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel(), 0, 0); + sWorld->AddGlobalPlayerData(newChar.GetGUID().GetCounter(), GetAccountId(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel(), 0, 0); newChar.CleanupsBeforeDelete(); delete createInfo; @@ -676,13 +680,14 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; + // Initiating uint32 initAccountId = GetAccountId(); // can't delete loaded character - if (ObjectAccessor::FindPlayerInOrOutOfWorld(guid) || sWorld->FindOfflineSessionForCharacterGUID(GUID_LOPART(guid))) + if (ObjectAccessor::FindConnectedPlayer(guid) || sWorld->FindOfflineSessionForCharacterGUID(guid.GetCounter())) { sScriptMgr->OnPlayerFailedDelete(guid, initAccountId); WorldPacket data(SMSG_CHAR_DELETE, 1); @@ -714,7 +719,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData) return; } - if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid))) + if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid.GetCounter())) { accountId = playerData->accountId; name = playerData->name; @@ -729,9 +734,9 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData) std::string IP_str = GetRemoteAddress(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid)); + LOG_DEBUG("server", "Account: %d (IP: %s) Delete Character:[%s] (%s)", GetAccountId(), IP_str.c_str(), name.c_str(), guid.ToString().c_str()); #endif - LOG_INFO("entities.player", "Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid)); + LOG_INFO("entities.player", "Account: %d (IP: %s) Delete Character:[%s] (%s)", GetAccountId(), IP_str.c_str(), name.c_str(), guid.ToString().c_str()); // To prevent hook failure, place hook before removing reference from DB sScriptMgr->OnPlayerDelete(guid, initAccountId); // To prevent race conditioning, but as it also makes sense, we hand the accountId over for successful delete. @@ -740,15 +745,14 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData) if (sLog->ShouldLog("entities.player.dump", LogLevel::LOG_LEVEL_INFO)) // optimize GetPlayerDump call { std::string dump; - - if (PlayerDumpWriter().GetDump(GUID_LOPART(guid), dump))\ - LOG_CHAR_DUMP(dump.c_str(), GetAccountId(), GUID_LOPART(guid), name.c_str()); + if (PlayerDumpWriter().GetDump(guid.GetCounter(), dump)) + LOG_CHAR_DUMP(dump.c_str(), GetAccountId(), guid.GetCounter(), name.c_str()); } sCalendarMgr->RemoveAllPlayerEventsAndInvites(guid); - Player::DeleteFromDB(guid, GetAccountId(), true, false); + Player::DeleteFromDB(guid.GetCounter(), GetAccountId(), true, false); - sWorld->DeleteGlobalPlayerData(GUID_LOPART(guid), name); + sWorld->DeleteGlobalPlayerData(guid.GetCounter(), name); WorldPacket data(SMSG_CHAR_DELETE, 1); data << (uint8)CHAR_DELETE_SUCCESS; SendPacket(&data); @@ -763,18 +767,18 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData) return; } - uint64 playerGuid = 0; + ObjectGuid playerGuid; recvData >> playerGuid; - if (!IsLegitCharacterForAccount(GUID_LOPART(playerGuid))) + if (!playerGuid.IsPlayer() || !IsLegitCharacterForAccount(playerGuid)) { - LOG_ERROR("server", "Account (%u) can't login with that character (%u).", GetAccountId(), GUID_LOPART(playerGuid)); + LOG_ERROR("server", "Account (%u) can't login with that character (%s).", GetAccountId(), playerGuid.ToString().c_str()); KickPlayer("Account can't login with this character"); return; } // pussywizard: - if (WorldSession* sess = sWorld->FindOfflineSessionForCharacterGUID(GUID_LOPART(playerGuid))) + if (WorldSession* sess = sWorld->FindOfflineSessionForCharacterGUID(playerGuid.GetCounter())) if (sess->GetAccountId() != GetAccountId()) { WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1); @@ -835,7 +839,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData) if (!plMover) break; WorldPacket pkt(MSG_MOVE_TELEPORT_ACK, 20); - pkt.append(plMover->GetPackGUID()); + pkt << plMover->GetPackGUID(); pkt << uint32(0); // flags pkt << uint32(0); // time sess->HandleMoveTeleportAck(pkt); @@ -874,14 +878,14 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData) void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) { - uint64 playerGuid = holder->GetGuid(); + ObjectGuid playerGuid = holder->GetGuid(); Player* pCurrChar = new Player(this); // for send server info and strings (config) ChatHandler chH = ChatHandler(this); // "GetAccountId() == db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools) - if (!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder)) + if (!pCurrChar->LoadFromDB(playerGuid, holder)) { SetPlayer(nullptr); KickPlayer("HandlePlayerLoginFromDB"); // disconnect client, player no set to session and it will not deleted or saved at kick @@ -924,7 +928,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) #endif } - if (uint32 guildId = Player::GetGuildIdFromStorage(pCurrChar->GetGUIDLow())) + if (uint32 guildId = Player::GetGuildIdFromStorage(pCurrChar->GetGUID().GetCounter())) { Guild* guild = sGuildMgr->GetGuildById(guildId); Guild::Member const* member = guild ? guild->GetMember(pCurrChar->GetGUID()) : nullptr; @@ -936,7 +940,8 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) } else { - LOG_ERROR("server", "Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), guildId); + LOG_ERROR("server", "Player %s (%s) marked as member of not existing guild (id: %u), removing guild membership for player.", + pCurrChar->GetName().c_str(), pCurrChar->GetGUID().ToString().c_str(), guildId); pCurrChar->SetInGuild(0); pCurrChar->SetRank(0); } @@ -973,7 +978,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) } // Xinef: moved this from below - sObjectAccessor->AddObject(pCurrChar); + ObjectAccessor::AddObject(pCurrChar); if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) { @@ -984,15 +989,10 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY, pCurrChar->m_homebindZ, pCurrChar->GetOrientation()); } - // pussywizard: optimization - std::string charName = pCurrChar->GetName(); - std::transform(charName.begin(), charName.end(), charName.begin(), ::tolower); - sObjectAccessor->playerNameToPlayerPointer[charName] = pCurrChar; - pCurrChar->SendInitialPacketsAfterAddToMap(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ONLINE); - stmt->setUInt32(0, pCurrChar->GetGUIDLow()); + stmt->setUInt32(0, pCurrChar->GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_ONLINE); @@ -1030,10 +1030,10 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) } // friend status - sSocialMgr->SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), true); + sSocialMgr->SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUID(), true); // Place character in world (and load zone) before some object loading - pCurrChar->LoadCorpse(); + pCurrChar->LoadCorpse(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_CORPSE_LOCATION)); // setting Ghost+speed if dead if (pCurrChar->m_deathState != ALIVE) @@ -1128,8 +1128,8 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) SendNotification(LANG_GM_ON); std::string IP_str = GetRemoteAddress(); - LOG_INFO("entities.player", "Account: %d (IP: %s) Login Character:[%s] (GUID: %u) Level: %d", - GetAccountId(), IP_str.c_str(), pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), pCurrChar->getLevel()); + LOG_INFO("entities.player", "Account: %d (IP: %s) Login Character:[%s] (%s) Level: %d", + GetAccountId(), IP_str.c_str(), pCurrChar->GetName().c_str(), pCurrChar->GetGUID().ToString().c_str(), pCurrChar->getLevel()); if (!pCurrChar->IsStandState() && !pCurrChar->HasUnitState(UNIT_STATE_STUNNED)) pCurrChar->SetStandState(UNIT_STAND_STATE_STAND); @@ -1423,7 +1423,7 @@ void WorldSession::HandleShowingCloakOpcode(WorldPacket& recvData) void WorldSession::HandleCharRenameOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; std::string newName; recvData >> guid; @@ -1443,7 +1443,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recvData) { WorldPacket data(SMSG_CHAR_RENAME, 1 + 8 + (newName.size() + 1)); data << uint8(res); - data << uint64(guid); + data << guid; data << newName; SendPacket(&data); return; @@ -1464,7 +1464,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recvData) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_FREE_NAME); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt32(1, GetAccountId()); stmt->setUInt16(2, AT_LOGIN_RENAME); stmt->setUInt16(3, AT_LOGIN_RENAME); @@ -1485,13 +1485,13 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu Field* fields = result->Fetch(); - uint32 guidLow = fields[0].GetUInt32(); + ObjectGuid::LowType guidLow = fields[0].GetUInt32(); std::string oldName = fields[1].GetString(); - uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER); + ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(guidLow); // pussywizard: - if (ObjectAccessor::FindPlayerInOrOutOfWorld(guid) || sWorld->FindOfflineSessionForCharacterGUID(guidLow)) + if (ObjectAccessor::FindConnectedPlayer(guid) || sWorld->FindOfflineSessionForCharacterGUID(guidLow)) { WorldPacket data(SMSG_CHAR_RENAME, 1); data << uint8(CHAR_CREATE_ERROR); @@ -1522,7 +1522,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu WorldPacket data(SMSG_CHAR_RENAME, 1 + 8 + (newName.size() + 1)); data << uint8(RESPONSE_SUCCESS); - data << uint64(guid); + data << guid; data << newName; SendPacket(&data); @@ -1537,17 +1537,17 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) if (!sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED)) return; - uint64 guid; + ObjectGuid guid; recvData >> guid; // not accept declined names for unsupported languages std::string name; - if (!sObjectMgr->GetPlayerNameByGUID(guid, name)) + if (!sObjectMgr->GetPlayerNameByGUID(guid.GetCounter(), name)) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); - data << uint64(guid); + data << guid; SendPacket(&data); return; } @@ -1557,7 +1557,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); - data << uint64(guid); + data << guid; SendPacket(&data); return; } @@ -1566,7 +1566,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); - data << uint64(guid); + data << guid; SendPacket(&data); return; } @@ -1580,7 +1580,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); - data << uint64(guid); + data << guid; SendPacket(&data); return; } @@ -1592,7 +1592,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); - data << uint64(guid); + data << guid; SendPacket(&data); return; } @@ -1602,7 +1602,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); - data << uint64(guid); + data << guid; SendPacket(&data); return; } @@ -1613,11 +1613,11 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_DECLINED_NAME); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_DECLINED_NAME); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); for (uint8 i = 0; i < 5; i++) stmt->setString(i + 1, declinedname.name[i]); @@ -1628,7 +1628,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(0); // OK - data << uint64(guid); + data << guid; SendPacket(&data); } @@ -1732,21 +1732,21 @@ void WorldSession::HandleRemoveGlyph(WorldPacket& recvData) void WorldSession::HandleCharCustomize(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; std::string newName; recvData >> guid; - if (!IsLegitCharacterForAccount(GUID_LOPART(guid))) + if (!IsLegitCharacterForAccount(guid)) { - LOG_ERROR("server", "Account %u, IP: %s tried to customise character %u, but it does not belong to their account!", - GetAccountId(), GetRemoteAddress().c_str(), GUID_LOPART(guid)); + LOG_ERROR("server", "Account %u, IP: %s tried to customise character %s, but it does not belong to their account!", + GetAccountId(), GetRemoteAddress().c_str(), guid.ToString().c_str()); recvData.rfinish(); KickPlayer("HandleCharCustomize"); return; } // pussywizard: - if (ObjectAccessor::FindPlayerInOrOutOfWorld(guid) || sWorld->FindOfflineSessionForCharacterGUID(GUID_LOPART(guid))) + if (ObjectAccessor::FindConnectedPlayer(guid) || sWorld->FindOfflineSessionForCharacterGUID(guid.GetCounter())) { recvData.rfinish(); WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); @@ -1763,7 +1763,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData) // xinef: zomg! sync query PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_AT_LOGIN); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -1776,7 +1776,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData) } // get the players old (at this moment current) race - GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid)); + GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid.GetCounter()); if (!playerData) { WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); @@ -1824,7 +1824,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData) } // character with this name already exist - if (uint64 newguid = sObjectMgr->GetPlayerGUIDByName(newName)) + if (ObjectGuid newguid = sObjectMgr->GetPlayerGUIDByName(newName)) { if (newguid != guid) { @@ -1835,7 +1835,8 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData) } } - LOG_INFO("entities.player", "Account: %d (IP: %s), Character [%s] (guid: %u) Customized to: %s", GetAccountId(), GetRemoteAddress().c_str(), playerData->name.c_str(), GUID_LOPART(guid), newName.c_str()); + LOG_INFO("entities.player", "Account: %d (IP: %s), Character [%s] (%s) Customized to: %s", + GetAccountId(), GetRemoteAddress().c_str(), playerData->name.c_str(), guid.ToString().c_str(), newName.c_str()); Player::Customize(guid, gender, skin, face, hairStyle, hairColor, facialHair); @@ -1843,7 +1844,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData) stmt->setString(0, newName); stmt->setUInt16(1, uint16(AT_LOGIN_CUSTOMIZE)); - stmt->setUInt32(2, GUID_LOPART(guid)); + stmt->setUInt32(2, guid.GetCounter()); CharacterDatabase.Execute(stmt); @@ -1851,18 +1852,18 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); CharacterDatabase.Execute(stmt); } // xinef: update global data - sWorld->UpdateGlobalNameData(GUID_LOPART(guid), playerData->name, newName); - sWorld->UpdateGlobalPlayerData(GUID_LOPART(guid), PLAYER_UPDATE_DATA_NAME | PLAYER_UPDATE_DATA_GENDER, newName, 0, gender); + sWorld->UpdateGlobalNameData(guid.GetCounter(), playerData->name, newName); + sWorld->UpdateGlobalPlayerData(guid.GetCounter(), PLAYER_UPDATE_DATA_NAME | PLAYER_UPDATE_DATA_GENDER, newName, 0, gender); WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1 + 8 + (newName.size() + 1) + 6); data << uint8(RESPONSE_SUCCESS); - data << uint64(guid); + data << guid; data << newName; data << uint8(gender); data << uint8(skin); @@ -1902,18 +1903,18 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket& recvData) for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) { - uint64 itemGuid; - recvData.readPackGUID(itemGuid); + ObjectGuid itemGuid; + recvData >> itemGuid.ReadAsPacked(); // xinef: if client sends 0, it means empty slot - if (itemGuid == 0) + if (!itemGuid) { - eqSet.Items[i] = 0; + eqSet.Items[i].Clear(); continue; } // equipment manager sends "1" (as raw GUID) for slots set to "ignore" (don't touch slot at equip set) - if (itemGuid == 1) + if (itemGuid.GetRawValue() == 1) { // ignored slots saved as bit mask because we have no free special values for Items[i] eqSet.IgnoreMask |= 1 << i; @@ -1924,11 +1925,11 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket& recvData) Item* item = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (!item || item->GetGUID() != itemGuid) { - eqSet.Items[i] = 0; + eqSet.Items[i].Clear(); continue; } - eqSet.Items[i] = GUID_LOPART(itemGuid); + eqSet.Items[i] = itemGuid; } _player->SetEquipmentSet(index, eqSet); @@ -1954,18 +1955,18 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData) for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) { - uint64 itemGuid; - recvData.readPackGUID(itemGuid); + ObjectGuid itemGuid; + recvData >> itemGuid.ReadAsPacked(); uint8 srcbag, srcslot; recvData >> srcbag >> srcslot; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("entities.player.items", "Item " UI64FMTD ": srcbag %u, srcslot %u", itemGuid, srcbag, srcslot); + LOG_DEBUG("entities.player.items", "Item %s: srcbag %u, srcslot %u", itemGuid.ToString().c_str(), srcbag, srcslot); #endif // check if item slot is set to "ignored" (raw value == 1), must not be unequipped then - if (itemGuid == 1) + if (itemGuid.GetRawValue() == 1) continue; // Only equip weapons in combat @@ -1973,7 +1974,7 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData) continue; Item* item = nullptr; - if (itemGuid > 0) + if (itemGuid) item = _player->GetItemByGuid(itemGuid); uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8); @@ -2036,22 +2037,22 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData) void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; std::string newname; uint8 gender, skin, face, hairStyle, hairColor, facialHair, race; recvData >> guid; - if (!IsLegitCharacterForAccount(GUID_LOPART(guid))) + if (!IsLegitCharacterForAccount(guid)) { - LOG_ERROR("server", "Account %u, IP: %s tried to factionchange character %u, but it does not belong to their account!", - GetAccountId(), GetRemoteAddress().c_str(), GUID_LOPART(guid)); + LOG_ERROR("server", "Account %u, IP: %s tried to factionchange character %s, but it does not belong to their account!", + GetAccountId(), GetRemoteAddress().c_str(), guid.ToString().c_str()); recvData.rfinish(); KickPlayer("HandleCharFactionOrRaceChange"); return; } // pussywizard: - if (ObjectAccessor::FindPlayerInOrOutOfWorld(guid) || sWorld->FindOfflineSessionForCharacterGUID(GUID_LOPART(guid))) + if (ObjectAccessor::FindConnectedPlayer(guid) || sWorld->FindOfflineSessionForCharacterGUID(guid.GetCounter())) { recvData.rfinish(); WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1); @@ -2063,7 +2064,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) recvData >> newname; recvData >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face >> race; - uint32 lowGuid = GUID_LOPART(guid); + ObjectGuid::LowType lowGuid = guid.GetCounter(); // get the players old (at this moment current) race GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(lowGuid); @@ -2115,7 +2116,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) for (; itr != _end; ++itr) { AuctionEntry* Aentry = itr->second; - if (Aentry && (Aentry->owner == lowGuid || Aentry->bidder == lowGuid)) + if (Aentry && (Aentry->owner == guid || Aentry->bidder == guid)) { has_auctions = true; break; @@ -2239,7 +2240,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) } // character with this name already exist - if (uint64 newguid = sObjectMgr->GetPlayerGUIDByName(newname)) + if (ObjectGuid newguid = sObjectMgr->GetPlayerGUIDByName(newname)) { if (newguid != guid) { @@ -2252,8 +2253,12 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) CharacterDatabase.EscapeString(newname); Player::Customize(guid, gender, skin, face, hairStyle, hairColor, facialHair); + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + // resurrect the character in case he's dead + Player::OfflineResurrect(guid, trans); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_FACTION_OR_RACE); stmt->setString(0, newname); stmt->setUInt8(1, race); @@ -2268,9 +2273,8 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) LOG_INFO("entities.player", "Account: %d (IP: %s), Character [%s] (guid: %u) Changed Race/Faction to: %s", GetAccountId(), GetRemoteAddress().c_str(), playerData->name.c_str(), lowGuid, newname.c_str()); // xinef: update global data - sWorld->UpdateGlobalNameData(GUID_LOPART(guid), playerData->name, newname); - sWorld->UpdateGlobalPlayerData(GUID_LOPART(guid), - PLAYER_UPDATE_DATA_NAME | PLAYER_UPDATE_DATA_RACE | PLAYER_UPDATE_DATA_GENDER, newname, 0, gender, race); + sWorld->UpdateGlobalNameData(lowGuid, playerData->name, newname); + sWorld->UpdateGlobalPlayerData(lowGuid, PLAYER_UPDATE_DATA_NAME | PLAYER_UPDATE_DATA_RACE | PLAYER_UPDATE_DATA_GENDER, newname, 0, gender, race); if (oldRace != race) { @@ -2404,7 +2408,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) { if (uint32 guildId = playerData->guildId) if (Guild* guild = sGuildMgr->GetGuildById(guildId)) - guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER), false, false, true); + guild->DeleteMember(guid, false, false, true); } if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND)) @@ -2436,7 +2440,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) stmt->setFloat (3, -8867.68f); stmt->setFloat (4, 673.373f); stmt->setFloat (5, 97.9034f); - Player::SavePositionInDB(0, -8867.68f, 673.373f, 97.9034f, 0.0f, 1519, lowGuid); + Player::SavePositionInDB(0, -8867.68f, 673.373f, 97.9034f, 0.0f, 1519, guid); } else { @@ -2445,7 +2449,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) stmt->setFloat (3, 1633.33f); stmt->setFloat (4, -4439.11f); stmt->setFloat (5, 15.7588f); - Player::SavePositionInDB(1, 1633.33f, -4439.11f, 15.7588f, 0.0f, 1637, lowGuid); + Player::SavePositionInDB(1, 1633.33f, -4439.11f, 15.7588f, 0.0f, 1637, guid); } trans->Append(stmt); @@ -2480,13 +2484,13 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE); stmt->setUInt32(0, new_entry); stmt->setUInt32(1, old_entry); - stmt->setUInt32(2, guid); + stmt->setUInt32(2, guid.GetCounter()); trans->Append(stmt); } // Delete all current quests stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); trans->Append(stmt); // Quest conversion @@ -2675,7 +2679,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1 + 8 + (newname.size() + 1) + 1 + 1 + 1 + 1 + 1 + 1 + 1); data << uint8(RESPONSE_SUCCESS); - data << uint64(guid); + data << guid; data << newname; data << uint8(gender); data << uint8(skin); diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp index fc42514556..757716dc36 100644 --- a/src/server/game/Handlers/ChatHandler.cpp +++ b/src/server/game/Handlers/ChatHandler.cpp @@ -152,8 +152,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) } break; default: - LOG_ERROR("network", "Player %s (GUID: %u) sent a chatmessage with an invalid language/message type combination", - GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); + LOG_ERROR("network", "Player %s (%s) sent a chatmessage with an invalid language/message type combination", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); recvData.rfinish(); return; @@ -276,8 +276,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) { if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) && !ChatHandler(this).isValidChatMessage(msg.c_str())) { - //LOG_ERROR("server", "Player %s (GUID: %u) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName().c_str(), - // GetPlayer()->GetGUIDLow(), msg.c_str()); + //LOG_ERROR("server", "Player %s (%s) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName().c_str(), + // GetPlayer()->GetGUID().ToString().c_str(), msg.c_str()); if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK)) KickPlayer("CONFIG_CHAT_STRICT_LINK_CHECKING_KICK"); @@ -686,7 +686,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData) return; uint32 text_emote, emoteNum; - uint64 guid; + ObjectGuid guid; recvData >> text_emote; recvData >> emoteNum; @@ -737,13 +737,13 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData) void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recvData) { - uint64 iguid; + ObjectGuid iguid; uint8 unk; recvData >> iguid; recvData >> unk; // probably related to spam reporting - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(iguid); + Player* player = ObjectAccessor::FindConnectedPlayer(iguid); if (!player) return; diff --git a/src/server/game/Handlers/CombatHandler.cpp b/src/server/game/Handlers/CombatHandler.cpp index 06cbbd77cc..bd002953fc 100644 --- a/src/server/game/Handlers/CombatHandler.cpp +++ b/src/server/game/Handlers/CombatHandler.cpp @@ -18,11 +18,11 @@ void WorldSession::HandleAttackSwingOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Recvd CMSG_ATTACKSWING Message guidlow:%u guidhigh:%u", GUID_LOPART(guid), GUID_HIPART(guid)); + LOG_DEBUG("network", "WORLD: Recvd CMSG_ATTACKSWING: %s", guid.ToString().c_str()); #endif Unit* pEnemy = ObjectAccessor::GetUnit(*_player, guid); @@ -80,8 +80,8 @@ void WorldSession::HandleSetSheathedOpcode(WorldPacket& recvData) void WorldSession::SendAttackStop(Unit const* enemy) { WorldPacket data(SMSG_ATTACKSTOP, (8 + 8 + 4)); // we guess size - data.append(GetPlayer()->GetPackGUID()); - data.append(enemy ? enemy->GetPackGUID() : 0); // must be packed guid + data << GetPlayer()->GetPackGUID(); + data << (enemy ? enemy->GetPackGUID() : PackedGuid()); // must be packed guid data << uint32(0); // unk, can be 1 also SendPacket(&data); } diff --git a/src/server/game/Handlers/DuelHandler.cpp b/src/server/game/Handlers/DuelHandler.cpp index c4e102f279..af4cef0313 100644 --- a/src/server/game/Handlers/DuelHandler.cpp +++ b/src/server/game/Handlers/DuelHandler.cpp @@ -14,7 +14,7 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) { - uint64 guid; + ObjectGuid guid; Player* player; Player* plTarget; @@ -30,8 +30,8 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) return; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player 1 is: %u (%s)", player->GetGUIDLow(), player->GetName().c_str()); - LOG_DEBUG("server", "Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName().c_str()); + LOG_DEBUG("server", "Player 1 is: %s (%s)", player->GetGUID().ToString().c_str(), player->GetName().c_str()); + LOG_DEBUG("server", "Player 2 is: %s (%s)", plTarget->GetGUID().ToString().c_str(), plTarget->GetName().c_str()); #endif time_t now = time(nullptr); @@ -47,7 +47,7 @@ void WorldSession::HandleDuelCancelledOpcode(WorldPacket& recvPacket) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Received CMSG_DUEL_CANCELLED"); #endif - uint64 guid; + ObjectGuid guid; recvPacket >> guid; // no duel requested diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index cac059de7b..e819616772 100644 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -109,7 +109,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData) return; } - if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) + if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUID())) { SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S); return; @@ -233,7 +233,8 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData) if (group->GetLeaderGUID() == GetPlayer()->GetGUID()) { - LOG_ERROR("server", "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); + LOG_ERROR("server", "HandleGroupAcceptOpcode: player %s (%s) tried to accept an invite to his own group", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); return; } @@ -244,7 +245,7 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData) return; } - Player* leader = ObjectAccessor::FindPlayerInOrOutOfWorld(group->GetLeaderGUID()); + Player* leader = ObjectAccessor::FindConnectedPlayer(group->GetLeaderGUID()); // Forming a new group, create it if (!group->IsCreated()) @@ -281,7 +282,7 @@ void WorldSession::HandleGroupDeclineOpcode(WorldPacket& /*recvData*/) return; // Remember leader if online (group pointer will be invalid if group gets disbanded) - Player* leader = ObjectAccessor::FindPlayerInOrOutOfWorld(group->GetLeaderGUID()); + Player* leader = ObjectAccessor::FindConnectedPlayer(group->GetLeaderGUID()); // uninvite, group can be deleted GetPlayer()->UninviteFromGroup(); @@ -301,7 +302,7 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_UNINVITE_GUID"); #endif - uint64 guid; + ObjectGuid guid; std::string reason, name; recvData >> guid; recvData >> reason; @@ -309,12 +310,13 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData) //can't uninvite yourself if (guid == GetPlayer()->GetGUID()) { - LOG_ERROR("server", "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); + LOG_ERROR("server", "WorldSession::HandleGroupUninviteGuidOpcode: leader %s (%s) tried to uninvite himself from the group.", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); return; } // Xinef: name is properly filled in packets - sObjectMgr->GetPlayerNameByGUID(guid, name); + sObjectMgr->GetPlayerNameByGUID(guid.GetCounter(), name); PartyResult res = GetPlayer()->CanUninviteFromGroup(); if (res != ERR_PARTY_RESULT_OK) @@ -371,7 +373,8 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket& recvData) // can't uninvite yourself if (GetPlayer()->GetName() == membername) { - LOG_ERROR("server", "WorldSession::HandleGroupUninviteOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); + LOG_ERROR("server", "WorldSession::HandleGroupUninviteOpcode: leader %s (%s) tried to uninvite himself from the group.", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); return; } @@ -386,7 +389,7 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket& recvData) if (!grp) return; - if (uint64 guid = grp->GetMemberGUID(membername)) + if (ObjectGuid guid = grp->GetMemberGUID(membername)) { Player::RemoveFromGroup(grp, guid, GROUP_REMOVEMETHOD_KICK, GetPlayer()->GetGUID()); return; @@ -407,10 +410,10 @@ void WorldSession::HandleGroupSetLeaderOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_SET_LEADER"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* player = ObjectAccessor::FindConnectedPlayer(guid); Group* group = GetPlayer()->GetGroup(); if (!group || !player) @@ -456,7 +459,7 @@ void WorldSession::HandleLootMethodOpcode(WorldPacket& recvData) #endif uint32 lootMethod; - uint64 lootMaster; + ObjectGuid lootMaster; uint32 lootThreshold; recvData >> lootMethod >> lootMaster >> lootThreshold; @@ -488,7 +491,7 @@ void WorldSession::HandleLootMethodOpcode(WorldPacket& recvData) void WorldSession::HandleLootRoll(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; uint32 itemSlot; uint8 rollType; recvData >> guid; // guid of the item rolled @@ -530,7 +533,7 @@ void WorldSession::HandleMinimapPingOpcode(WorldPacket& recvData) // everything's fine, do it WorldPacket data(MSG_MINIMAP_PING, (8 + 4 + 4)); - data << uint64(GetPlayer()->GetGUID()); + data << GetPlayer()->GetGUID(); data << float(x); data << float(y); GetPlayer()->GetGroup()->BroadcastPacket(&data, true, -1, GetPlayer()->GetGUID()); @@ -558,7 +561,7 @@ void WorldSession::HandleRandomRollOpcode(WorldPacket& recvData) data << uint32(minimum); data << uint32(maximum); data << uint32(roll); - data << uint64(GetPlayer()->GetGUID()); + data << GetPlayer()->GetGUID(); if (GetPlayer()->GetGroup()) GetPlayer()->GetGroup()->BroadcastPacket(&data, false); else @@ -591,12 +594,12 @@ void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recvData) if (group->isRaidGroup() && !group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) return; - uint64 guid; + ObjectGuid guid; recvData >> guid; - if (IS_PLAYER_GUID(guid)) + if (guid.IsPlayer()) { - Player* target = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* target = ObjectAccessor::FindConnectedPlayer(guid); if (!target || target->IsHostileTo(GetPlayer())) return; @@ -648,7 +651,7 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recvData) if (groupNr >= MAX_RAID_SUBGROUPS) return; - uint64 senderGuid = GetPlayer()->GetGUID(); + ObjectGuid senderGuid = GetPlayer()->GetGUID(); if (!group->IsLeader(senderGuid) && !group->IsAssistant(senderGuid)) return; @@ -656,7 +659,7 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recvData) return; Player* movedPlayer = ObjectAccessor::FindPlayerByName(name, false); - uint64 guid; + ObjectGuid guid; if (movedPlayer) { guid = movedPlayer->GetGUID(); @@ -683,7 +686,7 @@ void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket& recvData) if (!group->IsLeader(GetPlayer()->GetGUID())) return; - uint64 guid; + ObjectGuid guid; bool apply; recvData >> guid; recvData >> apply; @@ -703,13 +706,13 @@ void WorldSession::HandlePartyAssignmentOpcode(WorldPacket& recvData) if (!group) return; - uint64 senderGuid = GetPlayer()->GetGUID(); + ObjectGuid senderGuid = GetPlayer()->GetGUID(); if (!group->IsLeader(senderGuid) && !group->IsAssistant(senderGuid)) return; uint8 assignment; bool apply; - uint64 guid; + ObjectGuid guid; recvData >> assignment >> apply; recvData >> guid; @@ -771,7 +774,7 @@ void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket& recvData) // everything's fine, do it WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9); - data << uint64(GetPlayer()->GetGUID()); + data << GetPlayer()->GetGUID(); data << uint8(state); group->BroadcastReadyCheck(&data); } @@ -808,7 +811,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke byteCount += GroupUpdateLength[i]; data->Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount); - data->append(player->GetPackGUID()); + *data << player->GetPackGUID(); *data << uint32(mask); if (mask & GROUP_UPDATE_FLAG_STATUS) @@ -884,7 +887,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke if (mask & GROUP_UPDATE_FLAG_PET_GUID) { if (pet) - *data << (uint64) pet->GetGUID(); + *data << pet->GetGUID(); else *data << (uint64) 0; } @@ -978,7 +981,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData) { LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS"); - uint64 Guid; + ObjectGuid Guid; recvData >> Guid; Player* player = HashMapHolder<Player>::Find(Guid); @@ -986,7 +989,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData) { WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3 + 4 + 2); data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related - data.appendPackGUID(Guid); + data << Guid.WriteAsPacked(); data << uint32(GROUP_UPDATE_FLAG_STATUS); data << uint16(MEMBER_STATUS_OFFLINE); SendPacket(&data); @@ -998,7 +1001,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData) WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4 + 2 + 2 + 2 + 1 + 2 * 6 + 8 + 1 + 8); data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related - data.append(player->GetPackGUID()); + data << player->GetPackGUID(); uint32 updateFlags = GROUP_UPDATE_FLAG_STATUS | GROUP_UPDATE_FLAG_CUR_HP | GROUP_UPDATE_FLAG_MAX_HP | GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER | GROUP_UPDATE_FLAG_LEVEL @@ -1066,7 +1069,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData) data.put<uint64>(maskPos, auraMask); // GROUP_UPDATE_FLAG_AURAS if (pet && (updateFlags & GROUP_UPDATE_FLAG_PET_GUID)) - data << uint64(pet->GetGUID()); + data << pet->GetGUID(); data << std::string(pet ? pet->GetName() : ""); // GROUP_UPDATE_FLAG_PET_NAME data << uint16(pet ? pet->GetDisplayId() : 0); // GROUP_UPDATE_FLAG_PET_MODEL_ID @@ -1167,7 +1170,7 @@ void WorldSession::HandleGroupSwapSubGroupOpcode(WorldPacket& recv_data) // no player, cheating? if (!group->GetMemberGUID(playerName)) { - return uint64(0); + return ObjectGuid::Empty; } if (Player* player = ObjectAccessor::FindPlayerByName(playerName.c_str())) @@ -1176,19 +1179,19 @@ void WorldSession::HandleGroupSwapSubGroupOpcode(WorldPacket& recv_data) } else { - if (uint64 guid = sObjectMgr->GetPlayerGUIDByName(playerName)) + if (ObjectGuid guid = sObjectMgr->GetPlayerGUIDByName(playerName)) { return guid; } else { - return uint64(0); // no player - again, cheating? + return ObjectGuid::Empty; // no player - again, cheating? } } }; - uint64 guid1 = getGuid(playerName1); - uint64 guid2 = getGuid(playerName2); + ObjectGuid guid1 = getGuid(playerName1); + ObjectGuid guid2 = getGuid(playerName2); if(!guid1 || !guid2) { diff --git a/src/server/game/Handlers/GuildHandler.cpp b/src/server/game/Handlers/GuildHandler.cpp index a424e26f3a..d3d4fe94b8 100644 --- a/src/server/game/Handlers/GuildHandler.cpp +++ b/src/server/game/Handlers/GuildHandler.cpp @@ -342,16 +342,15 @@ void WorldSession::HandleGuildChangeInfoTextOpcode(WorldPacket& recvPacket) void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket) { - uint64 vendorGuid; + ObjectGuid vendorGuid; recvPacket >> vendorGuid; EmblemInfo emblemInfo; emblemInfo.ReadPacket(recvPacket); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("guild", "MSG_SAVE_GUILD_EMBLEM [%s]: Guid: [" UI64FMTD - "] Style: %d, Color: %d, BorderStyle: %d, BorderColor: %d, BackgroundColor: %d" - , GetPlayerInfo().c_str(), vendorGuid, emblemInfo.GetStyle() + LOG_DEBUG("guild", "MSG_SAVE_GUILD_EMBLEM [%s]: Guid: [%s] Style: %d, Color: %d, BorderStyle: %d, BorderColor: %d, BackgroundColor: %d" + , GetPlayerInfo().c_str(), vendorGuid.ToString().c_str(), emblemInfo.GetStyle() , emblemInfo.GetColor(), emblemInfo.GetBorderStyle() , emblemInfo.GetBorderColor(), emblemInfo.GetBackgroundColor()); #endif @@ -403,13 +402,13 @@ void WorldSession::HandleGuildPermissions(WorldPacket& /* recvData */) // Called when clicking on Guild bank gameobject void WorldSession::HandleGuildBankerActivate(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; bool sendAllSlots; recvData >> guid >> sendAllSlots; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("guild", "CMSG_GUILD_BANKER_ACTIVATE [%s]: Go: [" UI64FMTD "] AllSlots: %u" - , GetPlayerInfo().c_str(), guid, sendAllSlots); + LOG_DEBUG("guild", "CMSG_GUILD_BANKER_ACTIVATE [%s]: Go: [%s] AllSlots: %u" + , GetPlayerInfo().c_str(), guid.ToString().c_str(), sendAllSlots); #endif Guild* const guild = GetPlayer()->GetGuild(); if (!guild) @@ -424,15 +423,15 @@ void WorldSession::HandleGuildBankerActivate(WorldPacket& recvData) // Called when opening guild bank tab only (first one) void WorldSession::HandleGuildBankQueryTab(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; uint8 tabId; bool full; recvData >> guid >> tabId >> full; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("guild", "CMSG_GUILD_BANK_QUERY_TAB [%s]: Go: [" UI64FMTD "], TabId: %u, ShowTabs: %u" - , GetPlayerInfo().c_str(), guid, tabId, full); + LOG_DEBUG("guild", "CMSG_GUILD_BANK_QUERY_TAB [%s]: Go: [%s], TabId: %u, ShowTabs: %u" + , GetPlayerInfo().c_str(), guid.ToString().c_str(), tabId, full); #endif if (GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK)) if (Guild* guild = GetPlayer()->GetGuild()) @@ -441,13 +440,13 @@ void WorldSession::HandleGuildBankQueryTab(WorldPacket& recvData) void WorldSession::HandleGuildBankDepositMoney(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; uint32 money; recvData >> guid >> money; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("guild", "CMSG_GUILD_BANK_DEPOSIT_MONEY [%s]: Go: [" UI64FMTD "], money: %u", - GetPlayerInfo().c_str(), guid, money); + LOG_DEBUG("guild", "CMSG_GUILD_BANK_DEPOSIT_MONEY [%s]: Go: [%s], money: %u", + GetPlayerInfo().c_str(), guid.ToString().c_str(), money); #endif if (GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK)) if (money && GetPlayer()->HasEnoughMoney(money)) @@ -457,13 +456,13 @@ void WorldSession::HandleGuildBankDepositMoney(WorldPacket& recvData) void WorldSession::HandleGuildBankWithdrawMoney(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; uint32 money; recvData >> guid >> money; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("guild", "CMSG_GUILD_BANK_WITHDRAW_MONEY [%s]: Go: [" UI64FMTD "], money: %u", - GetPlayerInfo().c_str(), guid, money); + LOG_DEBUG("guild", "CMSG_GUILD_BANK_WITHDRAW_MONEY [%s]: Go: [%s], money: %u", + GetPlayerInfo().c_str(), guid.ToString().c_str(), money); #endif if (money && GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK)) if (Guild* guild = GetPlayer()->GetGuild()) @@ -476,7 +475,7 @@ void WorldSession::HandleGuildBankSwapItems(WorldPacket& recvData) LOG_DEBUG("guild", "CMSG_GUILD_BANK_SWAP_ITEMS [%s]", GetPlayerInfo().c_str()); #endif - uint64 GoGuid; + ObjectGuid GoGuid; recvData >> GoGuid; if (!GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) @@ -555,13 +554,13 @@ void WorldSession::HandleGuildBankSwapItems(WorldPacket& recvData) void WorldSession::HandleGuildBankBuyTab(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; uint8 tabId; recvData >> guid >> tabId; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("guild", "CMSG_GUILD_BANK_BUY_TAB [%s]: Go: [" UI64FMTD "], TabId: %u", GetPlayerInfo().c_str(), guid, tabId); + LOG_DEBUG("guild", "CMSG_GUILD_BANK_BUY_TAB [%s]: Go: [%s], TabId: %u", GetPlayerInfo().c_str(), guid.ToString().c_str(), tabId); #endif if (GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK)) @@ -571,15 +570,15 @@ void WorldSession::HandleGuildBankBuyTab(WorldPacket& recvData) void WorldSession::HandleGuildBankUpdateTab(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; uint8 tabId; std::string name, icon; recvData >> guid >> tabId >> name >> icon; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("guild", "CMSG_GUILD_BANK_UPDATE_TAB [%s]: Go: [" UI64FMTD "], TabId: %u, Name: %s, Icon: %s" - , GetPlayerInfo().c_str(), guid, tabId, name.c_str(), icon.c_str()); + LOG_DEBUG("guild", "CMSG_GUILD_BANK_UPDATE_TAB [%s]: Go: [%s], TabId: %u, Name: %s, Icon: %s" + , GetPlayerInfo().c_str(), guid.ToString().c_str(), tabId, name.c_str(), icon.c_str()); #endif // Check for overflow diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 049cc3a634..f48429ea3c 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -74,13 +74,13 @@ void WorldSession::HandleSwapInvItemOpcode(WorldPacket& recvData) if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, srcslot) && !CanUseBank()) { - //TC_LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + //TC_LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str()); return; } if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, dstslot) && !CanUseBank()) { - //TC_LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + //TC_LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str()); return; } @@ -92,7 +92,7 @@ void WorldSession::HandleSwapInvItemOpcode(WorldPacket& recvData) void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPacket& recvData) { - uint64 itemguid; + ObjectGuid itemguid; uint8 dstslot; recvData >> itemguid >> dstslot; @@ -137,13 +137,13 @@ void WorldSession::HandleSwapItem(WorldPacket& recvData) if (_player->IsBankPos(srcbag, srcslot) && !CanUseBank()) { - //TC_LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + //TC_LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str()); return; } if (_player->IsBankPos(dstbag, dstslot) && !CanUseBank()) { - //TC_LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + //TC_LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str()); return; } @@ -625,7 +625,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Received CMSG_SELL_ITEM"); #endif - uint64 vendorguid, itemguid; + ObjectGuid vendorguid, itemguid; uint32 count; recvData >> vendorguid >> itemguid >> count; @@ -637,7 +637,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData) if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(vendorguid))); + LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - Unit (%s) not found or you can not interact with him.", vendorguid.ToString().c_str()); #endif _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, itemguid, 0); return; @@ -756,7 +756,7 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Received CMSG_BUYBACK_ITEM"); #endif - uint64 vendorguid; + ObjectGuid vendorguid; uint32 slot; recvData >> vendorguid >> slot; @@ -765,9 +765,9 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData) if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleBuybackItem - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(vendorguid))); + LOG_DEBUG("network", "WORLD: HandleBuybackItem - Unit (%s) not found or you can not interact with him.", vendorguid.ToString().c_str()); #endif - _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, 0, 0); + _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, ObjectGuid::Empty, 0); return; } @@ -792,7 +792,7 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData) if (sWorld->getBoolConfig(CONFIG_ITEMDELETE_VENDOR)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_RECOVERY_ITEM); - stmt->setUInt32(0, _player->GetGUID()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); stmt->setUInt32(1, pItem->GetEntry()); stmt->setUInt32(2, pItem->GetCount()); CharacterDatabase.Execute(stmt); @@ -817,7 +817,7 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Received CMSG_BUY_ITEM_IN_SLOT"); #endif - uint64 vendorguid, bagguid; + ObjectGuid vendorguid, bagguid; uint32 item, slot, count; uint8 bagslot; @@ -861,7 +861,7 @@ void WorldSession::HandleBuyItemOpcode(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Received CMSG_BUY_ITEM"); #endif - uint64 vendorguid; + ObjectGuid vendorguid; uint32 item, slot, count; uint8 unk1; @@ -878,7 +878,7 @@ void WorldSession::HandleBuyItemOpcode(WorldPacket& recvData) void WorldSession::HandleListInventoryOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; @@ -892,7 +892,7 @@ void WorldSession::HandleListInventoryOpcode(WorldPacket& recvData) SendListInventory(guid); } -void WorldSession::SendListInventory(uint64 vendorGuid, uint32 vendorEntry) +void WorldSession::SendListInventory(ObjectGuid vendorGuid, uint32 vendorEntry) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Sent SMSG_LIST_INVENTORY"); @@ -902,9 +902,9 @@ void WorldSession::SendListInventory(uint64 vendorGuid, uint32 vendorEntry) if (!vendor) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: SendListInventory - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(vendorGuid))); + LOG_DEBUG("network", "WORLD: SendListInventory - Unit (%s) not found or you can not interact with him.", vendorGuid.ToString().c_str()); #endif - _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, 0, 0); + _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, ObjectGuid::Empty, 0); return; } @@ -922,7 +922,7 @@ void WorldSession::SendListInventory(uint64 vendorGuid, uint32 vendorEntry) if (!items) { WorldPacket data(SMSG_LIST_INVENTORY, 8 + 1 + 1); - data << uint64(vendorGuid); + data << vendorGuid; data << uint8(0); // count == 0, next will be error code data << uint8(0); // "Vendor has no inventory" SendPacket(&data); @@ -933,7 +933,7 @@ void WorldSession::SendListInventory(uint64 vendorGuid, uint32 vendorEntry) uint8 count = 0; WorldPacket data(SMSG_LIST_INVENTORY, 8 + 1 + itemCount * 8 * 4); - data << uint64(vendorGuid); + data << vendorGuid; size_t countPos = data.wpos(); data << uint8(count); @@ -1053,12 +1053,12 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) LOG_DEBUG("network", "WORLD: CMSG_BUY_BANK_SLOT"); #endif - uint64 guid; + ObjectGuid guid; recvPacket >> guid; if (!CanUseBank(guid)) { - //TC_LOG_DEBUG("network", "WORLD: HandleBuyBankSlotOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + //TC_LOG_DEBUG("network", "WORLD: HandleBuyBankSlotOpcode - Unit (%s) not found or you can't interact with him.", guid.ToString().c_str()); return; } @@ -1114,7 +1114,7 @@ void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) if (!CanUseBank()) { - //TC_LOG_DEBUG("network", "WORLD: HandleAutoBankItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + //TC_LOG_DEBUG("network", "WORLD: HandleAutoBankItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str()); return; } @@ -1156,7 +1156,7 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket) if (!CanUseBank()) { - //TC_LOG_DEBUG("network", "WORLD: HandleAutoStoreBankItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + //TC_LOG_DEBUG("network", "WORLD: HandleAutoStoreBankItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str()); return; } @@ -1223,24 +1223,24 @@ void WorldSession::HandleSetAmmoOpcode(WorldPacket& recvData) _player->RemoveAmmo(); } -void WorldSession::SendEnchantmentLog(uint64 target, uint64 caster, uint32 itemId, uint32 enchantId) +void WorldSession::SendEnchantmentLog(ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId) { WorldPacket data(SMSG_ENCHANTMENTLOG, (8 + 8 + 4 + 4)); // last check 2.0.10 - data.appendPackGUID(target); - data.appendPackGUID(caster); + data << target.WriteAsPacked(); + data << caster.WriteAsPacked(); data << uint32(itemId); data << uint32(enchantId); GetPlayer()->SendMessageToSet(&data, true); } -void WorldSession::SendItemEnchantTimeUpdate(uint64 Playerguid, uint64 Itemguid, uint32 slot, uint32 Duration) +void WorldSession::SendItemEnchantTimeUpdate(ObjectGuid Playerguid, ObjectGuid Itemguid, uint32 slot, uint32 Duration) { // last check 2.0.10 WorldPacket data(SMSG_ITEM_ENCHANT_TIME_UPDATE, (8 + 4 + 4 + 8)); - data << uint64(Itemguid); + data << Itemguid; data << uint32(slot); data << uint32(Duration); - data << uint64(Playerguid); + data << Playerguid; SendPacket(&data); } @@ -1325,7 +1325,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData) return; } - if (item->GetUInt64Value(ITEM_FIELD_GIFTCREATOR)) // HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED); + if (item->GetGuidValue(ITEM_FIELD_GIFTCREATOR)) // HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED); { _player->SendEquipError(EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, nullptr); return; @@ -1359,8 +1359,8 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData) SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_GIFT); - stmt->setUInt32(0, GUID_LOPART(item->GetOwnerGUID())); - stmt->setUInt32(1, item->GetGUIDLow()); + stmt->setUInt32(0, item->GetOwnerGUID().GetCounter()); + stmt->setUInt32(1, item->GetGUID().GetCounter()); stmt->setUInt32(2, item->GetEntry()); stmt->setUInt32(3, item->GetUInt32Value(ITEM_FIELD_FLAGS)); trans->Append(stmt); @@ -1388,7 +1388,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData) item->SetEntry(21831); break; } - item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, _player->GetGUID()); + item->SetGuidValue(ITEM_FIELD_GIFTCREATOR, _player->GetGUID()); item->SetUInt32Value(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED); item->SetState(ITEM_CHANGED, _player); @@ -1407,8 +1407,8 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: CMSG_SOCKET_GEMS"); #endif - uint64 item_guid; - uint64 gem_guids[MAX_GEM_SOCKETS]; + ObjectGuid item_guid; + ObjectGuid gem_guids[MAX_GEM_SOCKETS]; recvData >> item_guid; if (!item_guid) @@ -1633,7 +1633,7 @@ void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: CMSG_ITEM_REFUND_INFO"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; // item guid Item* item = _player->GetItemByGuid(guid); @@ -1653,7 +1653,7 @@ void WorldSession::HandleItemRefund(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: CMSG_ITEM_REFUND"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; // item guid Item* item = _player->GetItemByGuid(guid); @@ -1679,11 +1679,11 @@ void WorldSession::HandleItemRefund(WorldPacket& recvData) */ void WorldSession::HandleItemTextQuery(WorldPacket& recvData ) { - uint64 itemGuid; + ObjectGuid itemGuid; recvData >> itemGuid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_ITEM_TEXT_QUERY item guid: %u", GUID_LOPART(itemGuid)); + LOG_DEBUG("network", "CMSG_ITEM_TEXT_QUERY item: %s", itemGuid.ToString().c_str()); #endif WorldPacket data(SMSG_ITEM_TEXT_QUERY_RESPONSE, 50); // guess size @@ -1691,7 +1691,7 @@ void WorldSession::HandleItemTextQuery(WorldPacket& recvData ) if (Item* item = _player->GetItemByGuid(itemGuid)) { data << uint8(0); // has text - data << uint64(itemGuid); // item guid + data << itemGuid; // item guid data << item->GetText(); } else @@ -1702,7 +1702,7 @@ void WorldSession::HandleItemTextQuery(WorldPacket& recvData ) SendPacket(&data); } -bool WorldSession::CanUseBank(uint64 bankerGUID) const +bool WorldSession::CanUseBank(ObjectGuid bankerGUID) const { // bankerGUID parameter is optional, set to 0 by default. if (!bankerGUID) @@ -1728,7 +1728,7 @@ bool WorldSession::recoveryItem(Item* pItem) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_RECOVERY_ITEM); - stmt->setUInt32(0, pItem->GetOwnerGUID()); + stmt->setUInt32(0, pItem->GetOwnerGUID().GetCounter()); stmt->setUInt32(1, pItem->GetTemplate()->ItemId); stmt->setUInt32(2, pItem->GetCount()); diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp index 428550e45b..a5f4eb4459 100644 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -27,7 +27,7 @@ void BuildPartyLockDungeonBlock(WorldPacket& data, const lfg::LfgLockPartyMap& l data << uint8(lockMap.size()); for (lfg::LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it) { - data << uint64(it->first); // Player guid + data << it->first; // Player guid BuildPlayerLockDungeonBlock(data, it->second); } } @@ -57,7 +57,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData) if (!numDungeons) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID()); + LOG_DEBUG("network", "CMSG_LFG_JOIN [%s] no dungeons selected", GetPlayer()->GetGUID().ToString().c_str()); #endif recvData.rfinish(); return; @@ -78,7 +78,8 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData) std::string comment; recvData >> comment; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); + LOG_DEBUG("network", "CMSG_LFG_JOIN [%s] roles: %u, Dungeons: %u, Comment: %s", + GetPlayer()->GetGUID().ToString().c_str(), roles, uint8(newDungeons.size()), comment.c_str()); #endif sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment); @@ -87,18 +88,18 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData) void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recvData*/) { Group* group = GetPlayer()->GetGroup(); - uint64 guid = GetPlayer()->GetGUID(); - uint64 gguid = group ? group->GetGUID() : guid; + ObjectGuid guid = GetPlayer()->GetGUID(); + ObjectGuid gguid = group ? group->GetGUID() : guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", guid, group ? 1 : 0); + LOG_DEBUG("network", "CMSG_LFG_LEAVE [%s] in group: %u", guid.ToString().c_str(), group ? 1 : 0); #endif // Check cheating - only leader can leave the queue if (!group || group->GetLeaderGUID() == guid) { sLFGMgr->LeaveLfg(sLFGMgr->GetState(guid) == lfg::LFG_STATE_RAIDBROWSER ? guid : gguid); - sLFGMgr->LeaveAllLfgQueues(guid, true, group ? group->GetGUID() : 0); + sLFGMgr->LeaveAllLfgQueues(guid, true, group ? group->GetGUID() : ObjectGuid::Empty); } } @@ -110,7 +111,7 @@ void WorldSession::HandleLfgProposalResultOpcode(WorldPacket& recvData) recvData >> accept; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_LFG_PROPOSAL_RESULT [" UI64FMTD "] proposal: %u accept: %u", GetPlayer()->GetGUID(), proposalID, accept ? 1 : 0); + LOG_DEBUG("network", "CMSG_LFG_PROPOSAL_RESULT [%s] proposal: %u accept: %u", GetPlayer()->GetGUID().ToString().c_str(), proposalID, accept ? 1 : 0); #endif sLFGMgr->UpdateProposal(proposalID, GetPlayer()->GetGUID(), accept); } @@ -119,18 +120,18 @@ void WorldSession::HandleLfgSetRolesOpcode(WorldPacket& recvData) { uint8 roles; recvData >> roles; // Player Group Roles - uint64 guid = GetPlayer()->GetGUID(); + ObjectGuid guid = GetPlayer()->GetGUID(); Group* group = GetPlayer()->GetGroup(); if (!group) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", guid); + LOG_DEBUG("network", "CMSG_LFG_SET_ROLES [%s] Not in group", guid.ToString().c_str()); #endif return; } - uint64 gguid = group->GetGUID(); + ObjectGuid gguid = group->GetGUID(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_LFG_SET_ROLES: Group [" UI64FMTD "], Player [" UI64FMTD "], Roles: %u", gguid, guid, roles); + LOG_DEBUG("network", "CMSG_LFG_SET_ROLES: Group [%s], Player [%s], Roles: %u", gguid.ToString().c_str(), guid.ToString().c_str(), roles); #endif sLFGMgr->UpdateRoleCheck(gguid, guid, roles); } @@ -140,8 +141,8 @@ void WorldSession::HandleLfgSetCommentOpcode(WorldPacket& recvData) std::string comment; recvData >> comment; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - uint64 guid = GetPlayer()->GetGUID(); - LOG_DEBUG("network", "CMSG_LFG_SET_COMMENT [" UI64FMTD "] comment: %s", guid, comment.c_str()); + ObjectGuid guid = GetPlayer()->GetGUID(); + LOG_DEBUG("network", "CMSG_LFG_SET_COMMENT [%s] comment: %s", guid.ToString().c_str(), comment.c_str()); #endif sLFGMgr->SetComment(GetPlayer()->GetGUID(), comment); @@ -153,9 +154,9 @@ void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recvData) bool agree; // Agree to kick player recvData >> agree; - uint64 guid = GetPlayer()->GetGUID(); + ObjectGuid guid = GetPlayer()->GetGUID(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_LFG_SET_BOOT_VOTE [" UI64FMTD "] agree: %u", guid, agree ? 1 : 0); + LOG_DEBUG("network", "CMSG_LFG_SET_BOOT_VOTE [%s] agree: %u", guid.ToString().c_str(), agree ? 1 : 0); #endif sLFGMgr->UpdateBoot(guid, agree); } @@ -166,16 +167,16 @@ void WorldSession::HandleLfgTeleportOpcode(WorldPacket& recvData) recvData >> out; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0); + LOG_DEBUG("network", "CMSG_LFG_TELEPORT [%s] out: %u", GetPlayer()->GetGUID().ToString().c_str(), out ? 1 : 0); #endif sLFGMgr->TeleportPlayer(GetPlayer(), out, true); } void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData*/) { - uint64 guid = GetPlayer()->GetGUID(); + ObjectGuid guid = GetPlayer()->GetGUID(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + LOG_DEBUG("network", "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [%s]", guid.ToString().c_str()); #endif // Get Random dungeons that can be done at a certain level and expansion @@ -190,7 +191,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData* uint32 lsize = uint32(lock.size()); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid); + LOG_DEBUG("network", "SMSG_LFG_PLAYER_INFO [%s]", guid.ToString().c_str()); #endif WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4)); @@ -248,9 +249,9 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData* void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recvData*/) { - uint64 guid = GetPlayer()->GetGUID(); + ObjectGuid guid = GetPlayer()->GetGUID(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + LOG_DEBUG("network", "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [%s]", guid.ToString().c_str()); #endif Group* group = GetPlayer()->GetGroup(); @@ -265,7 +266,7 @@ void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recvData* if (!plrg) continue; - uint64 pguid = plrg->GetGUID(); + ObjectGuid pguid = plrg->GetGUID(); if (pguid == guid) continue; @@ -278,7 +279,7 @@ void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recvData* size += 8 + 4 + uint32(it->second.size()) * (4 + 4); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid); + LOG_DEBUG("network", "SMSG_LFG_PARTY_INFO [%s]", guid.ToString().c_str()); #endif WorldPacket data(SMSG_LFG_PARTY_INFO, 1 + size); BuildPartyLockDungeonBlock(data, lockMap); @@ -307,7 +308,7 @@ void WorldSession::HandleLfgGetStatus(WorldPacket& /*recvData*/) LOG_DEBUG("lfg", "CMSG_LFG_GET_STATUS %s", GetPlayerInfo().c_str()); #endif - uint64 guid = GetPlayer()->GetGUID(); + ObjectGuid guid = GetPlayer()->GetGUID(); lfg::LfgUpdateData updateData = sLFGMgr->GetLfgStatus(guid); if (GetPlayer()->GetGroup()) @@ -409,14 +410,14 @@ void WorldSession::SendLfgUpdateParty(lfg::LfgUpdateData const& updateData) SendPacket(&data); } -void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles) +void WorldSession::SendLfgRoleChosen(ObjectGuid guid, uint8 roles) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] guid: [" UI64FMTD "] roles: %u", GetPlayer()->GetGUID(), guid, roles); + LOG_DEBUG("network", "SMSG_LFG_ROLE_CHOSEN [%s] guid: [%s] roles: %u", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str(), roles); #endif WorldPacket data(SMSG_LFG_ROLE_CHOSEN, 8 + 1 + 4); - data << uint64(guid); // Guid + data << guid; // Guid data << uint8(roles > 0); // Ready data << uint32(roles); // Roles SendPacket(&data); @@ -431,7 +432,7 @@ void WorldSession::SendLfgRoleCheckUpdate(lfg::LfgRoleCheck const& roleCheck) dungeons = roleCheck.dungeons; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); + LOG_DEBUG("network", "SMSG_LFG_ROLE_CHECK_UPDATE [%s]", GetPlayer()->GetGUID().ToString().c_str()); #endif WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + roleCheck.roles.size() * (8 + 1 + 4 + 1)); @@ -446,12 +447,12 @@ void WorldSession::SendLfgRoleCheckUpdate(lfg::LfgRoleCheck const& roleCheck) if (!roleCheck.roles.empty()) { // Leader info MUST be sent 1st :S - uint64 guid = roleCheck.leader; + ObjectGuid guid = roleCheck.leader; uint8 roles = roleCheck.roles.find(guid)->second; - data << uint64(guid); // Guid + data << guid; // Guid data << uint8(roles > 0); // Ready data << uint32(roles); // Roles - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* player = ObjectAccessor::FindConnectedPlayer(guid); data << uint8(player ? player->getLevel() : 0); // Level for (lfg::LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it) @@ -461,10 +462,10 @@ void WorldSession::SendLfgRoleCheckUpdate(lfg::LfgRoleCheck const& roleCheck) guid = it->first; roles = it->second; - data << uint64(guid); // Guid + data << guid; // Guid data << uint8(roles > 0); // Ready data << uint32(roles); // Roles - player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + player = ObjectAccessor::FindConnectedPlayer(guid); data << uint8(player ? player->getLevel() : 0);// Level } } @@ -478,7 +479,7 @@ void WorldSession::SendLfgJoinResult(lfg::LfgJoinResultData const& joinData) size += 8 + 4 + uint32(it->second.size()) * (4 + 4); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); + LOG_DEBUG("network", "SMSG_LFG_JOIN_RESULT [%s] checkResult: %u checkValue: %u", GetPlayer()->GetGUID().ToString().c_str(), joinData.result, joinData.state); #endif WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size); data << uint32(joinData.result); // Check Result @@ -491,8 +492,9 @@ void WorldSession::SendLfgJoinResult(lfg::LfgJoinResultData const& joinData) void WorldSession::SendLfgQueueStatus(lfg::LfgQueueStatusData const& queueData) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_QUEUE_STATUS [" UI64FMTD "] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", - GetPlayer()->GetGUID(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg, queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps, queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps); + LOG_DEBUG("network", "SMSG_LFG_QUEUE_STATUS [%s] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", + GetPlayer()->GetGUID().ToString().c_str(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg, queueData.waitTimeTank, + queueData.waitTimeHealer, queueData.waitTimeDps, queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps); #endif WorldPacket data(SMSG_LFG_QUEUE_STATUS, 4 + 4 + 4 + 4 + 4 + 4 + 1 + 1 + 1 + 4); data << uint32(queueData.dungeonId); // Dungeon @@ -544,7 +546,7 @@ void WorldSession::SendLfgPlayerReward(lfg::LfgPlayerRewardData const& rewardDat void WorldSession::SendLfgBootProposalUpdate(lfg::LfgPlayerBoot const& boot) { - uint64 guid = GetPlayer()->GetGUID(); + ObjectGuid guid = GetPlayer()->GetGUID(); lfg::LfgAnswer playerVote = boot.votes.find(guid)->second; uint8 votesNum = 0; uint8 agreeNum = 0; @@ -559,31 +561,32 @@ void WorldSession::SendLfgBootProposalUpdate(lfg::LfgPlayerBoot const& boot) } } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_BOOT_PROPOSAL_UPDATE [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", - guid, uint8(boot.inProgress), uint8(playerVote != lfg::LFG_ANSWER_PENDING), uint8(playerVote == lfg::LFG_ANSWER_AGREE), boot.victim, votesNum, agreeNum, secsleft, lfg::LFG_GROUP_KICK_VOTES_NEEDED, boot.reason.c_str()); + LOG_DEBUG("network", "SMSG_LFG_BOOT_PROPOSAL_UPDATE [%s] inProgress: %u - didVote: %u - agree: %u - victim: [%s] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", + guid.ToString().c_str(), uint8(boot.inProgress), uint8(playerVote != lfg::LFG_ANSWER_PENDING), uint8(playerVote == lfg::LFG_ANSWER_AGREE), + boot.victim.ToString().c_str(), votesNum, agreeNum, secsleft, lfg::LFG_GROUP_KICK_VOTES_NEEDED, boot.reason.c_str()); #endif WorldPacket data(SMSG_LFG_BOOT_PROPOSAL_UPDATE, 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + boot.reason.length()); data << uint8(boot.inProgress); // Vote in progress - data << uint8(playerVote != lfg::LFG_ANSWER_PENDING); // Did Vote - data << uint8(playerVote == lfg::LFG_ANSWER_AGREE); // Agree - data << uint64(boot.victim); // Victim GUID + data << uint8(playerVote != lfg::LFG_ANSWER_PENDING); // Did Vote + data << uint8(playerVote == lfg::LFG_ANSWER_AGREE); // Agree + data << boot.victim; // Victim GUID data << uint32(votesNum); // Total Votes data << uint32(agreeNum); // Agree Count data << uint32(secsleft); // Time Left - data << uint32(lfg::LFG_GROUP_KICK_VOTES_NEEDED); // Needed Votes + data << uint32(lfg::LFG_GROUP_KICK_VOTES_NEEDED); // Needed Votes data << boot.reason.c_str(); // Kick reason SendPacket(&data); } void WorldSession::SendLfgUpdateProposal(lfg::LfgProposal const& proposal) { - uint64 guid = GetPlayer()->GetGUID(); - uint64 gguid = proposal.players.find(guid)->second.group; + ObjectGuid guid = GetPlayer()->GetGUID(); + ObjectGuid gguid = proposal.players.find(guid)->second.group; bool silent = !proposal.isNew && gguid == proposal.group; uint32 dungeonEntry = proposal.dungeonId; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", guid, proposal.state); + LOG_DEBUG("network", "SMSG_LFG_PROPOSAL_UPDATE [%s state: %u", guid.ToString().c_str(), proposal.state); #endif // show random dungeon if player selected random dungeon and it's not lfg group @@ -628,7 +631,7 @@ void WorldSession::SendLfgUpdateProposal(lfg::LfgProposal const& proposal) void WorldSession::SendLfgLfrList(bool update) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_LFR_LIST [" UI64FMTD "] update: %u", GetPlayer()->GetGUID(), update ? 1 : 0); + LOG_DEBUG("network", "SMSG_LFG_LFR_LIST [%s] update: %u", GetPlayer()->GetGUID().ToString().c_str(), update ? 1 : 0); #endif WorldPacket data(SMSG_LFG_UPDATE_SEARCH, 1); data << uint8(update); // In Lfg Queue? @@ -638,7 +641,7 @@ void WorldSession::SendLfgLfrList(bool update) void WorldSession::SendLfgDisabled() { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_DISABLED [" UI64FMTD "]", GetPlayer()->GetGUID()); + LOG_DEBUG("network", "SMSG_LFG_DISABLED [%s]", GetPlayer()->GetGUID().ToString().c_str()); #endif WorldPacket data(SMSG_LFG_DISABLED, 0); SendPacket(&data); @@ -647,7 +650,7 @@ void WorldSession::SendLfgDisabled() void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_OFFER_CONTINUE [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); + LOG_DEBUG("network", "SMSG_LFG_OFFER_CONTINUE [%s] dungeon entry: %u", GetPlayer()->GetGUID().ToString().c_str(), dungeonEntry); #endif WorldPacket data(SMSG_LFG_OFFER_CONTINUE, 4); data << uint32(dungeonEntry); @@ -657,7 +660,7 @@ void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) void WorldSession::SendLfgTeleportError(uint8 err) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "SMSG_LFG_TELEPORT_DENIED [" UI64FMTD "] reason: %u", GetPlayer()->GetGUID(), err); + LOG_DEBUG("network", "SMSG_LFG_TELEPORT_DENIED [%s] reason: %u", GetPlayer()->GetGUID().ToString().c_str(), err); #endif WorldPacket data(SMSG_LFG_TELEPORT_DENIED, 4); data << uint32(err); // Error diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 16acd2f7b9..d604d936f7 100644 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -31,13 +31,13 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: CMSG_AUTOSTORE_LOOT_ITEM"); #endif Player* player = GetPlayer(); - uint64 lguid = player->GetLootGUID(); + ObjectGuid lguid = player->GetLootGUID(); Loot* loot = nullptr; uint8 lootSlot = 0; recvData >> lootSlot; - if (IS_GAMEOBJECT_GUID(lguid)) + if (lguid.IsGameObject()) { GameObject* go = player->GetMap()->GetGameObject(lguid); // xinef: cheating protection @@ -53,7 +53,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData) loot = &go->loot; } - else if (IS_ITEM_GUID(lguid)) + else if (lguid.IsItem()) { Item* pItem = player->GetItemByGuid(lguid); @@ -65,7 +65,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData) loot = &pItem->loot; } - else if (IS_CORPSE_GUID(lguid)) + else if (lguid.IsCorpse()) { Corpse* bones = ObjectAccessor::GetCorpse(*player, lguid); if (!bones) @@ -93,7 +93,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData) player->StoreLootItem(lootSlot, loot); // If player is removing the last LootItem, delete the empty container. - if (loot->isLooted() && IS_ITEM_GUID(lguid)) + if (loot->isLooted() && lguid.IsItem()) DoLootRelease(lguid); } @@ -104,16 +104,16 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/) #endif Player* player = GetPlayer(); - uint64 guid = player->GetLootGUID(); + ObjectGuid guid = player->GetLootGUID(); if (!guid) return; Loot* loot = nullptr; bool shareMoney = true; - switch (GUID_HIPART(guid)) + switch (guid.GetHigh()) { - case HIGHGUID_GAMEOBJECT: + case HighGuid::GameObject: { GameObject* go = GetPlayer()->GetMap()->GetGameObject(guid); @@ -123,7 +123,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/) break; } - case HIGHGUID_CORPSE: // remove insignia ONLY in BG + case HighGuid::Corpse: // remove insignia ONLY in BG { Corpse* bones = ObjectAccessor::GetCorpse(*player, guid); @@ -135,7 +135,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/) break; } - case HIGHGUID_ITEM: + case HighGuid::Item: { if (Item* item = player->GetItemByGuid(guid)) { @@ -144,8 +144,8 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/) } break; } - case HIGHGUID_UNIT: - case HIGHGUID_VEHICLE: + case HighGuid::Unit: + case HighGuid::Vehicle: { Creature* creature = player->GetMap()->GetCreature(guid); bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING); @@ -210,11 +210,11 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/) loot->gold = 0; // Delete the money loot record from the DB - if (loot->containerId > 0) - sLootItemStorage->RemoveStoredLootMoney(loot->containerId, loot); + if (loot->containerGUID) + sLootItemStorage->RemoveStoredLootMoney(loot->containerGUID, loot); // Delete container if empty - if (loot->isLooted() && IS_ITEM_GUID(guid)) + if (loot->isLooted() && guid.IsItem()) DoLootRelease(guid); } } @@ -225,11 +225,11 @@ void WorldSession::HandleLootOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: CMSG_LOOT"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; // Check possible cheat - if (!GetPlayer()->IsAlive() || !IS_CRE_OR_VEH_GUID(guid)) + if (!GetPlayer()->IsAlive() || !guid.IsCreatureOrVehicle()) return; GetPlayer()->SendLoot(guid, LOOT_CORPSE); @@ -247,20 +247,20 @@ void WorldSession::HandleLootReleaseOpcode(WorldPacket& recvData) // cheaters can modify lguid to prevent correct apply loot release code and re-loot // use internal stored guid - uint64 guid; + ObjectGuid guid; recvData >> guid; - if (uint64 lguid = GetPlayer()->GetLootGUID()) + if (ObjectGuid lguid = GetPlayer()->GetLootGUID()) if (lguid == guid) DoLootRelease(lguid); } -void WorldSession::DoLootRelease(uint64 lguid) +void WorldSession::DoLootRelease(ObjectGuid lguid) { Player* player = GetPlayer(); Loot* loot; - player->SetLootGUID(0); + player->SetLootGUID(ObjectGuid::Empty); player->SendLootRelease(lguid); player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); @@ -268,7 +268,7 @@ void WorldSession::DoLootRelease(uint64 lguid) if (!player->IsInWorld()) return; - if (IS_GAMEOBJECT_GUID(lguid)) + if (lguid.IsGameObject()) { GameObject* go = GetPlayer()->GetMap()->GetGameObject(lguid); @@ -304,7 +304,7 @@ void WorldSession::DoLootRelease(uint64 lguid) if (go->GetGoType() == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.eventId) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("spells.aura", "Chest ScriptStart id %u for GO %u", go->GetGOInfo()->chest.eventId, go->GetDBTableGUIDLow()); + LOG_DEBUG("spells.aura", "Chest ScriptStart id %u for GO %u", go->GetGOInfo()->chest.eventId, go->GetSpawnId()); #endif player->GetMap()->ScriptsStart(sEventScripts, go->GetGOInfo()->chest.eventId, player, go); } @@ -319,10 +319,10 @@ void WorldSession::DoLootRelease(uint64 lguid) // if the round robin player release, reset it. if (player->GetGUID() == loot->roundRobinPlayer) - loot->roundRobinPlayer = 0; + loot->roundRobinPlayer.Clear(); } } - else if (IS_CORPSE_GUID(lguid)) // ONLY remove insignia at BG + else if (lguid.IsCorpse()) // ONLY remove insignia at BG { Corpse* corpse = ObjectAccessor::GetCorpse(*player, lguid); if (!corpse || !corpse->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) @@ -337,7 +337,7 @@ void WorldSession::DoLootRelease(uint64 lguid) corpse->RemoveFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE); } } - else if (IS_ITEM_GUID(lguid)) + else if (lguid.IsItem()) { Item* pItem = player->GetItemByGuid(lguid); if (!pItem) @@ -389,7 +389,7 @@ void WorldSession::DoLootRelease(uint64 lguid) // if the round robin player release, reset it. if (player->GetGUID() == loot->roundRobinPlayer) { - loot->roundRobinPlayer = 0; + loot->roundRobinPlayer.Clear(); if (Group* group = player->GetGroup()) group->SendLooter(creature, nullptr); @@ -406,7 +406,7 @@ void WorldSession::DoLootRelease(uint64 lguid) void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData) { uint8 slotid; - uint64 lootguid, target_playerguid; + ObjectGuid lootguid, target_playerguid; recvData >> lootguid >> slotid >> target_playerguid; @@ -416,7 +416,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData) return; } - Player* target = ObjectAccessor::GetPlayer(*_player, MAKE_NEW_GUID(target_playerguid, 0, HIGHGUID_PLAYER)); + Player* target = ObjectAccessor::GetPlayer(*_player, target_playerguid); if (!target) { _player->SendLootError(lootguid, LOOT_ERROR_PLAYER_NOT_FOUND); @@ -442,7 +442,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData) Loot* loot = nullptr; - if (IS_CRE_OR_VEH_GUID(GetPlayer()->GetLootGUID())) + if (GetPlayer()->GetLootGUID().IsCreatureOrVehicle()) { Creature* creature = GetPlayer()->GetMap()->GetCreature(lootguid); if (!creature) @@ -450,7 +450,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData) loot = &creature->loot; } - else if (IS_GAMEOBJECT_GUID(GetPlayer()->GetLootGUID())) + else if (GetPlayer()->GetLootGUID().IsGameObject()) { GameObject* pGO = GetPlayer()->GetMap()->GetGameObject(lootguid); if (!pGO) diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp index 34c17df300..b41130d400 100644 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -21,7 +21,7 @@ #define MAX_INBOX_CLIENT_CAPACITY 50 -bool WorldSession::CanOpenMailBox(uint64 guid) +bool WorldSession::CanOpenMailBox(ObjectGuid guid) { if (guid == _player->GetGUID()) { @@ -31,12 +31,12 @@ bool WorldSession::CanOpenMailBox(uint64 guid) return false; } } - else if (IS_GAMEOBJECT_GUID(guid)) + else if (guid.IsGameObject()) { if (!_player->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_MAILBOX)) return false; } - else if (IS_CRE_OR_VEH_OR_PET_GUID(guid)) + else if (guid.IsAnyTypeCreature()) { if (!_player->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_MAILBOX)) return false; @@ -49,7 +49,8 @@ bool WorldSession::CanOpenMailBox(uint64 guid) void WorldSession::HandleSendMail(WorldPacket& recvData) { - uint64 mailbox, unk3; + ObjectGuid mailbox; + uint64 unk3; std::string receiver, subject, body; uint32 unk1, unk2, money, COD; uint8 unk4; @@ -80,7 +81,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) return; } - uint64 itemGUIDs[MAX_MAIL_ITEMS]; + ObjectGuid itemGUIDs[MAX_MAIL_ITEMS]; for (uint8 i = 0; i < items_count; ++i) { @@ -108,21 +109,23 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) return; } - uint64 rc = 0; + ObjectGuid rc; if (normalizePlayerName(receiver)) rc = sObjectMgr->GetPlayerGUIDByName(receiver); if (!rc) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player %u is sending mail to %s (GUID: not existed!) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", player->GetGUIDLow(), receiver.c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); + LOG_DEBUG("server", "Player %s is sending mail to %s (GUID: not existed!) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", + player->GetGUID().ToString().c_str(), receiver.c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); #endif player->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND); return; } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player %u is sending mail to %s (GUID: %u) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", player->GetGUIDLow(), receiver.c_str(), GUID_LOPART(rc), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); + LOG_DEBUG("server", "Player %s is sending mail to %s (%s) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", + player->GetGUID().ToString().c_str(), receiver.c_str(), rc.ToString().c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); #endif if (player->GetGUID() == rc) @@ -155,7 +158,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) return; } - Player* receive = ObjectAccessor::FindPlayerInOrOutOfWorld(rc); + Player* receive = ObjectAccessor::FindConnectedPlayer(rc); uint32 rc_teamId = TEAM_NEUTRAL; uint16 mails_count = 0; //do not allow to send to one player more than 100 mails @@ -168,7 +171,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) else { // xinef: get data from global storage - if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(rc))) + if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(rc.GetCounter())) { rc_teamId = Player::TeamIdForRace(playerData->race); mails_count = playerData->mailCount; @@ -197,7 +200,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) } }*/ - uint32 rc_account = receive ? receive->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(rc); + uint32 rc_account = receive ? receive->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(rc.GetCounter()); if (/*!accountBound*/ GetAccountId() != rc_account && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && player->GetTeamId() != rc_teamId && AccountMgr::IsPlayerAccount(GetSecurity())) { @@ -298,7 +301,8 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) if( money >= 10 * GOLD ) { CleanStringForMysqlQuery(subject); - CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<MAIL> %s\", NOW())", GetAccountId(), player->GetGUIDLow(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), rc_account, receiver.c_str(), money, subject.c_str()); + CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<MAIL> %s\", NOW())", + GetAccountId(), player->GetGUID().GetCounter(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), rc_account, receiver.c_str(), money, subject.c_str()); } } @@ -313,7 +317,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) draft .AddMoney(money) .AddCOD(COD) - .SendMailTo(trans, MailReceiver(receive, GUID_LOPART(rc)), MailSender(player), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay); + .SendMailTo(trans, MailReceiver(receive, rc.GetCounter()), MailSender(player), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay); player->SaveInventoryAndGoldToDB(trans); CharacterDatabase.CommitTransaction(trans); @@ -322,7 +326,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) //called when mail is read void WorldSession::HandleMailMarkAsRead(WorldPacket& recvData) { - uint64 mailbox; + ObjectGuid mailbox; uint32 mailId; recvData >> mailbox; recvData >> mailId; @@ -345,7 +349,7 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket& recvData) //called when client deletes mail void WorldSession::HandleMailDelete(WorldPacket& recvData) { - uint64 mailbox; + ObjectGuid mailbox; uint32 mailId; recvData >> mailbox; recvData >> mailId; @@ -368,14 +372,14 @@ void WorldSession::HandleMailDelete(WorldPacket& recvData) m->state = MAIL_STATE_DELETED; // xinef: update global data - sWorld->UpdateGlobalPlayerMails(player->GetGUIDLow(), -1); + sWorld->UpdateGlobalPlayerMails(player->GetGUID().GetCounter(), -1); } player->SendMailResult(mailId, MAIL_DELETED, MAIL_OK); } void WorldSession::HandleMailReturnToSender(WorldPacket& recvData) { - uint64 mailbox; + ObjectGuid mailbox; uint32 mailId; recvData >> mailbox; recvData >> mailId; @@ -432,18 +436,18 @@ void WorldSession::HandleMailReturnToSender(WorldPacket& recvData) player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_OK); // xinef: update global data - sWorld->UpdateGlobalPlayerMails(player->GetGUIDLow(), -1); + sWorld->UpdateGlobalPlayerMails(player->GetGUID().GetCounter(), -1); } //called when player takes item attached in mail void WorldSession::HandleMailTakeItem(WorldPacket& recvData) { - uint64 mailbox; + ObjectGuid mailbox; uint32 mailId; - uint32 itemId; + uint32 itemLowGuid; recvData >> mailbox; recvData >> mailId; - recvData >> itemId; // item guid low + recvData >> itemLowGuid; // item guid low if (!CanOpenMailBox(mailbox)) return; @@ -460,7 +464,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData) // verify that the mail has the item to avoid cheaters taking COD items without paying bool foundItem = false; for (std::vector<MailItemInfo>::const_iterator itr = m->items.begin(); itr != m->items.end(); ++itr) - if (itr->item_guid == itemId) + if (itr->item_guid == itemLowGuid) { foundItem = true; break; @@ -478,25 +482,24 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData) return; } - Item* it = player->GetMItem(itemId); + Item* it = player->GetMItem(itemLowGuid); ItemPosCountVec dest; uint8 msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, it, false); if (msg == EQUIP_ERR_OK) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); - m->RemoveItem(itemId); - m->removedItems.push_back(itemId); + m->RemoveItem(itemLowGuid); + m->removedItems.push_back(itemLowGuid); if (m->COD > 0) // if there is COD, take COD money from player and send them to sender by mail { - uint64 sender_guid = MAKE_NEW_GUID(m->sender, 0, HIGHGUID_PLAYER); uint32 sender_accId = 0; - Player* sender = ObjectAccessor::FindPlayerInOrOutOfWorld(sender_guid); + Player* sender = ObjectAccessor::FindPlayerByLowGUID(m->sender); if (sender) sender_accId = sender->GetSession()->GetAccountId(); else - sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(sender_guid); + sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(m->sender); // check player existence if (sender || sender_accId) @@ -508,11 +511,12 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData) if( m->COD >= 10 * GOLD ) { std::string senderName; - if (!sObjectMgr->GetPlayerNameByGUID(sender_guid, senderName)) + if (!sObjectMgr->GetPlayerNameByGUID(m->sender, senderName)) senderName = sObjectMgr->GetAcoreStringForDBCLocale(LANG_UNKNOWN); std::string subj = m->subject; CleanStringForMysqlQuery(subj); - CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<COD> %s\", NOW())", GetAccountId(), player->GetGUIDLow(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), sender_accId, senderName.c_str(), m->COD, subj.c_str()); + CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<COD> %s\", NOW())", + GetAccountId(), player->GetGUID().GetCounter(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), sender_accId, senderName.c_str(), m->COD, subj.c_str()); } } @@ -522,7 +526,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData) m->COD = 0; m->state = MAIL_STATE_CHANGED; player->m_mailsUpdated = true; - player->RemoveMItem(it->GetGUIDLow()); + player->RemoveMItem(it->GetGUID().GetCounter()); uint32 count = it->GetCount(); // save counts before store and possible merge with deleting it->SetState(ITEM_UNCHANGED); // need to set this state, otherwise item cannot be removed later, if neccessary @@ -532,7 +536,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData) player->_SaveMail(trans); CharacterDatabase.CommitTransaction(trans); - player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_OK, 0, itemId, count); + player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_OK, 0, itemLowGuid, count); } else player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg); @@ -540,7 +544,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData) void WorldSession::HandleMailTakeMoney(WorldPacket& recvData) { - uint64 mailbox; + ObjectGuid mailbox; uint32 mailId; recvData >> mailbox; recvData >> mailId; @@ -579,7 +583,7 @@ void WorldSession::HandleMailTakeMoney(WorldPacket& recvData) //called when player lists his received mails void WorldSession::HandleGetMailList(WorldPacket& recvData) { - uint64 mailbox; + ObjectGuid mailbox; recvData >> mailbox; if (!CanOpenMailBox(mailbox)) @@ -623,7 +627,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recvData) switch ((*itr)->messageType) { case MAIL_NORMAL: // sender guid - data << uint64(MAKE_NEW_GUID((*itr)->sender, 0, HIGHGUID_PLAYER)); + data << ObjectGuid::Create<HighGuid::Player>((*itr)->sender); break; case MAIL_CREATURE: case MAIL_GAMEOBJECT: @@ -663,7 +667,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recvData) // item index (0-6?) data << uint8(i); // item guid low? - data << uint32((item ? item->GetGUIDLow() : 0)); + data << uint32((item ? item->GetGUID().GetCounter() : 0)); // entry data << uint32((item ? item->GetEntry() : 0)); for (uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; ++j) @@ -702,7 +706,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recvData) //used when player copies mail body to his inventory void WorldSession::HandleMailCreateTextItem(WorldPacket& recvData) { - uint64 mailbox; + ObjectGuid mailbox; uint32 mailId; recvData >> mailbox; @@ -721,7 +725,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket& recvData) } Item* bodyItem = new Item; // This is not bag and then can be used new Item. - if (!bodyItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), MAIL_BODY_ITEM_TEMPLATE, player)) + if (!bodyItem->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(), MAIL_BODY_ITEM_TEMPLATE, player)) { delete bodyItem; return; @@ -798,7 +802,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket& /*recvData*/) if (sentSenders.count(m->sender)) continue; - data << uint64(m->messageType == MAIL_NORMAL ? m->sender : 0); // player guid + data << (m->messageType == MAIL_NORMAL ? ObjectGuid::Create<HighGuid::Player>(m->sender) : ObjectGuid::Empty); // player guid data << uint32(m->messageType != MAIL_NORMAL ? m->sender : 0); // non-player entries data << uint32(m->messageType); data << uint32(m->stationery); diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index d55aa041b5..15d70f4f23 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -68,7 +68,8 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data) if (GetPlayer()->getDeathState() == JUST_DIED) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); + LOG_DEBUG("network", "HandleRepopRequestOpcode: got request after player %s (%s) was killed and before he was updated", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); #endif GetPlayer()->KillPlayer(); } @@ -91,7 +92,7 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recv_data) uint32 gossipListId; uint32 menuId; - uint64 guid; + ObjectGuid guid; std::string code = ""; recv_data >> guid >> menuId >> gossipListId; @@ -102,29 +103,29 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recv_data) Creature* unit = nullptr; GameObject* go = nullptr; Item* item = nullptr; - if (IS_CRE_OR_VEH_GUID(guid)) + if (guid.IsCreatureOrVehicle()) { unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - Unit (%s) not found or you can't interact with him.", guid.ToString().c_str()); #endif return; } } - else if (IS_GAMEOBJECT_GUID(guid)) + else if (guid.IsGameObject()) { go = _player->GetMap()->GetGameObject(guid); if (!go) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - GameObject (GUID: %u) not found.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - GameObject (%s) not found.", guid.ToString().c_str()); #endif return; } } - else if (IS_ITEM_GUID(guid)) + else if (guid.IsItem()) { item = _player->GetItemByGuid(guid); if (!item || _player->IsBankPos(item->GetPos())) @@ -133,7 +134,7 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recv_data) return; } } - else if (IS_PLAYER_GUID(guid)) + else if (guid.IsPlayer()) { if (guid != _player->GetGUID() || menuId != _player->PlayerTalkClass->GetGossipMenu().GetMenuId()) { @@ -144,7 +145,7 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recv_data) else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for highguid %u. lowpart %u.", uint32(GUID_HIPART(guid)), uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for %s.", guid.ToString().c_str()); #endif return; } @@ -292,7 +293,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData) data << uint32(displaycount); // placeholder, count of players displayed std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock()); - HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers(); + HashMapHolder<Player>::MapType const& m = ObjectAccessor::GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { if (AccountMgr::IsPlayerAccount(security)) @@ -415,7 +416,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recv_data*/) LOG_DEBUG("network", "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity()); #endif - if (uint64 lguid = GetPlayer()->GetLootGUID()) + if (ObjectGuid lguid = GetPlayer()->GetLootGUID()) DoLootRelease(lguid); bool instantLogout = ((GetSecurity() >= 0 && uint32(GetSecurity()) >= sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT)) @@ -463,7 +464,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recv_data*/) GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT); WorldPacket data(SMSG_FORCE_MOVE_ROOT, (8 + 4)); // guess size - data.append(GetPlayer()->GetPackGUID()); + data << GetPlayer()->GetPackGUID(); data << (uint32)2; SendPacket(&data); GetPlayer()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); @@ -490,7 +491,7 @@ void WorldSession::HandleLogoutCancelOpcode(WorldPacket& /*recv_data*/) if (GetPlayer()->CanFreeMove()) { data.Initialize(SMSG_FORCE_MOVE_UNROOT, 9 + 4); - data.append(GetPlayer()->GetPackGUID()); + data << GetPlayer()->GetPackGUID(); data << uint32(0); SendPacket(&data); @@ -538,7 +539,7 @@ void WorldSession::HandleZoneUpdateOpcode(WorldPacket& recv_data) void WorldSession::HandleSetSelectionOpcode(WorldPacket& recv_data) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; _player->SetSelection(guid); @@ -633,7 +634,7 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket& recv_data) LOG_DEBUG("network", "WORLD: Received CMSG_RECLAIM_CORPSE"); #endif - uint64 guid; + ObjectGuid guid; recv_data >> guid; if (_player->IsAlive()) @@ -648,7 +649,6 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket& recv_data) return; Corpse* corpse = _player->GetCorpse(); - if (!corpse) return; @@ -672,7 +672,7 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket& recv_data) LOG_DEBUG("network", "WORLD: Received CMSG_RESURRECT_RESPONSE"); #endif - uint64 guid; + ObjectGuid guid; uint8 status; recv_data >> guid; recv_data >> status; @@ -723,8 +723,8 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) if (player->IsInFlight()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u", - player->GetName().c_str(), player->GetGUIDLow(), triggerId); + LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (%s) in flight, ignore Area Trigger ID:%u", + player->GetName().c_str(), player->GetGUID().ToString().c_str(), triggerId); #endif return; } @@ -733,8 +733,8 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) if (!atEntry) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u", - player->GetName().c_str(), player->GetGUIDLow(), triggerId); + LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (%s) send unknown (by DBC) Area Trigger ID:%u", + player->GetName().c_str(), player->GetGUID().ToString().c_str(), triggerId); #endif return; } @@ -742,8 +742,8 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) if (!player->IsInAreaTriggerRadius(atEntry)) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u", - player->GetName().c_str(), atEntry->map, player->GetMapId(), player->GetGUIDLow(), triggerId); + LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player %s (%s) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u", + player->GetName().c_str(), player->GetGUID().ToString().c_str(), atEntry->map, player->GetMapId(), triggerId); #endif return; } @@ -895,11 +895,11 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) dest.resize(destSize); WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA, 8 + 4 + 4 + 4 + destSize); - data << uint64(_player ? _player->GetGUID() : 0); // player guid - data << uint32(type); // type (0-7) - data << uint32(adata->Time); // unix time - data << uint32(size); // decompressed length - data.append(dest); // compressed data + data << (_player ? _player->GetGUID() : ObjectGuid::Empty); // player guid + data << uint32(type); // type (0-7) + data << uint32(adata->Time); // unix time + data << uint32(size); // decompressed length + data.append(dest); // compressed data SendPacket(&data); } @@ -951,7 +951,8 @@ void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data) #endif break; default: - LOG_ERROR("server", "MISC: Unknown action button type %u for action %u into button %u for player %s (GUID: %u)", type, action, button, _player->GetName().c_str(), _player->GetGUIDLow()); + LOG_ERROR("server", "MISC: Unknown action button type %u for action %u into button %u for player %s (%s)", + type, action, button, _player->GetName().c_str(), _player->GetGUID().ToString().c_str()); return; } GetPlayer()->addActionButton(button, action, type); @@ -995,7 +996,7 @@ void WorldSession::HandleMoveUnRootAck(WorldPacket& recv_data) // no used recv_data.rfinish(); // prevent warnings spam /* - uint64 guid; + ObjectGuid guid; recv_data >> guid; // now can skip not our packet @@ -1023,7 +1024,7 @@ void WorldSession::HandleMoveRootAck(WorldPacket& recv_data) // no used recv_data.rfinish(); // prevent warnings spam /* - uint64 guid; + ObjectGuid guid; recv_data >> guid; // now can skip not our packet @@ -1074,7 +1075,7 @@ void WorldSession::HandlePlayedTime(WorldPacket& recv_data) void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) @@ -1085,15 +1086,15 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) if (!player) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_INSPECT: No player found from GUID: " UI64FMTD, guid); + LOG_DEBUG("network", "CMSG_INSPECT: No player found from %s", guid.ToString().c_str()); #endif return; } uint32 talent_points = 0x47; - uint32 guid_size = player->GetPackGUID().wpos(); + uint32 guid_size = player->GetPackGUID().size(); WorldPacket data(SMSG_INSPECT_TALENT, guid_size + 4 + talent_points); - data.append(player->GetPackGUID()); + data << player->GetPackGUID(); if (sWorld->getBoolConfig(CONFIG_TALENTS_INSPECTING) || _player->IsGameMaster()) { @@ -1112,20 +1113,20 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; Player* player = ObjectAccessor::GetPlayer(*_player, guid); if (!player) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "MSG_INSPECT_HONOR_STATS: No player found from GUID: " UI64FMTD, guid); + LOG_DEBUG("network", "MSG_INSPECT_HONOR_STATS: No player found from %s", guid.ToString().c_str()); #endif return; } WorldPacket data(MSG_INSPECT_HONOR_STATS, 8 + 1 + 4 * 4); - data << uint64(player->GetGUID()); + data << player->GetGUID(); data << uint8(player->GetHonorPoints()); data << uint32(player->GetUInt32Value(PLAYER_FIELD_KILLS)); data << uint32(player->GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION)); @@ -1157,7 +1158,7 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) if (GetPlayer()->IsInFlight()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "Player '%s' (GUID: %u) in flight, ignore worldport command.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); + LOG_DEBUG("network", "Player '%s' (%s) in flight, ignore worldport command.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); #endif return; } @@ -1243,7 +1244,7 @@ void WorldSession::HandleComplainOpcode(WorldPacket& recv_data) #endif uint8 spam_type; // 0 - mail, 1 - chat - uint64 spammer_guid; + ObjectGuid spammer_guid; uint32 unk1 = 0; uint32 unk2 = 0; uint32 unk3 = 0; @@ -1276,7 +1277,8 @@ void WorldSession::HandleComplainOpcode(WorldPacket& recv_data) SendPacket(&data); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "REPORT SPAM: type %u, guid %u, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s", spam_type, GUID_LOPART(spammer_guid), unk1, unk2, unk3, unk4, description.c_str()); + LOG_DEBUG("network", "REPORT SPAM: type %u, %s, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s", + spam_type, spammer_guid.ToString().c_str(), unk1, unk2, unk3, unk4, description.c_str()); #endif } @@ -1313,21 +1315,21 @@ void WorldSession::HandleFarSightOpcode(WorldPacket& recvData) if (apply) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "Added FarSight " UI64FMTD " to player %u", _player->GetUInt64Value(PLAYER_FARSIGHT), _player->GetGUIDLow()); + LOG_DEBUG("network", "Added FarSight %s to player %s", _player->GetGuidValue(PLAYER_FARSIGHT).ToString().c_str(), _player->GetGUID().ToString().c_str()); #endif if (WorldObject* target = _player->GetViewpoint()) _player->SetSeer(target); else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_ERROR("server", "Player %s requests non-existing seer " UI64FMTD, _player->GetName().c_str(), _player->GetUInt64Value(PLAYER_FARSIGHT)); + LOG_ERROR("server", "Player %s requests non-existing seer %s", _player->GetName().c_str(), _player->GetGuidValue(PLAYER_FARSIGHT).ToString().c_str()); #endif } } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "Player %u set vision to self", _player->GetGUIDLow()); + LOG_DEBUG("network", "Player %s set vision to self", _player->GetGUID().ToString().c_str()); #endif _player->SetSeer(_player); } @@ -1368,7 +1370,7 @@ void WorldSession::HandleResetInstancesOpcode(WorldPacket& /*recv_data*/) group->ResetInstances(INSTANCE_RESET_ALL, false, _player); } else - Player::ResetInstances(_player->GetGUIDLow(), INSTANCE_RESET_ALL, false); + Player::ResetInstances(_player->GetGUID(), INSTANCE_RESET_ALL, false); } void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data) @@ -1421,7 +1423,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data) _player->SendDungeonDifficulty(group != nullptr); return; } - Player::ResetInstances(_player->GetGUIDLow(), INSTANCE_RESET_CHANGE_DIFFICULTY, false); + Player::ResetInstances(_player->GetGUID(), INSTANCE_RESET_CHANGE_DIFFICULTY, false); _player->SetDungeonDifficulty(Difficulty(mode)); } } @@ -1583,7 +1585,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recv_data) _player->SendRaidDifficulty(group != nullptr); return; } - Player::ResetInstances(_player->GetGUIDLow(), INSTANCE_RESET_CHANGE_DIFFICULTY, true); + Player::ResetInstances(_player->GetGUID(), INSTANCE_RESET_CHANGE_DIFFICULTY, true); _player->SetRaidDifficulty(Difficulty(mode)); } } @@ -1618,8 +1620,8 @@ void WorldSession::HandleMoveSetCanFlyAckOpcode(WorldPacket& recv_data) LOG_DEBUG("network", "WORLD: CMSG_MOVE_SET_CAN_FLY_ACK"); #endif - uint64 guid; // guid - unused - recv_data.readPackGUID(guid); + ObjectGuid guid; + recv_data >> guid.ReadAsPacked(); // pussywizard: typical check for incomming movement packets if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || guid != _player->m_mover->GetGUID()) @@ -1668,8 +1670,8 @@ void WorldSession::HandleSetTaxiBenchmarkOpcode(WorldPacket& recv_data) void WorldSession::HandleQueryInspectAchievements(WorldPacket& recv_data) { - uint64 guid; - recv_data.readPackGUID(guid); + ObjectGuid guid; + recv_data >> guid.ReadAsPacked(); Player* player = ObjectAccessor::GetPlayer(*_player, guid); if (!player) @@ -1716,7 +1718,7 @@ void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data) Battleground* bg = _player->GetBattleground(); - uint64 guid; + ObjectGuid guid; recv_data >> guid; Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); @@ -1741,7 +1743,7 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket& recv_data) Battleground* bg = _player->GetBattleground(); - uint64 guid; + ObjectGuid guid; recv_data >> guid; Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); @@ -1787,7 +1789,8 @@ void WorldSession::HandleInstanceLockResponse(WorldPacket& recvPacket) if (!_player->HasPendingBind() || _player->GetPendingBind() != _player->GetInstanceId() || (_player->GetGroup() && _player->GetGroup()->isLFGGroup() && _player->GetGroup()->IsLfgRandomInstance())) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "InstanceLockResponse: Player %s (guid %u) tried to bind himself/teleport to graveyard without a pending bind!", _player->GetName().c_str(), _player->GetGUIDLow()); + LOG_DEBUG("server", "InstanceLockResponse: Player %s (%s) tried to bind himself/teleport to graveyard without a pending bind!", + _player->GetName().c_str(), _player->GetGUID().ToString().c_str()); #endif return; } @@ -1806,7 +1809,7 @@ void WorldSession::HandleUpdateMissileTrajectory(WorldPacket& recvPacket) LOG_DEBUG("network", "WORLD: CMSG_UPDATE_MISSILE_TRAJECTORY"); #endif - uint64 guid; + ObjectGuid guid; uint32 spellId; float elevation, speed; float curX, curY, curZ; diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index d56e1a9fff..d30e1458b6 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -71,8 +71,8 @@ void WorldSession::HandleMoveWorldportAckOpcode() { GetPlayer()->m_InstanceValid = true; // pussywizard: m_InstanceValid can be false only by leaving a group in an instance => so remove temp binds that could not be removed because player was still on the map! - if (!sInstanceSaveMgr->PlayerIsPermBoundToInstance(GetPlayer()->GetGUIDLow(), oldMap->GetId(), oldMap->GetDifficulty())) - sInstanceSaveMgr->PlayerUnbindInstance(GetPlayer()->GetGUIDLow(), oldMap->GetId(), oldMap->GetDifficulty(), true); + if (!sInstanceSaveMgr->PlayerIsPermBoundToInstance(GetPlayer()->GetGUID(), oldMap->GetId(), oldMap->GetDifficulty())) + sInstanceSaveMgr->PlayerUnbindInstance(GetPlayer()->GetGUID(), oldMap->GetId(), oldMap->GetDifficulty(), true); } // relocate the player to the teleport destination @@ -81,7 +81,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() // while the player is in transit, for example the map may get full if (!newMap || !newMap->CanEnter(GetPlayer(), false)) { - LOG_ERROR("server", "Map %d could not be created for player %d, porting player to homebind", loc.GetMapId(), GetPlayer()->GetGUIDLow()); + LOG_ERROR("server", "Map %d could not be created for player %s, porting player to homebind", loc.GetMapId(), GetPlayer()->GetGUID().ToString().c_str()); GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()); return; } @@ -95,7 +95,8 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SendInitialPacketsBeforeAddToMap(); if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer())) { - LOG_ERROR("server", "WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow(), loc.GetMapId()); + LOG_ERROR("server", "WORLD: failed to teleport player %s (%s) to map %d because of unknown reason!", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str(), loc.GetMapId()); GetPlayer()->ResetMap(); GetPlayer()->SetMap(oldMap); GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()); @@ -177,8 +178,8 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SendInitialPacketsAfterAddToMap(); // resurrect character at enter into instance where his corpse exist after add to map - Corpse* corpse = GetPlayer()->GetCorpse(); - if (corpse && corpse->GetType() != CORPSE_BONES && corpse->GetMapId() == GetPlayer()->GetMapId()) + Corpse* corpse = GetPlayer()->GetMap()->GetCorpseByPlayer(GetPlayer()->GetGUID()); + if (corpse && corpse->GetType() != CORPSE_BONES) { if (mEntry->IsDungeon()) { @@ -230,14 +231,14 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "MSG_MOVE_TELEPORT_ACK"); #endif - uint64 guid; - recvData.readPackGUID(guid); + ObjectGuid guid; + recvData >> guid.ReadAsPacked(); uint32 flags, time; recvData >> flags >> time; // unused #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Guid " UI64FMTD, guid); + LOG_DEBUG("server", "Guid %s", guid.ToString().c_str()); #endif #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("server", "Flags %u, time %u", flags, time / IN_MILLISECONDS); @@ -317,9 +318,8 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvData) } /* extract packet */ - uint64 guid; - - recvData.readPackGUID(guid); + ObjectGuid guid; + recvData >> guid.ReadAsPacked(); // prevent tampered movement data if (!guid || guid != mover->GetGUID()) @@ -523,11 +523,11 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket& recvData) #endif /* extract packet */ - uint64 guid; + ObjectGuid guid; uint32 unk1; float newspeed; - recvData.readPackGUID(guid); + recvData >> guid.ReadAsPacked(); // pussywizard: special check, only player mover allowed here if (guid != _player->m_mover->GetGUID() || guid != _player->GetGUID()) @@ -629,13 +629,14 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Recvd CMSG_SET_ACTIVE_MOVER"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; if (GetPlayer()->IsInWorld() && _player->m_mover && _player->m_mover->IsInWorld()) { if (_player->m_mover->GetGUID() != guid) - LOG_ERROR("server", "HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID()); + LOG_ERROR("server", "HandleSetActiveMoverOpcode: incorrect mover guid: mover is %s and should be %s", + guid.ToString().c_str(), _player->m_mover->GetGUID().ToString().c_str()); } } @@ -645,8 +646,8 @@ void WorldSession::HandleMoveNotActiveMover(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Recvd CMSG_MOVE_NOT_ACTIVE_MOVER"); #endif - uint64 old_mover_guid; - recvData.readPackGUID(old_mover_guid); + ObjectGuid old_mover_guid; + recvData >> old_mover_guid.ReadAsPacked(); // pussywizard: typical check for incomming movement packets if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || old_mover_guid != _player->m_mover->GetGUID()) @@ -665,7 +666,7 @@ void WorldSession::HandleMoveNotActiveMover(WorldPacket& recvData) void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recvData*/) { WorldPacket data(SMSG_MOUNTSPECIAL_ANIM, 8); - data << uint64(GetPlayer()->GetGUID()); + data << GetPlayer()->GetGUID(); GetPlayer()->SendMessageToSet(&data, false); } @@ -676,8 +677,8 @@ void WorldSession::HandleMoveKnockBackAck(WorldPacket& recvData) LOG_DEBUG("network", "CMSG_MOVE_KNOCK_BACK_ACK"); #endif - uint64 guid; - recvData.readPackGUID(guid); + ObjectGuid guid; + recvData >> guid.ReadAsPacked(); // pussywizard: typical check for incomming movement packets if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || guid != _player->m_mover->GetGUID()) @@ -695,7 +696,7 @@ void WorldSession::HandleMoveKnockBackAck(WorldPacket& recvData) _player->m_mover->m_movementInfo = movementInfo; WorldPacket data(MSG_MOVE_KNOCK_BACK, 66); - data.appendPackGUID(guid); + data << guid.WriteAsPacked(); _player->m_mover->BuildMovementPacket(&data); // knockback specific info @@ -713,8 +714,8 @@ void WorldSession::HandleMoveHoverAck(WorldPacket& recvData) LOG_DEBUG("network", "CMSG_MOVE_HOVER_ACK"); #endif - uint64 guid; // guid - unused - recvData.readPackGUID(guid); + ObjectGuid guid; + recvData >> guid.ReadAsPacked(); recvData.read_skip<uint32>(); // unk @@ -731,8 +732,8 @@ void WorldSession::HandleMoveWaterWalkAck(WorldPacket& recvData) LOG_DEBUG("network", "CMSG_MOVE_WATER_WALK_ACK"); #endif - uint64 guid; // guid - unused - recvData.readPackGUID(guid); + ObjectGuid guid; + recvData >> guid.ReadAsPacked(); recvData.read_skip<uint32>(); // unk @@ -748,7 +749,7 @@ void WorldSession::HandleSummonResponseOpcode(WorldPacket& recvData) if (!_player->IsAlive() || _player->IsInCombat()) return; - uint64 summoner_guid; + ObjectGuid summoner_guid; bool agree; recvData >> summoner_guid; recvData >> agree; @@ -773,30 +774,30 @@ void WorldSession::HandleMoveTimeSkippedOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Recvd CMSG_MOVE_TIME_SKIPPED"); #endif - uint64 guid; + ObjectGuid guid; uint32 timeSkipped; - recvData.readPackGUID(guid); + recvData >> guid.ReadAsPacked(); recvData >> timeSkipped; Unit* mover = GetPlayer()->m_mover; if (!mover) { - LOG_ERROR("server", "WorldSession::HandleMoveTimeSkippedOpcode wrong mover state from the unit moved by the player [" UI64FMTD "]", GetPlayer()->GetGUID()); + LOG_ERROR("server", "WorldSession::HandleMoveTimeSkippedOpcode wrong mover state from the unit moved by the player [%s]", GetPlayer()->GetGUID().ToString().c_str()); return; } // prevent tampered movement data if (guid != mover->GetGUID()) { - LOG_ERROR("server", "WorldSession::HandleMoveTimeSkippedOpcode wrong guid from the unit moved by the player [" UI64FMTD "]", GetPlayer()->GetGUID()); + LOG_ERROR("server", "WorldSession::HandleMoveTimeSkippedOpcode wrong guid from the unit moved by the player [%s]", GetPlayer()->GetGUID().ToString().c_str()); return; } mover->m_movementInfo.time += timeSkipped; WorldPacket data(MSG_MOVE_TIME_SKIPPED, recvData.size()); - data.appendPackGUID(guid); + data << guid.WriteAsPacked(); data << timeSkipped; GetPlayer()->SendMessageToSet(&data, false); } diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index b4161d5e19..7e1e928a8d 100644 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -39,14 +39,14 @@ enum StableResultCode void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TABARDDESIGNER); if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleTabardVendorActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleTabardVendorActivateOpcode - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str()); #endif return; } @@ -58,7 +58,7 @@ void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket& recvData) SendTabardVendorActivate(guid); } -void WorldSession::SendTabardVendorActivate(uint64 guid) +void WorldSession::SendTabardVendorActivate(ObjectGuid guid) { WorldPacket data(MSG_TABARDVENDOR_ACTIVATE, 8); data << guid; @@ -67,7 +67,7 @@ void WorldSession::SendTabardVendorActivate(uint64 guid) void WorldSession::HandleBankerActivateOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Received CMSG_BANKER_ACTIVATE"); @@ -79,7 +79,7 @@ void WorldSession::HandleBankerActivateOpcode(WorldPacket& recvData) if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleBankerActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleBankerActivateOpcode - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str()); #endif return; } @@ -91,7 +91,7 @@ void WorldSession::HandleBankerActivateOpcode(WorldPacket& recvData) SendShowBank(guid); } -void WorldSession::SendShowBank(uint64 guid) +void WorldSession::SendShowBank(ObjectGuid guid) { WorldPacket data(SMSG_SHOW_BANK, 8); data << guid; @@ -99,7 +99,7 @@ void WorldSession::SendShowBank(uint64 guid) SendPacket(&data); } -void WorldSession::SendShowMailBox(uint64 guid) +void WorldSession::SendShowMailBox(ObjectGuid guid) { WorldPacket data(SMSG_SHOW_MAILBOX, 8); data << guid; @@ -108,19 +108,19 @@ void WorldSession::SendShowMailBox(uint64 guid) void WorldSession::HandleTrainerListOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; SendTrainerList(guid); } -void WorldSession::SendTrainerList(uint64 guid) +void WorldSession::SendTrainerList(ObjectGuid guid) { std::string str = GetAcoreString(LANG_NPC_TAINER_HELLO); SendTrainerList(guid, str); } -void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle) +void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: SendTrainerList"); @@ -130,7 +130,7 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle) if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: SendTrainerList - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: SendTrainerList - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str()); #endif return; } @@ -144,7 +144,7 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle) if (!ci) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: SendTrainerList - (GUID: %u) NO CREATUREINFO!", GUID_LOPART(guid)); + LOG_DEBUG("network", "WORLD: SendTrainerList - (%s) NO CREATUREINFO!", guid.ToString().c_str()); #endif return; } @@ -153,7 +153,7 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle) if (!trainer_spells) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: SendTrainerList - Training spells not found for creature (GUID: %u Entry: %u)", GUID_LOPART(guid), unit->GetEntry()); + LOG_DEBUG("network", "WORLD: SendTrainerList - Training spells not found for creature (%s)", guid.ToString().c_str()); #endif return; } @@ -243,19 +243,19 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle) void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; uint32 spellId = 0; recvData >> guid >> spellId; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_TRAINER_BUY_SPELL NpcGUID=%u, learn spell id is: %u", uint32(GUID_LOPART(guid)), spellId); + LOG_DEBUG("network", "WORLD: Received CMSG_TRAINER_BUY_SPELL Npc %s, learn spell id is: %u", guid.ToString().c_str(), spellId); #endif Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleTrainerBuySpellOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleTrainerBuySpellOpcode - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str()); #endif return; } @@ -297,7 +297,7 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recvData) _player->learnSpell(spellId); WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, 12); - data << uint64(guid); + data << guid; data << uint32(spellId); // should be same as in packet from client SendPacket(&data); } @@ -308,14 +308,14 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_GOSSIP_HELLO"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleGossipHelloOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleGossipHelloOpcode - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str()); #endif return; } @@ -373,7 +373,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket& recvData) uint32 option; uint32 unk; - uint64 guid; + ObjectGuid guid; std::string code = ""; recvData >> guid >> unk >> option; @@ -393,7 +393,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket& recvData) if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network.opcode", "WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network.opcode", "WORLD: HandleGossipSelectOptionOpcode - Unit (%s) not found or you can't interact with him.", guid.ToString().c_str()); #endif return; } @@ -420,7 +420,7 @@ void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: CMSG_SPIRIT_HEALER_ACTIVATE"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; @@ -428,7 +428,7 @@ void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket& recvData) if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleSpiritHealerActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleSpiritHealerActivateOpcode - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str()); #endif return; } @@ -448,9 +448,12 @@ void WorldSession::SendSpiritResurrect() // get corpse nearest graveyard GraveyardStruct const* corpseGrave = nullptr; - Corpse* corpse = _player->GetCorpse(); - if (corpse) - corpseGrave = sGraveyard->GetClosestGraveyard(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeamId()); + WorldLocation corpseLocation = _player->GetCorpseLocation(); + if (_player->HasCorpse()) + { + corpseGrave = sGraveyard->GetClosestGraveyard(corpseLocation.GetPositionX(), corpseLocation.GetPositionY(), + corpseLocation.GetPositionZ(), corpseLocation.GetMapId(), _player->GetTeamId()); + } // now can spawn bones _player->SpawnCorpseBones(); @@ -473,7 +476,7 @@ void WorldSession::SendSpiritResurrect() void WorldSession::HandleBinderActivateOpcode(WorldPacket& recvData) { - uint64 npcGUID; + ObjectGuid npcGUID; recvData >> npcGUID; if (!GetPlayer()->IsInWorld() || !GetPlayer()->IsAlive()) @@ -483,7 +486,7 @@ void WorldSession::HandleBinderActivateOpcode(WorldPacket& recvData) if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleBinderActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID))); + LOG_DEBUG("network", "WORLD: HandleBinderActivateOpcode - Unit (%s) not found or you can not interact with him.", npcGUID.ToString().c_str()); #endif return; } @@ -507,7 +510,7 @@ void WorldSession::SendBindPoint(Creature* npc) npc->CastSpell(_player, bindspell, true); WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, (8 + 4)); - data << uint64(npc->GetGUID()); + data << npc->GetGUID(); data << uint32(bindspell); SendPacket(&data); @@ -519,7 +522,7 @@ void WorldSession::HandleListStabledPetsOpcode(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Recv MSG_LIST_STABLED_PETS"); #endif - uint64 npcGUID; + ObjectGuid npcGUID; recvData >> npcGUID; @@ -537,11 +540,11 @@ void WorldSession::HandleListStabledPetsOpcode(WorldPacket& recvData) SendStablePet(npcGUID); } -void WorldSession::SendStablePet(uint64 guid) +void WorldSession::SendStablePet(ObjectGuid guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SLOTS_DETAIL); - stmt->setUInt32(0, _player->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); stmt->setUInt8(1, PET_SAVE_FIRST_STABLE_SLOT); stmt->setUInt8(2, PET_SAVE_LAST_STABLE_SLOT); @@ -549,7 +552,7 @@ void WorldSession::SendStablePet(uint64 guid) _sendStabledPetCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt)); } -void WorldSession::SendStablePetCallback(PreparedQueryResult result, uint64 guid) +void WorldSession::SendStablePetCallback(PreparedQueryResult result, ObjectGuid guid) { if (!GetPlayer()) return; @@ -560,7 +563,7 @@ void WorldSession::SendStablePetCallback(PreparedQueryResult result, uint64 guid WorldPacket data(MSG_LIST_STABLED_PETS, 200); // guess size - data << uint64 (guid); + data << guid; Pet* pet = _player->GetPet(); @@ -584,7 +587,7 @@ void WorldSession::SendStablePetCallback(PreparedQueryResult result, uint64 guid else if (_player->IsPetDismissed() || _player->GetTemporaryUnsummonedPetNumber()) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT); - stmt->setUInt32(0, _player->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); stmt->setUInt8(1, uint8(_player->GetTemporaryUnsummonedPetNumber() ? PET_SAVE_AS_CURRENT : PET_SAVE_NOT_IN_SLOT)); if (PreparedQueryResult _result = CharacterDatabase.AsyncQuery(stmt)) @@ -632,7 +635,7 @@ void WorldSession::HandleStablePet(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Recv CMSG_STABLE_PET"); #endif - uint64 npcGUID; + ObjectGuid npcGUID; recvData >> npcGUID; @@ -675,7 +678,7 @@ void WorldSession::HandleStablePet(WorldPacket& recvData) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SLOTS); - stmt->setUInt32(0, _player->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); stmt->setUInt8(1, PET_SAVE_FIRST_STABLE_SLOT); stmt->setUInt8(2, PET_SAVE_LAST_STABLE_SLOT); @@ -720,7 +723,7 @@ void WorldSession::HandleStablePetCallback(PreparedQueryResult result) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_PET_SLOT_BY_SLOT); stmt->setUInt8(0, freeSlot); - stmt->setUInt32(1, _player->GetGUIDLow()); + stmt->setUInt32(1, _player->GetGUID().GetCounter()); stmt->setUInt8(2, uint8(_player->GetTemporaryUnsummonedPetNumber() ? PET_SAVE_AS_CURRENT : PET_SAVE_NOT_IN_SLOT)); trans->Append(stmt); @@ -739,7 +742,7 @@ void WorldSession::HandleUnstablePet(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Recv CMSG_UNSTABLE_PET."); #endif - uint64 npcGUID; + ObjectGuid npcGUID; uint32 petnumber; recvData >> npcGUID >> petnumber; @@ -756,7 +759,7 @@ void WorldSession::HandleUnstablePet(WorldPacket& recvData) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_ENTRY); - stmt->setUInt32(0, _player->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); stmt->setUInt32(1, petnumber); stmt->setUInt8(2, PET_SAVE_FIRST_STABLE_SLOT); stmt->setUInt8(3, PET_SAVE_LAST_STABLE_SLOT); @@ -822,7 +825,7 @@ void WorldSession::HandleUnstablePetCallback(PreparedQueryResult result, uint32 PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_PET_SLOT_BY_SLOT); stmt->setUInt8(0, slot); - stmt->setUInt32(1, _player->GetGUIDLow()); + stmt->setUInt32(1, _player->GetGUID().GetCounter()); stmt->setUInt8(2, uint8(_player->GetTemporaryUnsummonedPetNumber() ? PET_SAVE_AS_CURRENT : PET_SAVE_NOT_IN_SLOT)); trans->Append(stmt); @@ -842,7 +845,7 @@ void WorldSession::HandleBuyStableSlot(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Recv CMSG_BUY_STABLE_SLOT."); #endif - uint64 npcGUID; + ObjectGuid npcGUID; recvData >> npcGUID; @@ -884,7 +887,7 @@ void WorldSession::HandleStableSwapPet(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: Recv CMSG_STABLE_SWAP_PET."); #endif - uint64 npcGUID; + ObjectGuid npcGUID; uint32 petId; recvData >> npcGUID >> petId; @@ -923,7 +926,7 @@ void WorldSession::HandleStableSwapPet(WorldPacket& recvData) // Find swapped pet slot in stable PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SLOT_BY_ID); - stmt->setUInt32(0, _player->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); stmt->setUInt32(1, petId); _stableSwapCallback.SetParam(petId); @@ -975,7 +978,7 @@ void WorldSession::HandleStableSwapPetCallback(PreparedQueryResult result, uint3 PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_PET_SLOT_BY_SLOT); stmt->setUInt8(0, slot); - stmt->setUInt32(1, _player->GetGUIDLow()); + stmt->setUInt32(1, _player->GetGUID().GetCounter()); stmt->setUInt8(2, uint8(_player->GetTemporaryUnsummonedPetNumber() ? PET_SAVE_AS_CURRENT : PET_SAVE_NOT_IN_SLOT)); trans->Append(stmt); @@ -998,7 +1001,7 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: CMSG_REPAIR_ITEM"); #endif - uint64 npcGUID, itemGUID; + ObjectGuid npcGUID, itemGUID; uint8 guildBank; // new in 2.3.2, bool that means from guild bank money recvData >> npcGUID >> itemGUID >> guildBank; @@ -1007,7 +1010,7 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recvData) if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleRepairItemOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID))); + LOG_DEBUG("network", "WORLD: HandleRepairItemOpcode - Unit (%s) not found or you can not interact with him.", npcGUID.ToString().c_str()); #endif return; } @@ -1024,7 +1027,7 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recvData) if (itemGUID) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "ITEM: Repair item, itemGUID = %u, npcGUID = %u", GUID_LOPART(itemGUID), GUID_LOPART(npcGUID)); + LOG_DEBUG("network", "ITEM: Repair item, item %s, npc %s", itemGUID.ToString().c_str(), npcGUID.ToString().c_str()); #endif Item* item = _player->GetItemByGuid(itemGUID); @@ -1034,7 +1037,7 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recvData) else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "ITEM: Repair all items, npcGUID = %u", GUID_LOPART(npcGUID)); + LOG_DEBUG("network", "ITEM: Repair all items, npc %s", npcGUID.ToString().c_str()); #endif _player->DurabilityRepairAll(true, discountMod, guildBank); } diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index a53cc6c85a..6886a52763 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -126,7 +126,7 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result, } Map* map = owner->GetMap(); - uint32 guid = sObjectMgr->GenerateLowGuid(HIGHGUID_PET); + ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Pet>(); Pet* pet = new Pet(owner, pet_type); LoadPetFromDBQueryHolder* holder = new LoadPetFromDBQueryHolder(pet_number, current, uint32(time(nullptr) - fields[14].GetUInt32()), fields[13].GetString(), savedhealth, savedmana); if (!pet->Create(guid, map, owner->GetPhaseMask(), petentry, pet_number) || !holder->Initialize()) @@ -140,7 +140,8 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result, owner->GetClosePoint(px, py, pz, pet->GetObjectSize(), PET_FOLLOW_DIST, pet->GetFollowAngle()); if (!pet->IsPositionValid()) { - LOG_ERROR("server", "Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", pet->GetGUIDLow(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY()); + LOG_ERROR("server", "Pet (%s, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", + pet->GetGUID().ToString().c_str(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY()); delete pet; delete holder; return PET_LOAD_ERROR; @@ -222,14 +223,14 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result, PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_PET_SLOT_BY_SLOT_EXCLUDE_ID); stmt->setUInt8(0, uint8(PET_SAVE_NOT_IN_SLOT)); - stmt->setUInt32(1, owner->GetGUIDLow()); + stmt->setUInt32(1, owner->GetGUID().GetCounter()); stmt->setUInt8(2, uint8(PET_SAVE_AS_CURRENT)); stmt->setUInt32(3, pet_number); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID); stmt->setUInt8(0, uint8(PET_SAVE_AS_CURRENT)); - stmt->setUInt32(1, owner->GetGUIDLow()); + stmt->setUInt32(1, owner->GetGUID().GetCounter()); stmt->setUInt32(2, pet_number); trans->Append(stmt); @@ -242,8 +243,8 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result, if (summon_spell_id) { WorldPacket data(SMSG_SPELL_GO, (8 + 8 + 4 + 4 + 2)); - data.append(owner->GetPackGUID()); - data.append(owner->GetPackGUID()); + data << owner->GetPackGUID(); + data << owner->GetPackGUID(); data << uint8(0); data << uint32(summon_spell_id); data << uint32(256); // CAST_FLAG_UNKNOWN3 @@ -354,11 +355,11 @@ void WorldSession::HandleLoadPetFromDBSecondCallback(LoadPetFromDBQueryHolder* h void WorldSession::HandleDismissCritter(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_DISMISS_CRITTER for GUID " UI64FMTD, guid); + LOG_DEBUG("network", "WORLD: Received CMSG_DISMISS_CRITTER for %s", guid.ToString().c_str()); #endif Unit* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid); @@ -366,7 +367,8 @@ void WorldSession::HandleDismissCritter(WorldPacket& recvData) if (!pet) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "Vanitypet (guid: %u) does not exist - player '%s' (guid: %u / account: %u) attempted to dismiss it (possibly lagged out)", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow(), GetAccountId()); + LOG_DEBUG("network", "Vanitypet (%s) does not exist - player %s (%s / account: %u) attempted to dismiss it (possibly lagged out)", + guid.ToString().c_str(), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str(), GetAccountId()); #endif return; } @@ -380,9 +382,9 @@ void WorldSession::HandleDismissCritter(WorldPacket& recvData) void WorldSession::HandlePetAction(WorldPacket& recvData) { - uint64 guid1; + ObjectGuid guid1; uint32 data; - uint64 guid2; + ObjectGuid guid2; recvData >> guid1; //pet guid recvData >> data; recvData >> guid2; //tag guid @@ -393,18 +395,18 @@ void WorldSession::HandlePetAction(WorldPacket& recvData) // used also for charmed creature Unit* pet = ObjectAccessor::GetUnit(*_player, guid1); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "HandlePetAction: Pet %u - flag: %u, spellid: %u, target: %u.", uint32(GUID_LOPART(guid1)), uint32(flag), spellid, uint32(GUID_LOPART(guid2))); + LOG_DEBUG("server", "HandlePetAction: Pet %s - flag: %u, spellid: %u, target: %s.", guid1.ToString().c_str(), uint32(flag), spellid, guid2.ToString().c_str()); #endif if (!pet) { - LOG_ERROR("server", "HandlePetAction: Pet (GUID: %u) doesn't exist for player '%s'", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName().c_str()); + LOG_ERROR("server", "HandlePetAction: Pet (%s) doesn't exist for player %s", guid1.ToString().c_str(), GetPlayer()->GetName().c_str()); return; } if (pet != GetPlayer()->GetFirstControlled()) { - LOG_ERROR("server", "HandlePetAction: Pet (GUID: %u) does not belong to player '%s'", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName().c_str()); + LOG_ERROR("server", "HandlePetAction: Pet (%s) does not belong to player %s", guid1.ToString().c_str(), GetPlayer()->GetName().c_str()); return; } @@ -445,24 +447,24 @@ void WorldSession::HandlePetAction(WorldPacket& recvData) void WorldSession::HandlePetStopAttack(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_PET_STOP_ATTACK for GUID " UI64FMTD "", guid); + LOG_DEBUG("network", "WORLD: Received CMSG_PET_STOP_ATTACK for %s", guid.ToString().c_str()); #endif Unit* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid); if (!pet) { - LOG_ERROR("server", "HandlePetStopAttack: Pet %u does not exist", uint32(GUID_LOPART(guid))); + LOG_ERROR("server", "HandlePetStopAttack: Pet %s does not exist", guid.ToString().c_str()); return; } if (pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm()) { - LOG_ERROR("server", "HandlePetStopAttack: Pet GUID %u isn't a pet or charmed creature of player %s", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); + LOG_ERROR("server", "HandlePetStopAttack: Pet %s isn't a pet or charmed creature of player %s", guid.ToString().c_str(), GetPlayer()->GetName().c_str()); return; } @@ -473,13 +475,13 @@ void WorldSession::HandlePetStopAttack(WorldPacket& recvData) pet->ClearInPetCombat(); } -void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid, uint16 flag, uint64 guid2) +void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint16 spellid, uint16 flag, ObjectGuid guid2) { CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) { - LOG_ERROR("server", "WorldSession::HandlePetAction(petGuid: " UI64FMTD ", tagGuid: " UI64FMTD ", spellId: %u, flag: %u): object (entry: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", - guid1, guid2, spellid, flag, pet->GetGUIDLow(), pet->GetTypeId()); + LOG_ERROR("server", "WorldSession::HandlePetAction(petGuid: %s, tagGuid: %s, spellId: %u, flag: %u): object (%s) is considered pet-like but doesn't have a charminfo!", + guid1.ToString().c_str(), guid2.ToString().c_str(), spellid, flag, pet->GetGUID().ToString().c_str()); return; } @@ -509,7 +511,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid pet->ToPet()->ClearCastWhenWillAvailable(); charmInfo->SetForcedSpell(0); - charmInfo->SetForcedTargetGUID(0); + charmInfo->SetForcedTargetGUID(); break; } case COMMAND_FOLLOW: //spellid=1792 //FOLLOW @@ -529,7 +531,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid charmInfo->SetIsFollowing(false); charmInfo->RemoveStayPosition(); charmInfo->SetForcedSpell(0); - charmInfo->SetForcedTargetGUID(0); + charmInfo->SetForcedTargetGUID(); break; } case COMMAND_ATTACK: //spellid=1792 //ATTACK @@ -748,7 +750,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid spell->prepare(&(spell->m_targets)); charmInfo->SetForcedSpell(0); - charmInfo->SetForcedTargetGUID(0); + charmInfo->SetForcedTargetGUID(); } else if (pet->ToPet() && (result == SPELL_FAILED_LINE_OF_SIGHT || result == SPELL_FAILED_OUT_OF_RANGE)) { @@ -909,7 +911,7 @@ void WorldSession::HandlePetNameQuery(WorldPacket& recvData) #endif uint32 petnumber; - uint64 petguid; + ObjectGuid petguid; recvData >> petnumber; recvData >> petguid; @@ -917,7 +919,7 @@ void WorldSession::HandlePetNameQuery(WorldPacket& recvData) SendPetNameQuery(petguid, petnumber); } -void WorldSession::SendPetNameQuery(uint64 petguid, uint32 petnumber) +void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber) { Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid); if (!pet) @@ -961,7 +963,7 @@ void WorldSession::SendPetNameQuery(uint64 petguid, uint32 petnumber) SendPacket(&data); } -bool WorldSession::CheckStableMaster(uint64 guid) +bool WorldSession::CheckStableMaster(ObjectGuid guid) { // spell case or GM if (guid == GetPlayer()->GetGUID()) @@ -969,7 +971,7 @@ bool WorldSession::CheckStableMaster(uint64 guid) if (!GetPlayer()->IsGameMaster() && !GetPlayer()->HasAuraType(SPELL_AURA_OPEN_STABLE)) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player (GUID:%u) attempt open stable in cheating way.", GUID_LOPART(guid)); + LOG_DEBUG("server", "Player (%s) attempt open stable in cheating way.", guid.ToString().c_str()); #endif return false; } @@ -980,7 +982,7 @@ bool WorldSession::CheckStableMaster(uint64 guid) if (!GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_STABLEMASTER)) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Stablemaster (GUID:%u) not found or you can't interact with him.", GUID_LOPART(guid)); + LOG_DEBUG("server", "Stablemaster (%s) not found or you can't interact with him.", guid.ToString().c_str()); #endif return false; } @@ -994,7 +996,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData) LOG_DEBUG("server", "HandlePetSetAction. CMSG_PET_SET_ACTION"); #endif - uint64 petguid; + ObjectGuid petguid; uint8 count; recvData >> petguid; @@ -1002,7 +1004,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData) Unit* checkPet = ObjectAccessor::GetUnit(*_player, petguid); if (!checkPet || checkPet != _player->GetFirstControlled()) { - LOG_ERROR("server", "HandlePetSetAction: Unknown pet (GUID: %u) or pet owner (GUID: %u)", GUID_LOPART(petguid), _player->GetGUIDLow()); + LOG_ERROR("server", "HandlePetSetAction: Unknown pet (%s) or pet owner (%s)", petguid.ToString().c_str(), _player->GetGUID().ToString().c_str()); return; } @@ -1036,7 +1038,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData) } Unit::ControlSet petsSet; - if (checkPet->GetEntry() != GUID_ENPART(petguid)) + if (checkPet->GetEntry() != petguid.GetEntry()) petsSet.insert(checkPet); else petsSet = _player->m_Controlled; @@ -1045,13 +1047,14 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData) for (Unit::ControlSet::const_iterator itr = petsSet.begin(); itr != petsSet.end(); ++itr) { Unit* pet = *itr; - if (checkPet->GetEntry() == GUID_ENPART(petguid) && pet->GetEntry() != GUID_ENPART(petguid)) + if (checkPet->GetEntry() == petguid.GetEntry() && pet->GetEntry() != petguid.GetEntry()) continue; CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) { - LOG_ERROR("server", "WorldSession::HandlePetSetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); + LOG_ERROR("server", "WorldSession::HandlePetSetAction: object (%s TypeId: %u) is considered pet-like but doesn't have a charminfo!", + pet->GetGUID().ToString().c_str(), pet->GetTypeId()); continue; } @@ -1123,7 +1126,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData) LOG_DEBUG("server", "HandlePetRename. CMSG_PET_RENAME"); #endif - uint64 petguid; + ObjectGuid petguid; uint8 isdeclined; std::string name; @@ -1133,7 +1136,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData) recvData >> name; recvData >> isdeclined; - Pet* pet = ObjectAccessor::FindPet(petguid); + Pet* pet = ObjectAccessor::GetPet(*_player, petguid); // check it! if (!pet || !pet->IsPet() || ((Pet*)pet)->getPetType() != HUNTER_PET || !pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) || @@ -1187,7 +1190,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData) trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHAR_PET_DECLINEDNAME); - stmt->setUInt32(0, _player->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); for (uint8 i = 0; i < 5; i++) stmt->setString(i + 1, declinedname.name[i]); @@ -1198,7 +1201,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_NAME); stmt->setString(0, name); - stmt->setUInt32(1, _player->GetGUIDLow()); + stmt->setUInt32(1, _player->GetGUID().GetCounter()); stmt->setUInt32(2, pet->GetCharmInfo()->GetPetNumber()); trans->Append(stmt); @@ -1209,10 +1212,10 @@ void WorldSession::HandlePetRename(WorldPacket& recvData) void WorldSession::HandlePetAbandon(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; //pet guid #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "HandlePetAbandon. CMSG_PET_ABANDON pet guid is %u", GUID_LOPART(guid)); + LOG_DEBUG("server", "HandlePetAbandon. CMSG_PET_ABANDON pet is %s", guid.ToString().c_str()); #endif if (!_player->IsInWorld()) @@ -1242,7 +1245,7 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("server", "CMSG_PET_SPELL_AUTOCAST"); #endif - uint64 guid; + ObjectGuid guid; uint32 spellid; uint8 state; //1 for on, 0 for off recvPacket >> guid >> spellid >> state; @@ -1250,7 +1253,7 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket) if (!_player->GetGuardianPet() && !_player->GetCharm()) return; - if (IS_PLAYER_GUID(guid)) + if (guid.IsPlayer()) return; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); @@ -1260,12 +1263,12 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket) Creature* checkPet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid); if (!checkPet || (checkPet != _player->GetGuardianPet() && checkPet != _player->GetCharm())) { - LOG_ERROR("server", "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); + LOG_ERROR("server", "HandlePetSpellAutocastOpcode.Pet %s isn't pet of player %s .", guid.ToString().c_str(), GetPlayer()->GetName().c_str()); return; } Unit::ControlSet petsSet; - if (checkPet->GetEntry() != GUID_ENPART(guid)) + if (checkPet->GetEntry() != guid.GetEntry()) petsSet.insert(checkPet); else petsSet = _player->m_Controlled; @@ -1274,7 +1277,7 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket) for (Unit::ControlSet::const_iterator itr = petsSet.begin(); itr != petsSet.end(); ++itr) { Unit* pet = *itr; - if (checkPet->GetEntry() == GUID_ENPART(guid) && pet->GetEntry() != GUID_ENPART(guid)) + if (checkPet->GetEntry() == guid.GetEntry() && pet->GetEntry() != guid.GetEntry()) continue; // do not add not learned spells/ passive spells @@ -1284,7 +1287,8 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket) CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) { - LOG_ERROR("server", "WorldSession::HandlePetSpellAutocastOpcod: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); + LOG_ERROR("server", "WorldSession::HandlePetSpellAutocastOpcod: object (%s TypeId: %u) is considered pet-like but doesn't have a charminfo!", + pet->GetGUID().ToString().c_str(), pet->GetTypeId()); continue; } @@ -1303,7 +1307,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) LOG_DEBUG("network", "WORLD: CMSG_PET_CAST_SPELL"); #endif - uint64 guid; + ObjectGuid guid; uint8 castCount; uint32 spellId; uint8 castFlags; @@ -1311,7 +1315,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) recvPacket >> guid >> castCount >> spellId >> castFlags; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: CMSG_PET_CAST_SPELL, guid: " UI64FMTD ", castCount: %u, spellId %u, castFlags %u", guid, castCount, spellId, castFlags); + LOG_DEBUG("network", "WORLD: CMSG_PET_CAST_SPELL, guid: %s, castCount: %u, spellId %u, castFlags %u", guid.ToString().c_str(), castCount, spellId, castFlags); #endif // This opcode is also sent from charmed and possessed units (players and creatures) @@ -1322,7 +1326,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) if (!caster || (caster != _player->GetGuardianPet() && caster != _player->GetCharm())) { - LOG_ERROR("server", "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); + LOG_ERROR("server", "HandlePetCastSpellOpcode: Pet %s isn't pet of player %s .", guid.ToString().c_str(), GetPlayer()->GetName().c_str()); return; } @@ -1424,7 +1428,7 @@ void WorldSession::HandlePetLearnTalent(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: CMSG_PET_LEARN_TALENT"); #endif - uint64 guid; + ObjectGuid guid; uint32 talent_id, requested_rank; recvData >> guid >> talent_id >> requested_rank; @@ -1438,7 +1442,7 @@ void WorldSession::HandleLearnPreviewTalentsPet(WorldPacket& recvData) LOG_DEBUG("network", "CMSG_LEARN_PREVIEW_TALENTS_PET"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; uint32 talentsCount; diff --git a/src/server/game/Handlers/PetitionsHandler.cpp b/src/server/game/Handlers/PetitionsHandler.cpp index 96a4d10ca3..722c2f8b1f 100644 --- a/src/server/game/Handlers/PetitionsHandler.cpp +++ b/src/server/game/Handlers/PetitionsHandler.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/> * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> @@ -27,7 +27,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData) LOG_DEBUG("network", "Received opcode CMSG_PETITION_BUY"); #endif - uint64 guidNPC; + ObjectGuid guidNPC; uint32 clientIndex; // 1 for guild and arenaslot+1 for arenas in client std::string name; @@ -55,7 +55,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData) recvData.read_skip<uint32>(); // 0 #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "Petitioner with GUID %u tried sell petition: name %s", GUID_LOPART(guidNPC), name.c_str()); + LOG_DEBUG("network", "Petitioner (%s) tried sell petition: name %s", guidNPC.ToString().c_str(), name.c_str()); #endif // prevent cheating @@ -63,7 +63,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData) if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandlePetitionBuyOpcode - Unit (GUID: %u) not found or you can't interact with him.", GUID_LOPART(guidNPC)); + LOG_DEBUG("network", "WORLD: HandlePetitionBuyOpcode - Unit (%s) not found or you can't interact with him.", guidNPC.ToString().c_str()); #endif return; } @@ -183,7 +183,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData) if (!charter) return; - charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetGUIDLow()); + charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetGUID().GetCounter()); // ITEM_FIELD_ENCHANTMENT_1_1 is guild/arenateam id // ITEM_FIELD_ENCHANTMENT_1_1+1 is current signatures count (showed on item) charter->SetState(ITEM_CHANGED, _player); @@ -192,7 +192,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData) // a petition is invalid, if both the owner and the type matches // we checked above, if this player is in an arenateam, so this must be // datacorruption - Petition const* petition = sPetitionMgr->GetPetitionByOwnerWithType(_player->GetGUIDLow(), type); + Petition const* petition = sPetitionMgr->GetPetitionByOwnerWithType(_player->GetGUID(), type); CharacterDatabase.EscapeString(name); SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -200,7 +200,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData) if (petition) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "Invalid petition GUIDs: %u", petition->petitionGuid); + LOG_DEBUG("network", "Invalid petition: %s", petition->petitionGuid.ToString().c_str()); #endif trans->PAppend("DELETE FROM petition WHERE petitionguid = %u", petition->petitionGuid); @@ -212,8 +212,8 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData) // xinef: petition pointer is invalid from now on PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PETITION); - stmt->setUInt32(0, _player->GetGUIDLow()); - stmt->setUInt32(1, charter->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); + stmt->setUInt32(1, charter->GetGUID().GetCounter()); stmt->setString(2, name); stmt->setUInt8(3, uint8(type)); trans->Append(stmt); @@ -221,7 +221,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData) CharacterDatabase.CommitTransaction(trans); // xinef: fill petition store - sPetitionMgr->AddPetition(charter->GetGUIDLow(), _player->GetGUIDLow(), name, uint8(type)); + sPetitionMgr->AddPetition(charter->GetGUID(), _player->GetGUID(), name, uint8(type)); } void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData) @@ -230,13 +230,11 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData) LOG_DEBUG("network", "Received opcode CMSG_PETITION_SHOW_SIGNATURES"); #endif - uint64 petitionguid; + ObjectGuid petitionguid; recvData >> petitionguid; // petition guid - // solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?) - uint32 petitionGuidLow = GUID_LOPART(petitionguid); - - Petition const* petition = sPetitionMgr->GetPetition(petitionGuidLow); + // solve (possible) some strange compile problems with explicit use petition low guid at some GCC versions (wrong code optimization in compiler?) + Petition const* petition = sPetitionMgr->GetPetition(petitionguid); if (!petition) return; @@ -246,23 +244,23 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData) if (type == GUILD_CHARTER_TYPE && _player->GetGuildId()) return; - Signatures const* signatures = sPetitionMgr->GetSignature(petitionGuidLow); + Signatures const* signatures = sPetitionMgr->GetSignature(petitionguid); uint8 signs = signatures ? signatures->signatureMap.size() : 0; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_PETITION_SHOW_SIGNATURES petition entry: '%u'", petitionGuidLow); + LOG_DEBUG("network", "CMSG_PETITION_SHOW_SIGNATURES petition entry: '%u'", petitionguid.GetCounter()); #endif WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + 1 + signs * 12)); - data << uint64(petitionguid); // petition guid - data << uint64(_player->GetGUID()); // owner guid - data << uint32(petitionGuidLow); // guild guid + data << petitionguid; // petition guid + data << _player->GetGUID(); // owner guid + data << uint32(petitionguid.GetCounter()); // guild guid data << uint8(signs); // sign's count if (signs) for (SignatureMap::const_iterator itr = signatures->signatureMap.begin(); itr != signatures->signatureMap.end(); ++itr) { - data << uint64(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); // Player GUID + data << itr->first; // Player GUID data << uint32(0); // there 0 ... } @@ -275,34 +273,34 @@ void WorldSession::HandlePetitionQueryOpcode(WorldPacket& recvData) LOG_DEBUG("network", "Received opcode CMSG_PETITION_QUERY"); // ok #endif - uint32 guildguid; - uint64 petitionguid; - recvData >> guildguid; // in Trinity always same as GUID_LOPART(petitionguid) + ObjectGuid::LowType guildguid; + ObjectGuid petitionguid; + recvData >> guildguid; // in Trinity always same as petition low guid recvData >> petitionguid; // petition guid #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_PETITION_QUERY Petition GUID %u Guild GUID %u", GUID_LOPART(petitionguid), guildguid); + LOG_DEBUG("network", "CMSG_PETITION_QUERY Petition (%s) Guild GUID %u", petitionguid.ToString().c_str(), guildguid); #endif SendPetitionQueryOpcode(petitionguid); } -void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid) +void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid) { - Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionguid)); + Petition const* petition = sPetitionMgr->GetPetition(petitionguid); if (!petition) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_PETITION_QUERY failed for petition (GUID: %u)", GUID_LOPART(petitionguid)); + LOG_DEBUG("network", "CMSG_PETITION_QUERY failed for petition (%s)", petitionguid.ToString().c_str()); #endif return; } uint8 type = petition->petitionType; WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4 + 8 + petition->petitionName.size() + 1 + 1 + 4 * 12 + 2 + 10)); - data << uint32(GUID_LOPART(petitionguid)); // guild/team guid (in Trinity always same as GUID_LOPART(petition guid) - data << MAKE_NEW_GUID(petition->ownerGuid, 0, HIGHGUID_PLAYER); // charter owner guid - data << petition->petitionName; // name (guild/arena team) - data << uint8(0); // some string + data << uint32(petitionguid.GetCounter()); // guild/team guid (in Trinity always same as petition low guid + data << petition->ownerGuid; // charter owner guid + data << petition->petitionName; // name (guild/arena team) + data << uint8(0); // some string if (type == GUILD_CHARTER_TYPE) { uint32 needed = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS); @@ -341,7 +339,7 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recvData) LOG_DEBUG("network", "Received opcode MSG_PETITION_RENAME"); // ok #endif - uint64 petitionGuid; + ObjectGuid petitionGuid; std::string newName; recvData >> petitionGuid; // guid @@ -351,11 +349,11 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recvData) if (!item) return; - Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionGuid)); + Petition const* petition = sPetitionMgr->GetPetition(petitionGuid); if (!petition) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "CMSG_PETITION_QUERY failed for petition (GUID: %u)", GUID_LOPART(petitionGuid)); + LOG_DEBUG("network", "CMSG_PETITION_QUERY failed for petition (%s)", petitionGuid.ToString().c_str()); #endif return; } @@ -390,7 +388,7 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recvData) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PETITION_NAME); stmt->setString(0, newName); - stmt->setUInt32(1, GUID_LOPART(petitionGuid)); + stmt->setUInt32(1, petitionGuid.GetCounter()); CharacterDatabase.Execute(stmt); @@ -398,10 +396,10 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recvData) const_cast<Petition*>(petition)->petitionName = newName; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "Petition (GUID: %u) renamed to '%s'", GUID_LOPART(petitionGuid), newName.c_str()); + LOG_DEBUG("network", "Petition (%s) renamed to %s", petitionGuid.ToString().c_str(), newName.c_str()); #endif WorldPacket data(MSG_PETITION_RENAME, (8 + newName.size() + 1)); - data << uint64(petitionGuid); + data << petitionGuid; data << newName; SendPacket(&data); } @@ -412,31 +410,30 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recvData) LOG_DEBUG("network", "Received opcode CMSG_PETITION_SIGN"); // ok #endif - uint64 petitionGuid; + ObjectGuid petitionGuid; uint8 unk; recvData >> petitionGuid; // petition guid recvData >> unk; - Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionGuid)); + Petition const* petition = sPetitionMgr->GetPetition(petitionGuid); if (!petition) { - LOG_ERROR("server", "Petition %u is not found for player %u %s", GUID_LOPART(petitionGuid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName().c_str()); + LOG_ERROR("server", "Petition %s is not found for player %s (Name: %s)", petitionGuid.ToString().c_str(), GetPlayer()->GetGUID().ToString().c_str(), GetPlayer()->GetName().c_str()); return; } - uint64 ownerGuid = MAKE_NEW_GUID(petition->ownerGuid, 0, HIGHGUID_PLAYER); uint8 type = petition->petitionType; - uint32 playerGuid = _player->GetGUIDLow(); + ObjectGuid playerGuid = _player->GetGUID(); if (petition->ownerGuid == playerGuid) return; - Signatures const* signatures = sPetitionMgr->GetSignature(GUID_LOPART(petitionGuid)); + Signatures const* signatures = sPetitionMgr->GetSignature(petitionGuid); if (!signatures) return; // not let enemies sign guild charter - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeamId() != sObjectMgr->GetPlayerTeamIdByGUID(ownerGuid)) + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeamId() != sObjectMgr->GetPlayerTeamIdByGUID(petition->ownerGuid.GetCounter())) { if (type != GUILD_CHARTER_TYPE) SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED); @@ -501,38 +498,38 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recvData) if (found) { WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8 + 8 + 4)); - data << uint64(petitionGuid); - data << uint64(_player->GetGUID()); + data << petitionGuid; + data << playerGuid; data << (uint32)PETITION_SIGN_ALREADY_SIGNED; // close at signer side SendPacket(&data); // update for owner if online - if (Player* owner = ObjectAccessor::FindPlayerInOrOutOfWorld(ownerGuid)) + if (Player* owner = ObjectAccessor::FindConnectedPlayer(petition->ownerGuid)) owner->GetSession()->SendPacket(&data); return; } PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PETITION_SIGNATURE); - stmt->setUInt32(0, GUID_LOPART(ownerGuid)); - stmt->setUInt32(1, GUID_LOPART(petitionGuid)); - stmt->setUInt32(2, playerGuid); + stmt->setUInt32(0, petition->ownerGuid.GetCounter()); + stmt->setUInt32(1, petitionGuid.GetCounter()); + stmt->setUInt32(2, playerGuid.GetCounter()); stmt->setUInt32(3, GetAccountId()); CharacterDatabase.Execute(stmt); // xinef: fill petition store - sPetitionMgr->AddSignature(GUID_LOPART(petitionGuid), GetAccountId(), playerGuid); + sPetitionMgr->AddSignature(petitionGuid, GetAccountId(), playerGuid); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "PETITION SIGN: GUID %u by player: %s (GUID: %u Account: %u)", GUID_LOPART(petitionGuid), _player->GetName().c_str(), playerGuid, GetAccountId()); + LOG_DEBUG("network", "PETITION SIGN: %s by player: %s (%s, Account: %u)", petitionGuid.ToString().c_str(), _player->GetName().c_str(), playerGuid.ToString().c_str(), GetAccountId()); #endif WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8 + 8 + 4)); - data << uint64(petitionGuid); - data << uint64(_player->GetGUID()); + data << petitionGuid; + data << playerGuid; data << uint32(PETITION_SIGN_OK); // close at signer side @@ -544,7 +541,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recvData) // item->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1+1, signs); // update for owner if online - if (Player* owner = ObjectAccessor::FindPlayerInOrOutOfWorld(ownerGuid)) + if (Player* owner = ObjectAccessor::FindConnectedPlayer(petition->ownerGuid)) owner->GetSession()->SendPacket(&data); } @@ -554,22 +551,21 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket& recvData) LOG_DEBUG("network", "Received opcode MSG_PETITION_DECLINE"); // ok #endif - uint64 petitionguid; - uint64 ownerguid; + ObjectGuid petitionguid; + ObjectGuid ownerguid; recvData >> petitionguid; // petition guid #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "Petition %u declined by %u", GUID_LOPART(petitionguid), _player->GetGUIDLow()); + LOG_DEBUG("network", "Petition %s declined by %s", petitionguid.ToString().c_str(), _player->GetGUID().ToString().c_str()); #endif - Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionguid)); + Petition const* petition = sPetitionMgr->GetPetition(petitionguid); if (!petition) return; - ownerguid = MAKE_NEW_GUID(petition->ownerGuid, 0, HIGHGUID_PLAYER); - if (Player* owner = ObjectAccessor::FindPlayerInOrOutOfWorld(ownerguid)) // petition owner online + if (Player* owner = ObjectAccessor::FindConnectedPlayer(ownerguid)) // petition owner online { WorldPacket data(MSG_PETITION_DECLINE, 8); - data << uint64(_player->GetGUID()); + data << _player->GetGUID(); owner->GetSession()->SendPacket(&data); } } @@ -580,18 +576,18 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recvData) LOG_DEBUG("network", "Received opcode CMSG_OFFER_PETITION"); // ok #endif - uint64 petitionguid, plguid; + ObjectGuid petitionguid, plguid; uint32 junk; Player* player; recvData >> junk; // this is not petition type! recvData >> petitionguid; // petition guid recvData >> plguid; // player guid - player = ObjectAccessor::FindPlayerInOrOutOfWorld(plguid); + player = ObjectAccessor::FindConnectedPlayer(plguid); if (!player) return; - Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionguid)); + Petition const* petition = sPetitionMgr->GetPetition(petitionguid); if (!petition) return; @@ -645,19 +641,19 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recvData) } } - Signatures const* signatures = sPetitionMgr->GetSignature(GUID_LOPART(petitionguid)); + Signatures const* signatures = sPetitionMgr->GetSignature(petitionguid); uint8 signs = signatures ? signatures->signatureMap.size() : 0; WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + signs + signs * 12)); - data << uint64(petitionguid); // petition guid - data << uint64(_player->GetGUID()); // owner guid - data << uint32(GUID_LOPART(petitionguid)); // guild guid + data << petitionguid; // petition guid + data << _player->GetGUID(); // owner guid + data << uint32(petitionguid.GetCounter()); // guild guid data << uint8(signs); // sign's count if (signs) for (SignatureMap::const_iterator itr = signatures->signatureMap.begin(); itr != signatures->signatureMap.end(); ++itr) { - data << uint64(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); // Player GUID + data << itr->first; // Player GUID data << uint32(0); // there 0 ... } @@ -672,7 +668,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData) // Get petition guid from packet WorldPacket data; - uint64 petitionGuid; + ObjectGuid petitionGuid; recvData >> petitionGuid; @@ -682,22 +678,23 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData) return; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "Petition %u turned in by %u", GUID_LOPART(petitionGuid), _player->GetGUIDLow()); + LOG_DEBUG("network", "Petition %s turned in by %s", petitionGuid.ToString().c_str(), _player->GetGUID().ToString().c_str()); #endif - Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionGuid)); + Petition const* petition = sPetitionMgr->GetPetition(petitionGuid); if (!petition) { - LOG_ERROR("server", "Player %s (guid: %u) tried to turn in petition (guid: %u) that is not present in the database", _player->GetName().c_str(), _player->GetGUIDLow(), GUID_LOPART(petitionGuid)); + LOG_ERROR("server", "Player %s (%s) tried to turn in petition (%s) that is not present in the database", + _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), petitionGuid.ToString().c_str()); return; } - uint32 ownerguidlo = petition->ownerGuid; + ObjectGuid ownerGuid = petition->ownerGuid; uint8 type = petition->petitionType; std::string name = petition->petitionName; // Only the petition owner can turn in the petition - if (_player->GetGUIDLow() != ownerguidlo) + if (_player->GetGUID() != ownerGuid) return; // Petition type (guild/arena) specific checks @@ -742,7 +739,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData) } // Get petition signatures from db - Signatures const* signatures = sPetitionMgr->GetSignature(GUID_LOPART(petitionGuid)); + Signatures const* signatures = sPetitionMgr->GetSignature(petitionGuid); uint8 signs = signatures ? signatures->signatureMap.size() : 0; SignatureMap signatureCopy; if (signs) @@ -787,7 +784,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData) // Add members from signatures if (signs) for (SignatureMap::const_iterator itr = signatureCopy.begin(); itr != signatureCopy.end(); ++itr) - guild->AddMember(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + guild->AddMember(itr->first); } else { @@ -815,30 +812,30 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData) for (SignatureMap::const_iterator itr = signatureCopy.begin(); itr != signatureCopy.end(); ++itr) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "PetitionsHandler: Adding arena team (guid: %u) member %u", arenaTeam->GetId(), itr->first); + LOG_DEBUG("network", "PetitionsHandler: Adding arena team (guid: %u) member %s", arenaTeam->GetId(), itr->first.ToString().c_str()); #endif - arenaTeam->AddMember(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + arenaTeam->AddMember(itr->first); } } SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_BY_GUID); - stmt->setUInt32(0, GUID_LOPART(petitionGuid)); + stmt->setUInt32(0, petitionGuid.GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE_BY_GUID); - stmt->setUInt32(0, GUID_LOPART(petitionGuid)); + stmt->setUInt32(0, petitionGuid.GetCounter()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); // xinef: clear petition store (petition and signatures) - sPetitionMgr->RemovePetition(GUID_LOPART(petitionGuid)); + sPetitionMgr->RemovePetition(petitionGuid); // created #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "TURN IN PETITION GUID %u", GUID_LOPART(petitionGuid)); + LOG_DEBUG("network", "TURN IN PETITION %s", petitionGuid.ToString().c_str()); #endif data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4); @@ -852,19 +849,19 @@ void WorldSession::HandlePetitionShowListOpcode(WorldPacket& recvData) LOG_DEBUG("network", "Received CMSG_PETITION_SHOWLIST"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; SendPetitionShowList(guid); } -void WorldSession::SendPetitionShowList(uint64 guid) +void WorldSession::SendPetitionShowList(ObjectGuid guid) { Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_PETITIONER); if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandlePetitionShowListOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandlePetitionShowListOpcode - Unit (%s) not found or you can't interact with him.", guid.ToString().c_str()); #endif return; } diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index 569894cbd5..72759d3df6 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -19,12 +19,12 @@ #include "WorldPacket.h" #include "WorldSession.h" -void WorldSession::SendNameQueryOpcode(uint64 guid) +void WorldSession::SendNameQueryOpcode(ObjectGuid guid) { - GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid)); + GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid.GetCounter()); WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 1 + 1 + 1 + 1 + 10)); - data.appendPackGUID(guid); + data << guid.WriteAsPacked(); if (!playerData) { data << uint8(1); // name unknown @@ -32,7 +32,7 @@ void WorldSession::SendNameQueryOpcode(uint64 guid) return; } - Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + Player* player = ObjectAccessor::FindConnectedPlayer(guid); data << uint8(0); // name known data << playerData->name; // played name @@ -42,7 +42,7 @@ void WorldSession::SendNameQueryOpcode(uint64 guid) data << uint8(playerData->playerClass); // pussywizard: optimization - /*Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid); + /*Player* player = ObjectAccessor::FindConnectedPlayer(guid); if (DeclinedName const* names = (player ? player->GetDeclinedNames() : nullptr)) { data << uint8(1); // Name is declined @@ -57,7 +57,7 @@ void WorldSession::SendNameQueryOpcode(uint64 guid) void WorldSession::HandleNameQueryOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; // This is disable by default to prevent lots of console spam @@ -84,7 +84,7 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recvData) { uint32 entry; recvData >> entry; - uint64 guid; + ObjectGuid guid; recvData >> guid; CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(entry); @@ -138,7 +138,7 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recvData) else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: CMSG_CREATURE_QUERY - NO CREATURE INFO! (GUID: %u, ENTRY: %u)", GUID_LOPART(guid), entry); + LOG_DEBUG("network", "WORLD: CMSG_CREATURE_QUERY - NO CREATURE INFO! (%s)", guid.ToString().c_str()); #endif WorldPacket data(SMSG_CREATURE_QUERY_RESPONSE, 4); data << uint32(entry | 0x80000000); @@ -154,7 +154,7 @@ void WorldSession::HandleGameObjectQueryOpcode(WorldPacket& recvData) { uint32 entry; recvData >> entry; - uint64 guid; + ObjectGuid guid; recvData >> guid; const GameObjectTemplate* info = sObjectMgr->GetGameObjectTemplate(entry); @@ -207,8 +207,7 @@ void WorldSession::HandleGameObjectQueryOpcode(WorldPacket& recvData) else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: CMSG_GAMEOBJECT_QUERY - Missing gameobject info for (GUID: %u, ENTRY: %u)", - GUID_LOPART(guid), entry); + LOG_DEBUG("network", "WORLD: CMSG_GAMEOBJECT_QUERY - Missing gameobject info for (%s)", guid.ToString().c_str()); #endif WorldPacket data (SMSG_GAMEOBJECT_QUERY_RESPONSE, 4); data << uint32(entry | 0x80000000); @@ -225,9 +224,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket& /*recvData*/) LOG_DEBUG("network", "WORLD: Received MSG_CORPSE_QUERY"); #endif - Corpse* corpse = GetPlayer()->GetCorpse(); - - if (!corpse) + if (!_player->HasCorpse()) { WorldPacket data(MSG_CORPSE_QUERY, 1); data << uint8(0); // corpse not found @@ -235,24 +232,25 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket& /*recvData*/) return; } - uint32 mapid = corpse->GetMapId(); - float x = corpse->GetPositionX(); - float y = corpse->GetPositionY(); - float z = corpse->GetPositionZ(); - uint32 corpsemapid = mapid; + WorldLocation corpseLocation = _player->GetCorpseLocation(); + uint32 corpseMapID = corpseLocation.GetMapId(); + uint32 mapID = corpseLocation.GetMapId(); + float x = corpseLocation.GetPositionX(); + float y = corpseLocation.GetPositionY(); + float z = corpseLocation.GetPositionZ(); // if corpse at different map - if (mapid != _player->GetMapId()) + if (mapID != _player->GetMapId()) { // search entrance map for proper show entrance - if (MapEntry const* corpseMapEntry = sMapStore.LookupEntry(mapid)) + if (MapEntry const* corpseMapEntry = sMapStore.LookupEntry(mapID)) { if (corpseMapEntry->IsDungeon() && corpseMapEntry->entrance_map >= 0) { // if corpse map have entrance if (Map const* entranceMap = sMapMgr->CreateBaseMap(corpseMapEntry->entrance_map)) { - mapid = corpseMapEntry->entrance_map; + mapID = corpseMapEntry->entrance_map; x = corpseMapEntry->entrance_x; y = corpseMapEntry->entrance_y; z = entranceMap->GetHeight(GetPlayer()->GetPhaseMask(), x, y, MAX_HEIGHT); @@ -263,11 +261,11 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket& /*recvData*/) WorldPacket data(MSG_CORPSE_QUERY, 1 + (6 * 4)); data << uint8(1); // corpse found - data << int32(mapid); + data << int32(mapID); data << float(x); data << float(y); data << float(z); - data << int32(corpsemapid); + data << int32(corpseMapID); data << uint32(0); // unknown SendPacket(&data); } @@ -275,7 +273,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket& /*recvData*/) void WorldSession::HandleNpcTextQueryOpcode(WorldPacket& recvData) { uint32 textID; - uint64 guid; + ObjectGuid guid; recvData >> textID; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 20bbc854ac..8125cc7b6c 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -28,7 +28,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; uint32 questStatus = DIALOG_STATUS_NONE; @@ -36,7 +36,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recvData) if (!questGiver) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Error in CMSG_QUESTGIVER_STATUS_QUERY, called for not found questgiver (Typeid: %u GUID: %u)", GuidHigh2TypeId(GUID_HIPART(guid)), GUID_LOPART(guid)); + LOG_DEBUG("server", "Error in CMSG_QUESTGIVER_STATUS_QUERY, called for not found questgiver (%s)", guid.ToString().c_str()); #endif return; } @@ -46,7 +46,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recvData) case TYPEID_UNIT: { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for npc, guid = %u", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for npc %s", guid.ToString().c_str()); #endif if (!questGiver->ToCreature()->IsHostileTo(_player)) // do not show quest status to enemies questStatus = _player->GetQuestDialogStatus(questGiver); @@ -55,7 +55,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recvData) case TYPEID_GAMEOBJECT: { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for GameObject guid = %u", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for GameObject %s", guid.ToString().c_str()); #endif questStatus = _player->GetQuestDialogStatus(questGiver); break; @@ -71,18 +71,18 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recvData) void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_HELLO npc = %u", GUID_LOPART(guid)); + LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_HELLO npc %s", guid.ToString().c_str()); #endif Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!creature) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleQuestgiverHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", GUID_LOPART(guid)); + LOG_DEBUG("network", "WORLD: HandleQuestgiverHelloOpcode - Unit (%s) not found or you can't interact with him.", guid.ToString().c_str()); #endif return; } @@ -110,13 +110,13 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recvData) void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; uint32 questId; uint32 unk1; recvData >> guid >> questId >> unk1; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST npc = %u, quest = %u, unk1 = %u", uint32(GUID_LOPART(guid)), questId, unk1); + LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST npc %s, quest = %u, unk1 = %u", guid.ToString().c_str(), questId, unk1); #endif Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM | TYPEMASK_PLAYER); @@ -126,7 +126,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData) (object->GetTypeId() == TYPEID_PLAYER && !object->ToPlayer()->CanShareQuest(questId))) { _player->PlayerTalkClass->SendCloseGossip(); - _player->SetDivider(0); + _player->SetDivider(); return; } @@ -147,17 +147,17 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData) if (!GetPlayer()->CanTakeQuest(quest, true)) { _player->PlayerTalkClass->SendCloseGossip(); - _player->SetDivider(0); + _player->SetDivider(); return; } - if (_player->GetDivider() != 0) + if (_player->GetDivider()) { Player* player = ObjectAccessor::GetPlayer(*_player, _player->GetDivider()); if (player) { player->SendPushToPartyResponse(_player, QUEST_PARTY_MSG_ACCEPT_QUEST); - _player->SetDivider(0); + _player->SetDivider(); } } @@ -202,12 +202,12 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData) void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; uint32 questId; uint8 unk1; recvData >> guid >> questId >> unk1; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_QUERY_QUEST npc = %u, quest = %u, unk1 = %u", uint32(GUID_LOPART(guid)), questId, unk1); + LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_QUERY_QUEST npc %s, quest = %u, unk1 = %u", guid.ToString().c_str(), questId, unk1); #endif // Verify that the guid is valid and is a questgiver or involved in the requested quest @@ -254,17 +254,18 @@ void WorldSession::HandleQuestQueryOpcode(WorldPacket& recvData) void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData) { uint32 questId, reward; - uint64 guid; + ObjectGuid guid; recvData >> guid >> questId >> reward; if (reward >= QUEST_REWARD_CHOICES_COUNT) { - LOG_ERROR("server", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (guid %d) tried to get invalid reward (%u) (probably packet hacking)", _player->GetName().c_str(), _player->GetGUIDLow(), reward); + LOG_ERROR("server", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (%s) tried to get invalid reward (%u) (probably packet hacking)", + _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), reward); return; } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_CHOOSE_REWARD npc = %u, quest = %u, reward = %u", uint32(GUID_LOPART(guid)), questId, reward); + LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_CHOOSE_REWARD npc %s, quest = %u, reward = %u", guid.ToString().c_str(), questId, reward); #endif Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT); @@ -280,8 +281,8 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData) if ((!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(questId) == QUEST_STATUS_NONE) || (_player->GetQuestStatus(questId) != QUEST_STATUS_COMPLETE && !quest->IsAutoComplete())) { - LOG_ERROR("server", "HACK ALERT: Player %s (guid: %u) is trying to complete quest (id: %u) but he has no right to do it!", - _player->GetName().c_str(), _player->GetGUIDLow(), questId); + LOG_ERROR("server", "HACK ALERT: Player %s (%s) is trying to complete quest (id: %u) but he has no right to do it!", + _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), questId); return; } if (_player->CanRewardQuest(quest, reward, true)) @@ -342,11 +343,11 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData) void WorldSession::HandleQuestgiverRequestRewardOpcode(WorldPacket& recvData) { uint32 questId; - uint64 guid; + ObjectGuid guid; recvData >> guid >> questId; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_REQUEST_REWARD npc = %u, quest = %u", uint32(GUID_LOPART(guid)), questId); + LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_REQUEST_REWARD npc %s, quest = %u", guid.ToString().c_str(), questId); #endif Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT); @@ -427,7 +428,7 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recvData) sEluna->OnQuestAbandon(_player, questId); #endif #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player %u abandoned quest %u", _player->GetGUIDLow(), questId); + LOG_DEBUG("server", "Player %s abandoned quest %u", _player->GetGUID().ToString().c_str(), questId); #endif // check if Quest Tracker is enabled if (sWorld->getBoolConfig(CONFIG_QUEST_ENABLE_QUEST_TRACKER)) @@ -435,7 +436,7 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recvData) // prepare Quest Tracker datas auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_ABANDON_TIME); stmt->setUInt32(0, questId); - stmt->setUInt32(1, _player->GetGUIDLow()); + stmt->setUInt32(1, _player->GetGUID().GetCounter()); // add to Quest Tracker CharacterDatabase.Execute(stmt); @@ -481,19 +482,19 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recvData) if (_player->CanAddQuest(quest, true)) _player->AddQuestAndCheckCompletion(quest, nullptr); // nullptr, this prevent DB script from duplicate running - _player->SetDivider(0); + _player->SetDivider(); } } void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recvData) { uint32 questId; - uint64 guid; + ObjectGuid guid; recvData >> guid >> questId; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_COMPLETE_QUEST npc = %u, quest = %u", uint32(GUID_LOPART(guid)), questId); + LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_COMPLETE_QUEST npc %s, quest = %u", guid.ToString().c_str(), questId); #endif Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT); @@ -508,8 +509,8 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recvData) { if (!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(questId) == QUEST_STATUS_NONE) { - LOG_ERROR("server", "Possible hacking attempt: Player %s [guid: %u] tried to complete quest [entry: %u] without being in possession of the quest!", - _player->GetName().c_str(), _player->GetGUIDLow(), questId); + LOG_ERROR("server", "Possible hacking attempt: Player %s [%s] tried to complete quest [entry: %u] without being in possession of the quest!", + _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), questId); return; } @@ -599,7 +600,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) } } - if (player->GetDivider() != 0) + if (player->GetDivider()) { _player->SendPushToPartyResponse(player, QUEST_PARTY_MSG_BUSY); continue; @@ -624,7 +625,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket) { - uint64 guid; + ObjectGuid guid; uint32 questId; uint8 msg; recvPacket >> guid >> questId >> msg; @@ -638,10 +639,10 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket) if (Player* player = ObjectAccessor::GetPlayer(*_player, _player->GetDivider())) { WorldPacket data(MSG_QUEST_PUSH_RESULT, 8 + 4 + 1); - data << uint64(_player->GetGUID()); + data << _player->GetGUID(); data << uint8(msg); // valid values: 0-8 player->GetSession()->SendPacket(&data); - _player->SetDivider(0); + _player->SetDivider(); } } } @@ -657,11 +658,11 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4); data << uint32(count); // placeholder - for (Player::ClientGUIDs::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr) + for (GuidUnorderedSet::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr) { uint32 questStatus = DIALOG_STATUS_NONE; - if (IS_CRE_OR_VEH_OR_PET_GUID(*itr)) + if ((*itr).IsAnyTypeCreature()) { // need also pet quests case support Creature* questgiver = ObjectAccessor::GetCreatureOrPetOrVehicle(*GetPlayer(), *itr); @@ -672,11 +673,11 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket questStatus = _player->GetQuestDialogStatus(questgiver); - data << uint64(questgiver->GetGUID()); + data << questgiver->GetGUID(); data << uint8(questStatus); ++count; } - else if (IS_GAMEOBJECT_GUID(*itr)) + else if ((*itr).IsGameObject()) { GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr); if (!questgiver || questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER) @@ -684,7 +685,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket questStatus = _player->GetQuestDialogStatus(questgiver); - data << uint64(questgiver->GetGUID()); + data << questgiver->GetGUID(); data << uint8(questStatus); ++count; } diff --git a/src/server/game/Handlers/ReferAFriendHandler.cpp b/src/server/game/Handlers/ReferAFriendHandler.cpp index 927ce9fd2f..dd22c5292e 100644 --- a/src/server/game/Handlers/ReferAFriendHandler.cpp +++ b/src/server/game/Handlers/ReferAFriendHandler.cpp @@ -16,10 +16,10 @@ void WorldSession::HandleGrantLevel(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: CMSG_GRANT_LEVEL"); #endif - uint64 guid; - recvData.readPackGUID(guid); + ObjectGuid guid; + recvData >> guid.ReadAsPacked(); - Player* target = ObjectAccessor::GetObjectInWorld(guid, _player); + Player* target = ObjectAccessor::GetPlayer(*_player, guid); // check cheating uint8 levels = _player->GetGrantableLevels(); @@ -51,7 +51,7 @@ void WorldSession::HandleGrantLevel(WorldPacket& recvData) } WorldPacket data2(SMSG_PROPOSE_LEVEL_GRANT, 8); - data2.append(_player->GetPackGUID()); + data2 << _player->GetPackGUID(); target->GetSession()->SendPacket(&data2); } @@ -61,10 +61,10 @@ void WorldSession::HandleAcceptGrantLevel(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: CMSG_ACCEPT_LEVEL_GRANT"); #endif - uint64 guid; - recvData.readPackGUID(guid); + ObjectGuid guid; + recvData >> guid.ReadAsPacked(); - Player* other = ObjectAccessor::GetObjectInWorld(guid, _player); + Player* other = ObjectAccessor::GetPlayer(*_player, guid); if (!other) return; diff --git a/src/server/game/Handlers/SkillHandler.cpp b/src/server/game/Handlers/SkillHandler.cpp index 00c26c8a0b..774c70872b 100644 --- a/src/server/game/Handlers/SkillHandler.cpp +++ b/src/server/game/Handlers/SkillHandler.cpp @@ -55,14 +55,14 @@ void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "MSG_TALENT_WIPE_CONFIRM"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleTalentWipeConfirmOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleTalentWipeConfirmOpcode - Unit (%s) not found or you can't interact with him.", guid.ToString().c_str()); #endif return; } diff --git a/src/server/game/Handlers/Socialhandler.cpp b/src/server/game/Handlers/Socialhandler.cpp index ac3f5dd92e..07453f6162 100644 --- a/src/server/game/Handlers/Socialhandler.cpp +++ b/src/server/game/Handlers/Socialhandler.cpp @@ -40,15 +40,14 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket& recv_data) LOG_DEBUG("network", "WORLD: %s asked to add friend : '%s'", GetPlayer()->GetName().c_str(), friendName.c_str()); // xinef: Get Data From global storage - uint32 guidLow = sWorld->GetGlobalPlayerGUID(friendName); - if (!guidLow) + ObjectGuid friendGuid = sWorld->GetGlobalPlayerGUID(friendName); + if (!friendGuid) return; - GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guidLow); + GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(friendGuid.GetCounter()); if (!playerData) return; - uint64 friendGuid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER); uint32 friendAccountId = playerData->accountId; TeamId teamId = Player::TeamIdForRace(playerData->race); FriendsResult friendResult = FRIEND_NOT_FOUND; @@ -61,11 +60,11 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket& recv_data) friendResult = FRIEND_SELF; else if (GetPlayer()->GetTeamId() != teamId && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && AccountMgr::IsPlayerAccount(GetSecurity())) friendResult = FRIEND_ENEMY; - else if (GetPlayer()->GetSocial()->HasFriend(guidLow)) + else if (GetPlayer()->GetSocial()->HasFriend(friendGuid)) friendResult = FRIEND_ALREADY; else { - Player* pFriend = ObjectAccessor::FindPlayerInOrOutOfWorld(friendGuid); + Player* pFriend = ObjectAccessor::FindConnectedPlayer(friendGuid); if (pFriend && pFriend->IsVisibleGloballyFor(GetPlayer()) && !AccountMgr::IsGMAccount(pFriend->GetSession()->GetSecurity())) friendResult = FRIEND_ADDED_ONLINE; else @@ -75,23 +74,23 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket& recv_data) else friendResult = FRIEND_LIST_FULL; } - GetPlayer()->GetSocial()->SetFriendNote(guidLow, friendNote); + GetPlayer()->GetSocial()->SetFriendNote(friendGuid, friendNote); } } - sSocialMgr->SendFriendStatus(GetPlayer(), friendResult, guidLow, false); + sSocialMgr->SendFriendStatus(GetPlayer(), friendResult, friendGuid, false); LOG_DEBUG("network", "WORLD: Sent (SMSG_FRIEND_STATUS)"); } void WorldSession::HandleDelFriendOpcode(WorldPacket& recv_data) { - uint64 FriendGUID; + ObjectGuid FriendGUID; recv_data >> FriendGUID; - _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID), SOCIAL_FLAG_FRIEND); + _player->GetSocial()->RemoveFromSocialList(FriendGUID, SOCIAL_FLAG_FRIEND); - sSocialMgr->SendFriendStatus(GetPlayer(), FRIEND_REMOVED, GUID_LOPART(FriendGUID), false); + sSocialMgr->SendFriendStatus(GetPlayer(), FRIEND_REMOVED, FriendGUID, false); LOG_DEBUG("network", "WORLD: Sent motd (SMSG_FRIEND_STATUS)"); } @@ -107,44 +106,43 @@ void WorldSession::HandleAddIgnoreOpcode(WorldPacket& recv_data) LOG_DEBUG("network", "WORLD: %s asked to Ignore: '%s'", GetPlayer()->GetName().c_str(), ignoreName.c_str()); - uint32 lowGuid = sWorld->GetGlobalPlayerGUID(ignoreName); - if (!lowGuid) + ObjectGuid ignoreGuid = sWorld->GetGlobalPlayerGUID(ignoreName); + if (!ignoreGuid) return; - uint64 IgnoreGuid = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER); FriendsResult ignoreResult; - if (IgnoreGuid == GetPlayer()->GetGUID()) //not add yourself + if (ignoreGuid == GetPlayer()->GetGUID()) //not add yourself ignoreResult = FRIEND_IGNORE_SELF; - else if (GetPlayer()->GetSocial()->HasIgnore(lowGuid)) + else if (GetPlayer()->GetSocial()->HasIgnore(ignoreGuid)) ignoreResult = FRIEND_IGNORE_ALREADY; else { ignoreResult = FRIEND_IGNORE_ADDED; // ignore list full - if (!GetPlayer()->GetSocial()->AddToSocialList(lowGuid, SOCIAL_FLAG_IGNORED)) + if (!GetPlayer()->GetSocial()->AddToSocialList(ignoreGuid, SOCIAL_FLAG_IGNORED)) ignoreResult = FRIEND_IGNORE_FULL; } - sSocialMgr->SendFriendStatus(GetPlayer(), ignoreResult, lowGuid, false); + sSocialMgr->SendFriendStatus(GetPlayer(), ignoreResult, ignoreGuid, false); LOG_DEBUG("network", "WORLD: Sent (SMSG_FRIEND_STATUS)"); } void WorldSession::HandleDelIgnoreOpcode(WorldPacket& recv_data) { - uint64 IgnoreGUID; + ObjectGuid IgnoreGUID; recv_data >> IgnoreGUID; - _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID), SOCIAL_FLAG_IGNORED); - sSocialMgr->SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, GUID_LOPART(IgnoreGUID), false); + _player->GetSocial()->RemoveFromSocialList(IgnoreGUID, SOCIAL_FLAG_IGNORED); + sSocialMgr->SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, IgnoreGUID, false); } void WorldSession::HandleSetContactNotesOpcode(WorldPacket& recv_data) { - uint64 guid; + ObjectGuid guid; std::string note; recv_data >> guid >> note; - _player->GetSocial()->SetFriendNote(GUID_LOPART(guid), note); + _player->GetSocial()->SetFriendNote(guid, note); } diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index 435e6e5237..a860597608 100644 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -62,7 +62,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) uint8 bagIndex, slot, castFlags; uint8 castCount; // next cast if exists (single or not) - uint64 itemGUID; + ObjectGuid itemGUID; uint32 glyphIndex; // something to do with glyphs? uint32 spellId; // casted spell id @@ -208,8 +208,8 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) if (!(proto->Flags & ITEM_FLAG_HAS_LOOT) && !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED)) { pUser->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, nullptr); - LOG_ERROR("server", "Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!", - pUser->GetName().c_str(), pUser->GetGUIDLow(), item->GetGUIDLow(), proto->ItemId); + LOG_ERROR("server", "Possible hacking attempt: Player %s [%s] tried to open item [%s, entry: %u] which is not openable!", + pUser->GetName().c_str(), pUser->GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), proto->ItemId); return; } @@ -222,7 +222,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) if (!lockInfo) { pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, nullptr); - LOG_ERROR("server", "WORLD::OpenItem: item [guid = %u] has an unknown lockId: %u!", item->GetGUIDLow(), lockId); + LOG_ERROR("server", "WORLD::OpenItem: item [%s] has an unknown lockId: %u!", item->GetGUID().ToString().c_str(), lockId); return; } @@ -238,18 +238,18 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM); - stmt->setUInt32(0, item->GetGUIDLow()); + stmt->setUInt32(0, item->GetGUID().GetCounter()); _openWrappedItemCallback.SetFirstParam(bagIndex); _openWrappedItemCallback.SetSecondParam(slot); - _openWrappedItemCallback.SetThirdParam(item->GetGUIDLow()); + _openWrappedItemCallback.SetThirdParam(item->GetGUID().GetCounter()); _openWrappedItemCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt)); } else pUser->SendLoot(item->GetGUID(), LOOT_CORPSE); } -void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uint8 bagIndex, uint8 slot, uint32 itemLowGUID) +void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uint8 bagIndex, uint8 slot, ObjectGuid::LowType itemLowGUID) { if (!GetPlayer()) return; @@ -258,12 +258,12 @@ void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uin if (!item) return; - if (item->GetGUIDLow() != itemLowGUID || !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED)) // during getting result, gift was swapped with another item + if (item->GetGUID().GetCounter() != itemLowGUID || !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED)) // during getting result, gift was swapped with another item return; if (!result) { - LOG_ERROR("server", "Wrapped item %u don't have record in character_gifts table and will deleted", item->GetGUIDLow()); + LOG_ERROR("server", "Wrapped item %s don't have record in character_gifts table and will deleted", item->GetGUID().ToString().c_str()); GetPlayer()->DestroyItem(item->GetBagSlot(), item->GetSlot(), true); return; } @@ -274,7 +274,7 @@ void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uin uint32 entry = fields[0].GetUInt32(); uint32 flags = fields[1].GetUInt32(); - item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0); + item->SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Empty); item->SetEntry(entry); item->SetUInt32Value(ITEM_FIELD_FLAGS, flags); item->SetUInt32Value(ITEM_FIELD_MAXDURABILITY, item->GetTemplate()->MaxDurability); @@ -283,7 +283,7 @@ void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uin GetPlayer()->SaveInventoryAndGoldToDB(trans); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT); - stmt->setUInt32(0, item->GetGUIDLow()); + stmt->setUInt32(0, item->GetGUID().GetCounter()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); @@ -291,11 +291,11 @@ void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uin void WorldSession::HandleGameObjectUseOpcode(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Recvd CMSG_GAMEOBJ_USE Message [guid=%u]", GUID_LOPART(guid)); + LOG_DEBUG("network", "WORLD: Recvd CMSG_GAMEOBJ_USE Message [%s]", guid.ToString().c_str()); #endif if (GameObject* obj = GetPlayer()->GetMap()->GetGameObject(guid)) @@ -314,11 +314,11 @@ void WorldSession::HandleGameObjectUseOpcode(WorldPacket& recvData) void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket) { - uint64 guid; + ObjectGuid guid; recvPacket >> guid; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Recvd CMSG_GAMEOBJ_REPORT_USE Message [in game guid: %u]", GUID_LOPART(guid)); + LOG_DEBUG("network", "WORLD: Recvd CMSG_GAMEOBJ_REPORT_USE Message [%s]", guid.ToString().c_str()); #endif // ignore for remote control state @@ -450,7 +450,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) spellInfo = actualSpellInfo; } - Spell* spell = new Spell(mover, spellInfo, TRIGGERED_NONE, 0, false); + Spell* spell = new Spell(mover, spellInfo, TRIGGERED_NONE, ObjectGuid::Empty, false); sScriptMgr->ValidateSpellAtCastSpellResult(_player, mover, spell, oldSpellId, spellId); @@ -493,12 +493,12 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) } // maybe should only remove one buff when there are multiple? - _player->RemoveOwnedAura(spellId, 0, 0, AURA_REMOVE_BY_CANCEL); + _player->RemoveOwnedAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL); } void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket) { - uint64 guid; + ObjectGuid guid; uint32 spellId; recvPacket >> guid; @@ -515,13 +515,13 @@ void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket) if (!pet) { - LOG_ERROR("server", "HandlePetCancelAura: Attempt to cancel an aura for non-existant pet %u by player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); + LOG_ERROR("server", "HandlePetCancelAura: Attempt to cancel an aura for non-existant pet %s by player %s", guid.ToString().c_str(), GetPlayer()->GetName().c_str()); return; } if (pet != GetPlayer()->GetGuardianPet() && pet != GetPlayer()->GetCharm()) { - LOG_ERROR("server", "HandlePetCancelAura: Pet %u is not a pet of player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); + LOG_ERROR("server", "HandlePetCancelAura: Pet %s is not a pet of player %s", guid.ToString().c_str(), GetPlayer()->GetName().c_str()); return; } @@ -531,7 +531,7 @@ void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket) return; } - pet->RemoveOwnedAura(spellId, 0, 0, AURA_REMOVE_BY_CANCEL); + pet->RemoveOwnedAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL); pet->AddSpellCooldown(spellId, 0, 0); } @@ -606,7 +606,7 @@ void WorldSession::HandleSelfResOpcode(WorldPacket& /*recvData*/) void WorldSession::HandleSpellClick(WorldPacket& recvData) { - uint64 guid; + ObjectGuid guid; recvData >> guid; // this will get something not in world. crash @@ -627,11 +627,11 @@ void WorldSession::HandleMirrorImageDataRequest(WorldPacket& recvData) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("network", "WORLD: CMSG_GET_MIRRORIMAGE_DATA"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; // Get unit for which data is needed by client - Unit* unit = ObjectAccessor::GetObjectInWorld(guid, (Unit*)nullptr); + Unit* unit = ObjectAccessor::GetUnit(*_player, guid); if (!unit) return; @@ -644,7 +644,7 @@ void WorldSession::HandleMirrorImageDataRequest(WorldPacket& recvData) return; WorldPacket data(SMSG_MIRRORIMAGE_DATA, 68); - data << uint64(guid); + data << guid; data << uint32(creator->GetDisplayId()); data << uint8(creator->getRace()); data << uint8(creator->getGender()); @@ -723,7 +723,7 @@ void WorldSession::HandleUpdateProjectilePosition(WorldPacket& recvPacket) LOG_DEBUG("network", "WORLD: CMSG_UPDATE_PROJECTILE_POSITION"); #endif - uint64 casterGuid; + ObjectGuid casterGuid; uint32 spellId; uint8 castCount; float x, y, z; // Position of missile hit @@ -748,7 +748,7 @@ void WorldSession::HandleUpdateProjectilePosition(WorldPacket& recvPacket) spell->m_targets.ModDst(pos); WorldPacket data(SMSG_SET_PROJECTILE_POSITION, 21); - data << uint64(casterGuid); + data << casterGuid; data << uint8(castCount); data << float(x); data << float(y); diff --git a/src/server/game/Handlers/TaxiHandler.cpp b/src/server/game/Handlers/TaxiHandler.cpp index c72f8b2878..73fdfc18b1 100644 --- a/src/server/game/Handlers/TaxiHandler.cpp +++ b/src/server/game/Handlers/TaxiHandler.cpp @@ -21,20 +21,20 @@ void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_TAXINODE_STATUS_QUERY"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; SendTaxiStatus(guid); } -void WorldSession::SendTaxiStatus(uint64 guid) +void WorldSession::SendTaxiStatus(ObjectGuid guid) { // cheating checks Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WorldSession::SendTaxiStatus - Unit (GUID: %u) not found.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WorldSession::SendTaxiStatus - Unit (%s) not found.", guid.ToString().c_str()); #endif return; } @@ -64,7 +64,7 @@ void WorldSession::HandleTaxiQueryAvailableNodes(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_TAXIQUERYAVAILABLENODES"); #endif - uint64 guid; + ObjectGuid guid; recvData >> guid; // cheating checks @@ -72,7 +72,7 @@ void WorldSession::HandleTaxiQueryAvailableNodes(WorldPacket& recvData) if (!unit) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleTaxiQueryAvailableNodes - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleTaxiQueryAvailableNodes - Unit (%s) not found or you can't interact with him.", guid.ToString().c_str()); #endif return; } @@ -106,7 +106,7 @@ void WorldSession::SendTaxiMenu(Creature* unit) WorldPacket data(SMSG_SHOWTAXINODES, (4 + 8 + 4 + 8 * 4)); data << uint32(1); - data << uint64(unit->GetGUID()); + data << unit->GetGUID(); data << uint32(curloc); GetPlayer()->m_taxi.AppendTaximaskTo(data, GetPlayer()->isTaxiCheater()); SendPacket(&data); @@ -147,7 +147,7 @@ bool WorldSession::SendLearnNewTaxiNode(Creature* unit) SendPacket(&msg); WorldPacket update(SMSG_TAXINODE_STATUS, 9); - update << uint64(unit->GetGUID()); + update << unit->GetGUID(); update << uint8(1); SendPacket(&update); @@ -172,7 +172,7 @@ void WorldSession::HandleActivateTaxiExpressOpcode (WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_ACTIVATETAXIEXPRESS"); #endif - uint64 guid; + ObjectGuid guid; uint32 node_count; recvData >> guid >> node_count; @@ -181,7 +181,7 @@ void WorldSession::HandleActivateTaxiExpressOpcode (WorldPacket& recvData) if (!npc) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleActivateTaxiExpressOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleActivateTaxiExpressOpcode - Unit (%s) not found or you can't interact with it.", guid.ToString().c_str()); #endif return; } @@ -218,8 +218,8 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_MOVE_SPLINE_DONE"); #endif - uint64 guid; // used only for proper packet read - recvData.readPackGUID(guid); + ObjectGuid guid; // used only for proper packet read + recvData >> guid.ReadAsPacked(); MovementInfo movementInfo; // used only for proper packet read movementInfo.guid = guid; @@ -234,7 +234,7 @@ void WorldSession::HandleActivateTaxiOpcode(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Received CMSG_ACTIVATETAXI"); #endif - uint64 guid; + ObjectGuid guid; std::vector<uint32> nodes; nodes.resize(2); @@ -246,7 +246,7 @@ void WorldSession::HandleActivateTaxiOpcode(WorldPacket& recvData) if (!npc) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: HandleActivateTaxiOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid))); + LOG_DEBUG("network", "WORLD: HandleActivateTaxiOpcode - Unit (%s) not found or you can't interact with it.", guid.ToString().c_str()); #endif return; } diff --git a/src/server/game/Handlers/TicketHandler.cpp b/src/server/game/Handlers/TicketHandler.cpp index d045ee68c8..2e40057708 100644 --- a/src/server/game/Handlers/TicketHandler.cpp +++ b/src/server/game/Handlers/TicketHandler.cpp @@ -33,7 +33,7 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) GmTicket* ticket = sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID()); if (ticket && ticket->IsCompleted()) - sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID());; + sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID()); // Player must not have ticket if (!ticket || ticket->IsClosed()) @@ -207,7 +207,7 @@ void WorldSession::HandleGMSurveySubmit(WorldPacket& recv_data) recv_data >> comment; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GM_SURVEY); - stmt->setUInt32(0, GUID_LOPART(GetPlayer()->GetGUID())); + stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter()); stmt->setUInt32(1, nextSurveyID); stmt->setUInt32(2, mainSurvey); stmt->setString(3, comment); @@ -230,7 +230,7 @@ void WorldSession::HandleReportLag(WorldPacket& recv_data) recv_data >> z; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_LAG_REPORT); - stmt->setUInt32(0, GUID_LOPART(GetPlayer()->GetGUID())); + stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter()); stmt->setUInt8 (1, lagType); stmt->setUInt16(2, mapId); stmt->setFloat (3, x); diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp index 9756e67394..33e072a109 100644 --- a/src/server/game/Handlers/TradeHandler.cpp +++ b/src/server/game/Handlers/TradeHandler.cpp @@ -60,7 +60,7 @@ void WorldSession::SendTradeStatus(TradeStatus status) void WorldSession::HandleIgnoreTradeOpcode(WorldPacket& /*recvPacket*/) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Ignore Trade %u", _player->GetGUIDLow()); + LOG_DEBUG("network", "WORLD: Ignore Trade %s", _player->GetGUID().ToString().c_str()); #endif // recvPacket.print_storage(); } @@ -68,7 +68,7 @@ void WorldSession::HandleIgnoreTradeOpcode(WorldPacket& /*recvPacket*/) void WorldSession::HandleBusyTradeOpcode(WorldPacket& /*recvPacket*/) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "WORLD: Busy Trade %u", _player->GetGUIDLow()); + LOG_DEBUG("network", "WORLD: Busy Trade %s", _player->GetGUID().ToString().c_str()); #endif // recvPacket.print_storage(); } @@ -96,13 +96,13 @@ void WorldSession::SendUpdateTrade(bool trader_data /*= true*/) data << uint32(item->GetCount()); // stack count // wrapped: hide stats but show giftcreator name data << uint32(item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED) ? 1 : 0); - data << uint64(item->GetUInt64Value(ITEM_FIELD_GIFTCREATOR)); + data << item->GetGuidValue(ITEM_FIELD_GIFTCREATOR); // perm. enchantment and gems data << uint32(item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT)); for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot) data << uint32(item->GetEnchantmentId(EnchantmentSlot(enchant_slot))); // creator - data << uint64(item->GetUInt64Value(ITEM_FIELD_CREATOR)); + data << item->GetGuidValue(ITEM_FIELD_CREATOR); data << uint32(item->GetSpellCharges()); // charges data << uint32(item->GetItemSuffixFactor()); // SuffixFactor data << uint32(item->GetItemRandomPropertyId());// random properties id @@ -145,7 +145,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) { // logging #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "partner storing: %u", myItems[i]->GetGUIDLow()); + LOG_DEBUG("network", "partner storing: %s", myItems[i]->GetGUID().ToString().c_str()); #endif // adjust time (depends on /played) @@ -158,7 +158,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) { // logging #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("network", "player storing: %u", hisItems[i]->GetGUIDLow()); + LOG_DEBUG("network", "player storing: %s", hisItems[i]->GetGUID().ToString().c_str()); #endif // adjust time (depends on /played) @@ -175,21 +175,21 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) if (myItems[i]) { if (!traderCanTrade) - LOG_ERROR("server", "trader can't store item: %u", myItems[i]->GetGUIDLow()); + LOG_ERROR("server", "trader can't store item: %s", myItems[i]->GetGUID().ToString().c_str()); if (_player->CanStoreItem(NULL_BAG, NULL_SLOT, playerDst, myItems[i], false) == EQUIP_ERR_OK) _player->MoveItemToInventory(playerDst, myItems[i], true, true); else - LOG_ERROR("server", "player can't take item back: %u", myItems[i]->GetGUIDLow()); + LOG_ERROR("server", "player can't take item back: %s", myItems[i]->GetGUID().ToString().c_str()); } // return the already removed items to the original owner if (hisItems[i]) { if (!playerCanTrade) - LOG_ERROR("server", "player can't store item: %u", hisItems[i]->GetGUIDLow()); + LOG_ERROR("server", "player can't store item: %s", hisItems[i]->GetGUID().ToString().c_str()); if (trader->CanStoreItem(NULL_BAG, NULL_SLOT, traderDst, hisItems[i], false) == EQUIP_ERR_OK) trader->MoveItemToInventory(traderDst, hisItems[i], true, true); else - LOG_ERROR("server", "trader can't take item back: %u", hisItems[i]->GetGUIDLow()); + LOG_ERROR("server", "trader can't take item back: %s", hisItems[i]->GetGUID().ToString().c_str()); } } } @@ -208,7 +208,7 @@ static void setAcceptTradeMode(TradeData* myTrade, TradeData* hisTrade, Item * * if (Item* item = myTrade->GetItem(TradeSlots(i))) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "player trade item %u bag: %u slot: %u", item->GetGUIDLow(), item->GetBagSlot(), item->GetSlot()); + LOG_DEBUG("server", "player trade item %s bag: %u slot: %u", item->GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot()); #endif //Can return nullptr myItems[i] = item; @@ -218,7 +218,7 @@ static void setAcceptTradeMode(TradeData* myTrade, TradeData* hisTrade, Item * * if (Item* item = hisTrade->GetItem(TradeSlots(i))) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "partner trade item %u bag: %u slot: %u", item->GetGUIDLow(), item->GetBagSlot(), item->GetSlot()); + LOG_DEBUG("server", "partner trade item %s bag: %u slot: %u", item->GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot()); #endif hisItems[i] = item; hisItems[i]->SetInTrade(); @@ -450,12 +450,12 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) { if (myItems[i]) { - myItems[i]->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, _player->GetGUID()); + myItems[i]->SetGuidValue(ITEM_FIELD_GIFTCREATOR, _player->GetGUID()); _player->MoveItemFromInventory(myItems[i]->GetBagSlot(), myItems[i]->GetSlot(), true); } if (hisItems[i]) { - hisItems[i]->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, trader->GetGUID()); + hisItems[i]->SetGuidValue(ITEM_FIELD_GIFTCREATOR, trader->GetGUID()); trader->MoveItemFromInventory(hisItems[i]->GetBagSlot(), hisItems[i]->GetSlot(), true); } } @@ -465,11 +465,13 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) if( my_trade->GetMoney() >= 10 * GOLD ) { - CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<TRADE>\", NOW())", GetAccountId(), _player->GetGUIDLow(), _player->GetName().c_str(), GetRemoteAddress().c_str(), trader->GetSession()->GetAccountId(), trader->GetName().c_str(), my_trade->GetMoney()); + CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<TRADE>\", NOW())", + GetAccountId(), _player->GetGUID().GetCounter(), _player->GetName().c_str(), GetRemoteAddress().c_str(), trader->GetSession()->GetAccountId(), trader->GetName().c_str(), my_trade->GetMoney()); } if( his_trade->GetMoney() >= 10 * GOLD ) { - CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<TRADE>\", NOW())", trader->GetSession()->GetAccountId(), trader->GetGUIDLow(), trader->GetName().c_str(), trader->GetSession()->GetRemoteAddress().c_str(), GetAccountId(), _player->GetName().c_str(), his_trade->GetMoney()); + CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<TRADE>\", NOW())", + trader->GetSession()->GetAccountId(), trader->GetGUID().GetCounter(), trader->GetName().c_str(), trader->GetSession()->GetRemoteAddress().c_str(), GetAccountId(), _player->GetName().c_str(), his_trade->GetMoney()); } // update money @@ -540,7 +542,7 @@ void WorldSession::HandleCancelTradeOpcode(WorldPacket& /*recvPacket*/) void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) { - uint64 ID; + ObjectGuid ID; recvPacket >> ID; if (GetPlayer()->m_trade) @@ -617,7 +619,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) return; } - if (pOther->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow())) + if (pOther->GetSocial()->HasIgnore(GetPlayer()->GetGUID())) { SendTradeStatus(TRADE_STATUS_IGNORE_YOU); return; @@ -650,7 +652,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) WorldPacket data(SMSG_TRADE_STATUS, 12); data << uint32(TRADE_STATUS_BEGIN_TRADE); - data << uint64(_player->GetGUID()); + data << _player->GetGUID(); pOther->GetSession()->SendPacket(&data); } @@ -696,7 +698,7 @@ void WorldSession::HandleSetTradeItemOpcode(WorldPacket& recvPacket) return; } - uint64 iGUID = item->GetGUID(); + ObjectGuid iGUID = item->GetGUID(); // prevent place single item into many trade slots using cheating and client bugs if (my_trade->HasItem(iGUID)) diff --git a/src/server/game/Handlers/VehicleHandler.cpp b/src/server/game/Handlers/VehicleHandler.cpp index f25e2ab300..334dd25452 100644 --- a/src/server/game/Handlers/VehicleHandler.cpp +++ b/src/server/game/Handlers/VehicleHandler.cpp @@ -18,7 +18,7 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket& recvData) LOG_DEBUG("network", "WORLD: Recvd CMSG_DISMISS_CONTROLLED_VEHICLE"); #endif - uint64 vehicleGUID = _player->GetCharmGUID(); + ObjectGuid vehicleGUID = _player->GetCharmGUID(); if (!vehicleGUID) // something wrong here... { @@ -26,9 +26,8 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket& recvData) return; } - uint64 guid; - - recvData.readPackGUID(guid); + ObjectGuid guid; + recvData >> guid.ReadAsPacked(); // pussywizard: typical check for incomming movement packets if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || guid != _player->m_mover->GetGUID()) @@ -64,8 +63,8 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket& recvData) if (!seat->CanSwitchFromSeat()) { recvData.rfinish(); // prevent warnings spam - LOG_ERROR("server", "HandleChangeSeatsOnControlledVehicle, Opcode: %u, Player %u tried to switch seats but current seatflags %u don't permit that.", - recvData.GetOpcode(), GetPlayer()->GetGUIDLow(), seat->m_flags); + LOG_ERROR("server", "HandleChangeSeatsOnControlledVehicle, Opcode: %u, Player %s tried to switch seats but current seatflags %u don't permit that.", + recvData.GetOpcode(), GetPlayer()->GetGUID().ToString().c_str(), seat->m_flags); return; } @@ -79,8 +78,8 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket& recvData) break; case CMSG_CHANGE_SEATS_ON_CONTROLLED_VEHICLE: { - uint64 guid; // current vehicle guid - recvData.readPackGUID(guid); + ObjectGuid guid; // current vehicle guid + recvData >> guid.ReadAsPacked(); // pussywizard: if (vehicle_base->GetGUID() != guid) @@ -94,8 +93,8 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket& recvData) ReadMovementInfo(recvData, &movementInfo); vehicle_base->m_movementInfo = movementInfo; - uint64 accessory; // accessory guid - recvData.readPackGUID(accessory); + ObjectGuid accessory; // accessory guid + recvData >> accessory.ReadAsPacked(); int8 seatId; recvData >> seatId; @@ -112,8 +111,8 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket& recvData) } case CMSG_REQUEST_VEHICLE_SWITCH_SEAT: { - uint64 guid; // current vehicle guid - recvData.readPackGUID(guid); + ObjectGuid guid; // current vehicle guid + recvData >> guid.ReadAsPacked(); int8 seatId; recvData >> seatId; @@ -134,7 +133,7 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket& recvData) void WorldSession::HandleEnterPlayerVehicle(WorldPacket& data) { // Read guid - uint64 guid; + ObjectGuid guid; data >> guid; if (Player* player = ObjectAccessor::GetPlayer(*_player, guid)) @@ -159,25 +158,25 @@ void WorldSession::HandleEjectPassenger(WorldPacket& data) if (!vehicle) { data.rfinish(); // prevent warnings spam - LOG_ERROR("server", "HandleEjectPassenger: Player %u is not in a vehicle!", GetPlayer()->GetGUIDLow()); + LOG_ERROR("server", "HandleEjectPassenger: Player %s is not in a vehicle!", GetPlayer()->GetGUID().ToString().c_str()); return; } - uint64 guid; + ObjectGuid guid; data >> guid; - if (IS_PLAYER_GUID(guid)) + if (guid.IsPlayer()) { Player* player = ObjectAccessor::GetPlayer(*_player, guid); if (!player) { - LOG_ERROR("server", "Player %u tried to eject player %u from vehicle, but the latter was not found in world!", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid)); + LOG_ERROR("server", "Player %s tried to eject player %s from vehicle, but the latter was not found in world!", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str()); return; } if (!player->IsOnVehicle(vehicle->GetBase())) { - LOG_ERROR("server", "Player %u tried to eject player %u, but they are not in the same vehicle", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid)); + LOG_ERROR("server", "Player %s tried to eject player %s, but they are not in the same vehicle", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str()); return; } @@ -186,21 +185,20 @@ void WorldSession::HandleEjectPassenger(WorldPacket& data) if (seat->IsEjectable()) player->ExitVehicle(); else - LOG_ERROR("server", "Player %u attempted to eject player %u from non-ejectable seat.", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid)); + LOG_ERROR("server", "Player %s attempted to eject player %s from non-ejectable seat.", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str()); } - - else if (IS_CREATURE_GUID(guid)) + else if (guid.IsCreature()) { Unit* unit = ObjectAccessor::GetUnit(*_player, guid); if (!unit) // creatures can be ejected too from player mounts { - LOG_ERROR("server", "Player %u tried to eject creature guid %u from vehicle, but the latter was not found in world!", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid)); + LOG_ERROR("server", "Player %s tried to eject creature guid %s from vehicle, but the latter was not found in world!", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str()); return; } if (!unit->IsOnVehicle(vehicle->GetBase())) { - LOG_ERROR("server", "Player %u tried to eject unit %u, but they are not in the same vehicle", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid)); + LOG_ERROR("server", "Player %s tried to eject unit %s, but they are not in the same vehicle", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str()); return; } @@ -212,10 +210,10 @@ void WorldSession::HandleEjectPassenger(WorldPacket& data) unit->ExitVehicle(); } else - LOG_ERROR("server", "Player %u attempted to eject creature GUID %u from non-ejectable seat.", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid)); + LOG_ERROR("server", "Player %s attempted to eject creature %s from non-ejectable seat.", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str()); } else - LOG_ERROR("server", "HandleEjectPassenger: Player %u tried to eject invalid GUID " UI64FMTD, GetPlayer()->GetGUIDLow(), guid); + LOG_ERROR("server", "HandleEjectPassenger: Player %s tried to eject invalid %s", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str()); } void WorldSession::HandleRequestVehicleExit(WorldPacket& /*recvData*/) @@ -231,8 +229,8 @@ void WorldSession::HandleRequestVehicleExit(WorldPacket& /*recvData*/) if (seat->CanEnterOrExit()) GetPlayer()->ExitVehicle(); else - LOG_ERROR("server", "Player %u tried to exit vehicle, but seatflags %u (ID: %u) don't permit that.", - GetPlayer()->GetGUIDLow(), seat->m_ID, seat->m_flags); + LOG_ERROR("server", "Player %s tried to exit vehicle, but seatflags %u (ID: %u) don't permit that.", + GetPlayer()->GetGUID().ToString().c_str(), seat->m_ID, seat->m_flags); } } } diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index 1a49d4530c..d046d609a7 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -197,16 +197,16 @@ MapEntry const* InstanceSave::GetMapEntry() return sMapStore.LookupEntry(m_mapid); } -void InstanceSave::AddPlayer(uint32 guidLow) +void InstanceSave::AddPlayer(ObjectGuid guid) { std::lock_guard<std::mutex> guard(_lock); - m_playerList.push_back(guidLow); + m_playerList.push_back(guid); } -bool InstanceSave::RemovePlayer(uint32 guidLow, InstanceSaveManager* ism) +bool InstanceSave::RemovePlayer(ObjectGuid guid, InstanceSaveManager* ism) { std::lock_guard<std::mutex> guard(_lock); - m_playerList.remove(guidLow); + m_playerList.remove(guid); // ism passed as an argument to avoid calling via singleton (might result in a deadlock) return ism->DeleteInstanceSaveIfNeeded(this->GetInstanceId(), false); @@ -365,7 +365,7 @@ void InstanceSaveManager::LoadCharacterBinds() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()); uint32 instanceId = fields[1].GetUInt32(); bool perm = fields[2].GetBool(); bool extended = fields[3].GetBool(); @@ -379,7 +379,7 @@ void InstanceSaveManager::LoadCharacterBinds() if (bind.perm) // already loaded perm -> delete currently checked one from db { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_GUID); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt32(1, instanceId); CharacterDatabase.Execute(stmt); continue; @@ -387,7 +387,7 @@ void InstanceSaveManager::LoadCharacterBinds() else // override temp bind by newest one { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_GUID); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt32(1, bind.save->GetInstanceId()); CharacterDatabase.Execute(stmt); bind.save->RemovePlayer(guid, this); @@ -460,11 +460,11 @@ void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator& itr) { lock_instLists = true; - InstanceSave::PlayerListType& pList = itr->second->m_playerList; - for (InstanceSave::PlayerListType::iterator iter = pList.begin(), iter2; iter != pList.end(); ) + GuidList& pList = itr->second->m_playerList; + for (GuidList::iterator iter = pList.begin(), iter2; iter != pList.end(); ) { iter2 = iter++; - PlayerUnbindInstanceNotExtended(*iter2, itr->second->GetMapId(), itr->second->GetDifficulty(), ObjectAccessor::GetObjectInOrOutOfWorld(MAKE_NEW_GUID(*iter2, 0, HIGHGUID_PLAYER), (Player*)nullptr)); + PlayerUnbindInstanceNotExtended(*iter2, itr->second->GetMapId(), itr->second->GetDifficulty(), ObjectAccessor::FindConnectedPlayer(*iter2)); } // delete stuff if no players left (noone extended id) @@ -581,9 +581,9 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b } } -InstancePlayerBind* InstanceSaveManager::PlayerBindToInstance(uint32 guidLow, InstanceSave* save, bool permanent, Player* player /*= nullptr*/) +InstancePlayerBind* InstanceSaveManager::PlayerBindToInstance(ObjectGuid guid, InstanceSave* save, bool permanent, Player* player /*= nullptr*/) { - InstancePlayerBind& bind = playerBindStorage[guidLow]->m[save->GetDifficulty()][save->GetMapId()]; + InstancePlayerBind& bind = playerBindStorage[guid]->m[save->GetDifficulty()][save->GetMapId()]; ASSERT(!bind.perm || permanent); // ensure there's no changing permanent to temporary, this can be done only by unbinding if (bind.save) @@ -595,7 +595,7 @@ InstancePlayerBind* InstanceSaveManager::PlayerBindToInstance(uint32 guidLow, In PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INSTANCE); stmt->setUInt32(0, save->GetInstanceId()); stmt->setBool(1, permanent); - stmt->setUInt32(2, guidLow); + stmt->setUInt32(2, guid.GetCounter()); stmt->setUInt32(3, bind.save->GetInstanceId()); CharacterDatabase.Execute(stmt); } @@ -621,7 +621,7 @@ InstancePlayerBind* InstanceSaveManager::PlayerBindToInstance(uint32 guidLow, In CharacterDatabase.CommitTransaction(trans);*/ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_INSTANCE); - stmt->setUInt32(0, guidLow); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt32(1, save->GetInstanceId()); stmt->setBool(2, permanent); CharacterDatabase.Execute(stmt); @@ -630,8 +630,8 @@ InstancePlayerBind* InstanceSaveManager::PlayerBindToInstance(uint32 guidLow, In if (bind.save != save) { if (bind.save) - bind.save->RemovePlayer(guidLow, this); - save->AddPlayer(guidLow); + bind.save->RemovePlayer(guid, this); + save->AddPlayer(guid); } if (permanent) @@ -650,16 +650,16 @@ InstancePlayerBind* InstanceSaveManager::PlayerBindToInstance(uint32 guidLow, In return &bind; } -void InstanceSaveManager::PlayerUnbindInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty, bool deleteFromDB, Player* player /*= nullptr*/) +void InstanceSaveManager::PlayerUnbindInstance(ObjectGuid guid, uint32 mapid, Difficulty difficulty, bool deleteFromDB, Player* player /*= nullptr*/) { - BoundInstancesMapWrapper* w = playerBindStorage[guidLow]; + BoundInstancesMapWrapper* w = playerBindStorage[guid]; BoundInstancesMap::iterator itr = w->m[difficulty].find(mapid); if (itr != w->m[difficulty].end()) { if (deleteFromDB) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_GUID); - stmt->setUInt32(0, guidLow); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt32(1, itr->second.save->GetInstanceId()); CharacterDatabase.Execute(stmt); } @@ -669,13 +669,13 @@ void InstanceSaveManager::PlayerUnbindInstance(uint32 guidLow, uint32 mapid, Dif InstanceSave* tmp = itr->second.save; w->m[difficulty].erase(itr); - tmp->RemovePlayer(guidLow, this); + tmp->RemovePlayer(guid, this); } } -void InstanceSaveManager::PlayerUnbindInstanceNotExtended(uint32 guidLow, uint32 mapid, Difficulty difficulty, Player* player /*= nullptr*/) +void InstanceSaveManager::PlayerUnbindInstanceNotExtended(ObjectGuid guid, uint32 mapid, Difficulty difficulty, Player* player /*= nullptr*/) { - BoundInstancesMapWrapper* w = playerBindStorage[guidLow]; + BoundInstancesMapWrapper* w = playerBindStorage[guid]; BoundInstancesMap::iterator itr = w->m[difficulty].find(mapid); if (itr != w->m[difficulty].end()) { @@ -688,12 +688,12 @@ void InstanceSaveManager::PlayerUnbindInstanceNotExtended(uint32 guidLow, uint32 InstanceSave* tmp = itr->second.save; w->m[difficulty].erase(itr); - tmp->RemovePlayer(guidLow, this); + tmp->RemovePlayer(guid, this); } } } -InstancePlayerBind* InstanceSaveManager::PlayerGetBoundInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty) +InstancePlayerBind* InstanceSaveManager::PlayerGetBoundInstance(ObjectGuid guid, uint32 mapid, Difficulty difficulty) { Difficulty difficulty_fixed = ( IsSharedDifficultyMap(mapid) ? Difficulty(difficulty % 2) : difficulty); @@ -702,7 +702,7 @@ InstancePlayerBind* InstanceSaveManager::PlayerGetBoundInstance(uint32 guidLow, return nullptr; BoundInstancesMapWrapper* w = nullptr; - PlayerBindStorage::const_iterator itr = playerBindStorage.find(guidLow); + PlayerBindStorage::const_iterator itr = playerBindStorage.find(guid); if (itr != playerBindStorage.end()) w = itr->second; else @@ -715,31 +715,31 @@ InstancePlayerBind* InstanceSaveManager::PlayerGetBoundInstance(uint32 guidLow, return nullptr; } -bool InstanceSaveManager::PlayerIsPermBoundToInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty) +bool InstanceSaveManager::PlayerIsPermBoundToInstance(ObjectGuid guid, uint32 mapid, Difficulty difficulty) { - if (InstancePlayerBind* bind = PlayerGetBoundInstance(guidLow, mapid, difficulty)) + if (InstancePlayerBind* bind = PlayerGetBoundInstance(guid, mapid, difficulty)) if (bind->perm) return true; return false; } -BoundInstancesMap const& InstanceSaveManager::PlayerGetBoundInstances(uint32 guidLow, Difficulty difficulty) +BoundInstancesMap const& InstanceSaveManager::PlayerGetBoundInstances(ObjectGuid guid, Difficulty difficulty) { - PlayerBindStorage::iterator itr = playerBindStorage.find(guidLow); + PlayerBindStorage::iterator itr = playerBindStorage.find(guid); if (itr != playerBindStorage.end()) return itr->second->m[difficulty]; return emptyBoundInstancesMap; } -void InstanceSaveManager::PlayerCreateBoundInstancesMaps(uint32 guidLow) +void InstanceSaveManager::PlayerCreateBoundInstancesMaps(ObjectGuid guid) { - if (playerBindStorage.find(guidLow) == playerBindStorage.end()) - playerBindStorage[guidLow] = new BoundInstancesMapWrapper; + if (playerBindStorage.find(guid) == playerBindStorage.end()) + playerBindStorage[guid] = new BoundInstancesMapWrapper; } -InstanceSave* InstanceSaveManager::PlayerGetInstanceSave(uint32 guidLow, uint32 mapid, Difficulty difficulty) +InstanceSave* InstanceSaveManager::PlayerGetInstanceSave(ObjectGuid guid, uint32 mapid, Difficulty difficulty) { - InstancePlayerBind* pBind = PlayerGetBoundInstance(guidLow, mapid, difficulty); + InstancePlayerBind* pBind = PlayerGetBoundInstance(guid, mapid, difficulty); return (pBind ? pBind->save : nullptr); } @@ -748,19 +748,19 @@ uint32 InstanceSaveManager::PlayerGetDestinationInstanceId(Player* player, uint3 // returning 0 means a new instance will be created // non-zero implicates that InstanceSave exists - InstancePlayerBind* ipb = PlayerGetBoundInstance(player->GetGUIDLow(), mapid, difficulty); + InstancePlayerBind* ipb = PlayerGetBoundInstance(player->GetGUID(), mapid, difficulty); if (ipb && ipb->perm) // 1. self perm return ipb->save->GetInstanceId(); if (Group* g = player->GetGroup()) { - if (InstancePlayerBind* ilb = PlayerGetBoundInstance(GUID_LOPART(g->GetLeaderGUID()), mapid, difficulty)) // 2. leader temp/perm + if (InstancePlayerBind* ilb = PlayerGetBoundInstance(g->GetLeaderGUID(), mapid, difficulty)) // 2. leader temp/perm return ilb->save->GetInstanceId(); return 0; // 3. in group, no leader bind } return ipb ? ipb->save->GetInstanceId() : 0; // 4. self temp } -void InstanceSaveManager::CopyBinds(uint32 from, uint32 to, Player* toPlr) +void InstanceSaveManager::CopyBinds(ObjectGuid from, ObjectGuid to, Player* toPlr) { if (from == to) return; @@ -776,7 +776,7 @@ void InstanceSaveManager::CopyBinds(uint32 from, uint32 to, Player* toPlr) void InstanceSaveManager::UnbindAllFor(InstanceSave* save) { - InstanceSave::PlayerListType& pList = save->m_playerList; + GuidList& pList = save->m_playerList; while (!pList.empty()) - PlayerUnbindInstance(*(pList.begin()), save->GetMapId(), save->GetDifficulty(), true, ObjectAccessor::GetObjectInOrOutOfWorld(MAKE_NEW_GUID(*(pList.begin()), 0, HIGHGUID_PLAYER), (Player*)nullptr)); + PlayerUnbindInstance(*(pList.begin()), save->GetMapId(), save->GetDifficulty(), true, ObjectAccessor::FindConnectedPlayer(*(pList.begin()))); } diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h index 287f350ce7..8031685fa6 100644 --- a/src/server/game/Instances/InstanceSaveMgr.h +++ b/src/server/game/Instances/InstanceSaveMgr.h @@ -31,14 +31,14 @@ struct InstancePlayerBind InstancePlayerBind() : perm(false), extended(false) {} }; -typedef std::unordered_map< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap; +typedef std::unordered_map<uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap; struct BoundInstancesMapWrapper { BoundInstancesMap m[MAX_DIFFICULTY]; }; -typedef std::unordered_map< uint32 /*guidLow*/, BoundInstancesMapWrapper* > PlayerBindStorage; +typedef std::unordered_map<ObjectGuid /*guid*/, BoundInstancesMapWrapper* > PlayerBindStorage; class InstanceSave { @@ -72,12 +72,11 @@ public: InstanceTemplate const* GetTemplate(); MapEntry const* GetMapEntry(); - void AddPlayer(uint32 guidLow); - bool RemovePlayer(uint32 guidLow, InstanceSaveManager* ism); + void AddPlayer(ObjectGuid guid); + bool RemovePlayer(ObjectGuid guid, InstanceSaveManager* ism); - typedef std::list<uint32> PlayerListType; private: - PlayerListType m_playerList; + GuidList m_playerList; time_t m_resetTime; time_t m_extendedResetTime; uint32 m_instanceid; @@ -159,16 +158,16 @@ public: InstanceSave* GetInstanceSave(uint32 InstanceId); - InstancePlayerBind* PlayerBindToInstance(uint32 guidLow, InstanceSave* save, bool permanent, Player* player = nullptr); - void PlayerUnbindInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty, bool deleteFromDB, Player* player = nullptr); - void PlayerUnbindInstanceNotExtended(uint32 guidLow, uint32 mapid, Difficulty difficulty, Player* player = nullptr); - InstancePlayerBind* PlayerGetBoundInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty); - bool PlayerIsPermBoundToInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty); - BoundInstancesMap const& PlayerGetBoundInstances(uint32 guidLow, Difficulty difficulty); - void PlayerCreateBoundInstancesMaps(uint32 guidLow); - InstanceSave* PlayerGetInstanceSave(uint32 guidLow, uint32 mapid, Difficulty difficulty); + InstancePlayerBind* PlayerBindToInstance(ObjectGuid guid, InstanceSave* save, bool permanent, Player* player = nullptr); + void PlayerUnbindInstance(ObjectGuid guid, uint32 mapid, Difficulty difficulty, bool deleteFromDB, Player* player = nullptr); + void PlayerUnbindInstanceNotExtended(ObjectGuid guid, uint32 mapid, Difficulty difficulty, Player* player = nullptr); + InstancePlayerBind* PlayerGetBoundInstance(ObjectGuid guid, uint32 mapid, Difficulty difficulty); + bool PlayerIsPermBoundToInstance(ObjectGuid guid, uint32 mapid, Difficulty difficulty); + BoundInstancesMap const& PlayerGetBoundInstances(ObjectGuid guid, Difficulty difficulty); + void PlayerCreateBoundInstancesMaps(ObjectGuid guid); + InstanceSave* PlayerGetInstanceSave(ObjectGuid guid, uint32 mapid, Difficulty difficulty); uint32 PlayerGetDestinationInstanceId(Player* player, uint32 mapid, Difficulty difficulty); - void CopyBinds(uint32 from, uint32 to, Player* toPlr = nullptr); + void CopyBinds(ObjectGuid from, ObjectGuid to, Player* toPlr = nullptr); void UnbindAllFor(InstanceSave* save); protected: diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index 11c99c2a2c..033ec5d9ba 100644 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -36,7 +36,7 @@ void InstanceScript::SaveToDB() CharacterDatabase.Execute(stmt); } -void InstanceScript::HandleGameObject(uint64 GUID, bool open, GameObject* go) +void InstanceScript::HandleGameObject(ObjectGuid GUID, bool open, GameObject* go) { if (!go) go = instance->GetGameObject(GUID); @@ -255,7 +255,7 @@ std::string InstanceScript::GetBossSaveData() return saveStream.str(); } -void InstanceScript::DoUseDoorOrButton(uint64 uiGuid, uint32 uiWithRestoreTime, bool bUseAlternativeState) +void InstanceScript::DoUseDoorOrButton(ObjectGuid uiGuid, uint32 uiWithRestoreTime, bool bUseAlternativeState) { if (!uiGuid) return; @@ -276,7 +276,7 @@ void InstanceScript::DoUseDoorOrButton(uint64 uiGuid, uint32 uiWithRestoreTime, } } -void InstanceScript::DoRespawnGameObject(uint64 uiGuid, uint32 uiTimeToDespawn) +void InstanceScript::DoRespawnGameObject(ObjectGuid uiGuid, uint32 uiTimeToDespawn) { if (GameObject* go = instance->GetGameObject(uiGuid)) { @@ -427,7 +427,7 @@ void InstanceScript::SendEncounterUnit(uint32 type, Unit* unit /*= nullptr*/, ui case ENCOUNTER_FRAME_ENGAGE: case ENCOUNTER_FRAME_DISENGAGE: case ENCOUNTER_FRAME_UPDATE_PRIORITY: - data.append(unit->GetPackGUID()); + data << unit->GetPackGUID(); data << uint8(param1); break; case ENCOUNTER_FRAME_ADD_TIMER: diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h index 3204aab17b..8bd6daca54 100644 --- a/src/server/game/Instances/InstanceScript.h +++ b/src/server/game/Instances/InstanceScript.h @@ -89,6 +89,12 @@ struct MinionData uint32 entry, bossId; }; +struct ObjectData +{ + uint32 entry; + uint32 type; +}; + struct BossInfo { BossInfo() : state(TO_BE_DECIDED) {} @@ -153,15 +159,15 @@ public: virtual void OnPlayerAreaUpdate(Player* /*player*/, uint32 /*oldArea*/, uint32 /*newArea*/) {} //Handle open / close objects - //use HandleGameObject(0, boolen, GO); in OnObjectCreate in instance scripts + //use HandleGameObject(ObjectGuid::Empty, boolen, GO); in OnObjectCreate in instance scripts //use HandleGameObject(GUID, boolen, nullptr); in any other script - void HandleGameObject(uint64 guid, bool open, GameObject* go = nullptr); + void HandleGameObject(ObjectGuid guid, bool open, GameObject* go = nullptr); //change active state of doors or buttons - void DoUseDoorOrButton(uint64 guid, uint32 withRestoreTime = 0, bool useAlternativeState = false); + void DoUseDoorOrButton(ObjectGuid guid, uint32 withRestoreTime = 0, bool useAlternativeState = false); //Respawns a GO having negative spawntimesecs in gameobject-table - void DoRespawnGameObject(uint64 guid, uint32 timeToDespawn = MINUTE); + void DoRespawnGameObject(ObjectGuid guid, uint32 timeToDespawn = MINUTE); //sends world state update to all players in instance void DoUpdateWorldState(uint32 worldstateId, uint32 worldstateValue); diff --git a/src/server/game/Loot/LootItemStorage.cpp b/src/server/game/Loot/LootItemStorage.cpp index 7ecbd1f105..658010ecb9 100644 --- a/src/server/game/Loot/LootItemStorage.cpp +++ b/src/server/game/Loot/LootItemStorage.cpp @@ -40,7 +40,7 @@ void LootItemStorage::LoadStorageFromDB() { Field* fields = result->Fetch(); - StoredLootItemList& itemList = lootItemStore[fields[0].GetUInt32()]; + StoredLootItemList& itemList = lootItemStore[ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt32())]; itemList.push_back(StoredLootItem(fields[1].GetUInt32(), fields[2].GetUInt32(), fields[3].GetInt32(), fields[4].GetUInt32())); ++count; @@ -50,11 +50,12 @@ void LootItemStorage::LoadStorageFromDB() LOG_INFO("server", " "); } -void LootItemStorage::RemoveEntryFromDB(uint32 containerId, uint32 itemid, uint32 count) +void LootItemStorage::RemoveEntryFromDB(ObjectGuid containerGUID, uint32 itemid, uint32 count) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_SINGLE_ITEM); - stmt->setUInt32(0, containerId); + stmt->setUInt32(0, containerGUID.GetCounter()); stmt->setUInt32(1, itemid); stmt->setUInt32(2, count); trans->Append(stmt); @@ -64,16 +65,16 @@ void LootItemStorage::RemoveEntryFromDB(uint32 containerId, uint32 itemid, uint3 void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* /*player*/) { - if (lootItemStore.find(loot->containerId) != lootItemStore.end()) + if (lootItemStore.find(loot->containerGUID) != lootItemStore.end()) { - LOG_INFO("misc", "LootItemStorage::AddNewStoredLoot (A1) - %u!", loot->containerId); + LOG_INFO("misc", "LootItemStorage::AddNewStoredLoot (A1) - %s!", loot->containerGUID.ToString().c_str()); return; } SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = nullptr; - StoredLootItemList& itemList = lootItemStore[loot->containerId]; + StoredLootItemList& itemList = lootItemStore[loot->containerGUID]; // Gold at first if (loot->gold) @@ -81,7 +82,7 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* /*player*/) itemList.push_back(StoredLootItem(0, loot->gold, 0, 0)); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_SINGLE_ITEM); - stmt->setUInt32(0, loot->containerId); + stmt->setUInt32(0, loot->containerGUID.GetCounter()); stmt->setUInt32(1, 0); stmt->setUInt32(2, loot->gold); stmt->setInt32(3, 0); @@ -106,7 +107,7 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* /*player*/) itemList.push_back(StoredLootItem(li->itemid, li->count, li->randomPropertyId, li->randomSuffix)); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_SINGLE_ITEM); - stmt->setUInt32(0, loot->containerId); + stmt->setUInt32(0, loot->containerGUID.GetCounter()); stmt->setUInt32(1, li->itemid); stmt->setUInt32(2, li->count); stmt->setInt32 (3, li->randomPropertyId); @@ -120,7 +121,7 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* /*player*/) bool LootItemStorage::LoadStoredLoot(Item* item) { Loot* loot = &item->loot; - LootItemContainer::iterator itr = lootItemStore.find(loot->containerId); + LootItemContainer::iterator itr = lootItemStore.find(loot->containerGUID); if (itr == lootItemStore.end()) return false; @@ -145,7 +146,7 @@ bool LootItemStorage::LoadStoredLoot(Item* item) li.needs_quest = false; li.randomPropertyId = it2->randomPropertyId; li.randomSuffix = it2->randomSuffix; - li.rollWinnerGUID = 0; + li.rollWinnerGUID = ObjectGuid::Empty; loot->items.push_back(li); loot->unlootedCount++; @@ -156,9 +157,9 @@ bool LootItemStorage::LoadStoredLoot(Item* item) return true; } -void LootItemStorage::RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count, Loot* loot) +void LootItemStorage::RemoveStoredLootItem(ObjectGuid containerGUID, uint32 itemid, uint32 count, Loot* loot) { - LootItemContainer::iterator itr = lootItemStore.find(containerId); + LootItemContainer::iterator itr = lootItemStore.find(containerGUID); if (itr == lootItemStore.end()) return; @@ -166,7 +167,7 @@ void LootItemStorage::RemoveStoredLootItem(uint32 containerId, uint32 itemid, ui for (StoredLootItemList::iterator it2 = itemList.begin(); it2 != itemList.end(); ++it2) if (it2->itemid == itemid && it2->count == count) { - RemoveEntryFromDB(containerId, itemid, count); + RemoveEntryFromDB(containerGUID, itemid, count); itemList.erase(it2); break; } @@ -177,9 +178,9 @@ void LootItemStorage::RemoveStoredLootItem(uint32 containerId, uint32 itemid, ui lootItemStore.erase(itr); } -void LootItemStorage::RemoveStoredLootMoney(uint32 containerId, Loot* loot) +void LootItemStorage::RemoveStoredLootMoney(ObjectGuid containerGUID, Loot* loot) { - LootItemContainer::iterator itr = lootItemStore.find(containerId); + LootItemContainer::iterator itr = lootItemStore.find(containerGUID); if (itr == lootItemStore.end()) return; @@ -187,7 +188,7 @@ void LootItemStorage::RemoveStoredLootMoney(uint32 containerId, Loot* loot) for (StoredLootItemList::iterator it2 = itemList.begin(); it2 != itemList.end(); ++it2) if (it2->itemid == 0) { - RemoveEntryFromDB(containerId, 0, it2->count); + RemoveEntryFromDB(containerGUID, 0, it2->count); itemList.erase(it2); break; } @@ -198,13 +199,14 @@ void LootItemStorage::RemoveStoredLootMoney(uint32 containerId, Loot* loot) lootItemStore.erase(itr); } -void LootItemStorage::RemoveStoredLoot(uint32 containerId) +void LootItemStorage::RemoveStoredLoot(ObjectGuid containerGUID) { - lootItemStore.erase(containerId); + lootItemStore.erase(containerGUID); SQLTransaction trans = CharacterDatabase.BeginTransaction(); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_CONTAINER); - stmt->setUInt32(0, containerId); + stmt->setUInt32(0, containerGUID.GetCounter()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); diff --git a/src/server/game/Loot/LootItemStorage.h b/src/server/game/Loot/LootItemStorage.h index a05f0237d0..dd97915883 100644 --- a/src/server/game/Loot/LootItemStorage.h +++ b/src/server/game/Loot/LootItemStorage.h @@ -24,7 +24,7 @@ struct StoredLootItem }; typedef std::list<StoredLootItem> StoredLootItemList; -typedef std::unordered_map<uint32, StoredLootItemList> LootItemContainer; +typedef std::unordered_map<ObjectGuid, StoredLootItemList> LootItemContainer; class LootItemStorage { @@ -36,14 +36,14 @@ public: static LootItemStorage* instance(); void LoadStorageFromDB(); - void RemoveEntryFromDB(uint32 containerId, uint32 itemid, uint32 count); + void RemoveEntryFromDB(ObjectGuid containerGUID, uint32 itemid, uint32 count); void AddNewStoredLoot(Loot* loot, Player* player); bool LoadStoredLoot(Item* item); - void RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count, Loot* loot); - void RemoveStoredLootMoney(uint32 containerId, Loot* loot); - void RemoveStoredLoot(uint32 containerId); + void RemoveStoredLootItem(ObjectGuid containerGUID, uint32 itemid, uint32 count, Loot* loot); + void RemoveStoredLootMoney(ObjectGuid containerGUID, Loot* loot); + void RemoveStoredLoot(ObjectGuid containerGUID); private: LootItemContainer lootItemStore; diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index 3f6576c059..89b52947f4 100644 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -383,7 +383,7 @@ LootItem::LootItem(LootStoreItem const& li) is_blocked = 0; is_underthreshold = 0; is_counted = 0; - rollWinnerGUID = 0; + rollWinnerGUID = ObjectGuid::Empty; } // Basic checks for player/item compatibility - if false no chance to see the item in the loot @@ -444,9 +444,9 @@ bool LootItem::AllowedForPlayer(Player const* player, bool isGivenByMasterLooter return true; } -void LootItem::AddAllowedLooter(const Player* player) +void LootItem::AddAllowedLooter(Player const* player) { - allowedGUIDs.insert(player->GetGUIDLow()); + allowedGUIDs.insert(player->GetGUID()); } // @@ -532,17 +532,17 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo void Loot::FillNotNormalLootFor(Player* player, bool presentAtLooting) { - uint32 plguid = player->GetGUIDLow(); + ObjectGuid playerGuid = player->GetGUID(); - QuestItemMap::const_iterator qmapitr = PlayerQuestItems.find(plguid); + QuestItemMap::const_iterator qmapitr = PlayerQuestItems.find(playerGuid); if (qmapitr == PlayerQuestItems.end()) FillQuestLoot(player); - qmapitr = PlayerFFAItems.find(plguid); + qmapitr = PlayerFFAItems.find(playerGuid); if (qmapitr == PlayerFFAItems.end()) FillFFALoot(player); - qmapitr = PlayerNonQuestNonFFAConditionalItems.find(plguid); + qmapitr = PlayerNonQuestNonFFAConditionalItems.find(playerGuid); if (qmapitr == PlayerNonQuestNonFFAConditionalItems.end()) FillNonQuestNonFFAConditionalLoot(player, presentAtLooting); @@ -587,7 +587,7 @@ QuestItemList* Loot::FillFFALoot(Player* player) return nullptr; } - PlayerFFAItems[player->GetGUIDLow()] = ql; + PlayerFFAItems[player->GetGUID()] = ql; return ql; } @@ -625,7 +625,7 @@ QuestItemList* Loot::FillQuestLoot(Player* player) return nullptr; } - PlayerQuestItems[player->GetGUIDLow()] = ql; + PlayerQuestItems[player->GetGUID()] = ql; return ql; } @@ -657,7 +657,7 @@ QuestItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player, bool pres return nullptr; } - PlayerNonQuestNonFFAConditionalItems[player->GetGUIDLow()] = ql; + PlayerNonQuestNonFFAConditionalItems[player->GetGUID()] = ql; return ql; } @@ -708,7 +708,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex) ++i_next; if (Player* player = ObjectAccessor::FindPlayer(*i)) { - QuestItemMap::const_iterator pq = PlayerQuestItems.find(player->GetGUIDLow()); + QuestItemMap::const_iterator pq = PlayerQuestItems.find(player->GetGUID()); if (pq != PlayerQuestItems.end() && pq->second) { // find where/if the player has the given item in it's vector @@ -748,7 +748,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem * *qit if (lootSlot >= items.size()) { uint32 questSlot = lootSlot - items.size(); - QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUIDLow()); + QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUID()); if (itr != PlayerQuestItems.end() && questSlot < itr->second->size()) { QuestItem* qitem2 = &itr->second->at(questSlot); @@ -766,7 +766,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem * *qit is_looted = item->is_looted; if (item->freeforall) { - QuestItemMap::const_iterator itr = PlayerFFAItems.find(player->GetGUIDLow()); + QuestItemMap::const_iterator itr = PlayerFFAItems.find(player->GetGUID()); if (itr != PlayerFFAItems.end()) { for (QuestItemList::const_iterator iter = itr->second->begin(); iter != itr->second->end(); ++iter) @@ -782,7 +782,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem * *qit } else if (!item->conditions.empty()) { - QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow()); + QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.find(player->GetGUID()); if (itr != PlayerNonQuestNonFFAConditionalItems.end()) { for (QuestItemList::const_iterator iter = itr->second->begin(); iter != itr->second->end(); ++iter) @@ -808,7 +808,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem * *qit uint32 Loot::GetMaxSlotInLootFor(Player* player) const { - QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUIDLow()); + QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUID()); return items.size() + (itr != PlayerQuestItems.end() ? itr->second->size() : 0); } @@ -830,7 +830,7 @@ bool Loot::hasItemForAll() const bool Loot::hasItemFor(Player* player) const { QuestItemMap const& lootPlayerQuestItems = GetPlayerQuestItems(); - QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(player->GetGUIDLow()); + QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(player->GetGUID()); if (q_itr != lootPlayerQuestItems.end()) { QuestItemList* q_list = q_itr->second; @@ -843,7 +843,7 @@ bool Loot::hasItemFor(Player* player) const } QuestItemMap const& lootPlayerFFAItems = GetPlayerFFAItems(); - QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(player->GetGUIDLow()); + QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(player->GetGUID()); if (ffa_itr != lootPlayerFFAItems.end()) { QuestItemList* ffa_list = ffa_itr->second; @@ -856,7 +856,7 @@ bool Loot::hasItemFor(Player* player) const } QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = GetPlayerNonQuestNonFFAConditionalItems(); - QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow()); + QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(player->GetGUID()); if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end()) { QuestItemList* conditional_list = nn_itr->second; @@ -960,7 +960,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) else continue; } - else if (l.roundRobinPlayer == 0 || lv.viewer->GetGUID() == l.roundRobinPlayer || !l.items[i].is_underthreshold) + else if (!l.roundRobinPlayer || lv.viewer->GetGUID() == l.roundRobinPlayer || !l.items[i].is_underthreshold) { // no round robin owner or he has released the loot // or it IS the round robin group owner @@ -984,7 +984,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) { if (!l.items[i].is_looted && !l.items[i].freeforall && l.items[i].conditions.empty() && l.items[i].AllowedForPlayer(lv.viewer)) { - if (l.roundRobinPlayer != 0 && lv.viewer->GetGUID() != l.roundRobinPlayer) + if (l.roundRobinPlayer && lv.viewer->GetGUID() != l.roundRobinPlayer) // item shall not be displayed. continue; @@ -1020,7 +1020,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) LootSlotType partySlotType = lv.permission == MASTER_PERMISSION ? LOOT_SLOT_TYPE_MASTER : slotType; QuestItemMap const& lootPlayerQuestItems = l.GetPlayerQuestItems(); - QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUIDLow()); + QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUID()); if (q_itr != lootPlayerQuestItems.end()) { QuestItemList* q_list = q_itr->second; @@ -1063,7 +1063,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) } QuestItemMap const& lootPlayerFFAItems = l.GetPlayerFFAItems(); - QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUIDLow()); + QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUID()); if (ffa_itr != lootPlayerFFAItems.end()) { QuestItemList* ffa_list = ffa_itr->second; @@ -1082,7 +1082,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) } QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = l.GetPlayerNonQuestNonFFAConditionalItems(); - QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUIDLow()); + QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUID()); if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end()) { QuestItemList* conditional_list = nn_itr->second; diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h index 878759a663..f55ca83e81 100644 --- a/src/server/game/Loot/LootMgr.h +++ b/src/server/game/Loot/LootMgr.h @@ -10,12 +10,14 @@ #include "ByteBuffer.h" #include "ConditionMgr.h" #include "ItemEnchantmentMgr.h" +#include "ObjectGuid.h" #include "RefManager.h" #include "SharedDefines.h" #include <list> #include <map> #include <vector> + enum RollType { ROLL_PASS = 0, @@ -135,7 +137,7 @@ struct LootStoreItem // Checks correctness of values }; -typedef std::set<uint32> AllowedLooterSet; +typedef GuidSet AllowedLooterSet; struct LootItem { @@ -144,7 +146,7 @@ struct LootItem int32 randomPropertyId; ConditionList conditions; // additional loot condition AllowedLooterSet allowedGUIDs; - uint64 rollWinnerGUID; // Stores the guid of person who won loot, if his bags are full only he can see the item in loot list! + ObjectGuid rollWinnerGUID; // Stores the guid of person who won loot, if his bags are full only he can see the item in loot list! uint8 count : 8; bool is_looted : 1; bool is_blocked : 1; @@ -183,7 +185,7 @@ class LootTemplate; typedef std::vector<QuestItem> QuestItemList; typedef std::vector<LootItem> LootItemList; -typedef std::map<uint32, QuestItemList*> QuestItemMap; +typedef std::map<ObjectGuid, QuestItemList*> QuestItemMap; typedef std::list<LootStoreItem*> LootStoreItemList; typedef std::unordered_map<uint32, LootTemplate*> LootTemplateMap; @@ -306,11 +308,11 @@ struct Loot std::vector<LootItem> quest_items; uint32 gold; uint8 unlootedCount{0}; - uint64 roundRobinPlayer{0}; // GUID of the player having the Round-Robin ownership for the loot. If 0, round robin owner has released. - LootType loot_type{LOOT_NONE}; // required for achievement system + ObjectGuid roundRobinPlayer; // GUID of the player having the Round-Robin ownership for the loot. If 0, round robin owner has released. + LootType loot_type{LOOT_NONE}; // required for achievement system - // GUIDLow of container that holds this loot (item_instance.entry), set for items that can be looted - uint32 containerId{0}; + // GUID of container that holds this loot (item_instance.entry), set for items that can be looted + ObjectGuid containerGUID; Loot(uint32 _gold = 0) : gold(_gold) { } ~Loot() { clear(); } @@ -341,7 +343,7 @@ struct Loot quest_items.clear(); gold = 0; unlootedCount = 0; - roundRobinPlayer = 0; + roundRobinPlayer.Clear(); i_LootValidatorRefManager.clearReferences(); loot_type = LOOT_NONE; } @@ -352,8 +354,8 @@ struct Loot void NotifyItemRemoved(uint8 lootIndex); void NotifyQuestItemRemoved(uint8 questIndex); void NotifyMoneyRemoved(); - void AddLooter(uint64 GUID) { PlayersLooting.insert(GUID); } - void RemoveLooter(uint64 GUID) { PlayersLooting.erase(GUID); } + void AddLooter(ObjectGuid GUID) { PlayersLooting.insert(GUID); } + void RemoveLooter(ObjectGuid GUID) { PlayersLooting.erase(GUID); } void generateMoneyLoot(uint32 minAmount, uint32 maxAmount); bool FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bool personal, bool noEmptyError = false, uint16 lootMode = LOOT_MODE_DEFAULT); @@ -373,7 +375,7 @@ private: QuestItemList* FillQuestLoot(Player* player); QuestItemList* FillNonQuestNonFFAConditionalLoot(Player* player, bool presentAtLooting); - typedef std::set<uint64> PlayersLootingSet; + typedef GuidSet PlayersLootingSet; PlayersLootingSet PlayersLooting; QuestItemMap PlayerQuestItems; QuestItemMap PlayerFFAItems; diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp index ea29f82c2b..4b356addfe 100644 --- a/src/server/game/Mails/Mail.cpp +++ b/src/server/game/Mails/Mail.cpp @@ -35,7 +35,7 @@ MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery break;*/ case TYPEID_PLAYER: m_messageType = MAIL_NORMAL; - m_senderId = sender->GetGUIDLow(); + m_senderId = sender->GetGUID().GetCounter(); break; default: m_messageType = MAIL_NORMAL; @@ -59,7 +59,7 @@ MailSender::MailSender(Player* sender) { m_messageType = MAIL_NORMAL; m_stationery = sender->IsGameMaster() ? MAIL_STATIONERY_GM : MAIL_STATIONERY_DEFAULT; - m_senderId = sender->GetGUIDLow(); + m_senderId = sender->GetGUID().GetCounter(); } MailSender::MailSender(uint32 senderEntry) @@ -69,18 +69,18 @@ MailSender::MailSender(uint32 senderEntry) m_stationery = MAIL_STATIONERY_DEFAULT; } -MailReceiver::MailReceiver(Player* receiver) : m_receiver(receiver), m_receiver_lowguid(receiver->GetGUIDLow()) +MailReceiver::MailReceiver(Player* receiver) : m_receiver(receiver), m_receiver_lowguid(receiver->GetGUID().GetCounter()) { } -MailReceiver::MailReceiver(Player* receiver, uint32 receiver_lowguid) : m_receiver(receiver), m_receiver_lowguid(receiver_lowguid) +MailReceiver::MailReceiver(Player* receiver, ObjectGuid::LowType receiver_lowguid) : m_receiver(receiver), m_receiver_lowguid(receiver_lowguid) { - ASSERT(!receiver || receiver->GetGUIDLow() == receiver_lowguid); + ASSERT(!receiver || receiver->GetGUID().GetCounter() == receiver_lowguid); } MailDraft& MailDraft::AddItem(Item* item) { - m_items[item->GetGUIDLow()] = item; + m_items[item->GetGUID()] = item; return *this; } @@ -119,7 +119,7 @@ void MailDraft::deleteIncludedItems(SQLTransaction& trans, bool inDB /*= false*/ if (inDB) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); - stmt->setUInt32(0, item->GetGUIDLow()); + stmt->setUInt32(0, item->GetGUID().GetCounter()); trans->Append(stmt); } @@ -129,13 +129,13 @@ void MailDraft::deleteIncludedItems(SQLTransaction& trans, bool inDB /*= false*/ m_items.clear(); } -void MailDraft::SendReturnToSender(uint32 /*sender_acc*/, uint32 sender_guid, uint32 receiver_guid, SQLTransaction& trans) +void MailDraft::SendReturnToSender(uint32 /*sender_acc*/, ObjectGuid::LowType sender_guid, ObjectGuid::LowType receiver_guid, SQLTransaction& trans) { - Player* receiver = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER)); + Player* receiver = ObjectAccessor::FindPlayerByLowGUID(receiver_guid); uint32 rc_account = 0; if (!receiver) - rc_account = sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER)); + rc_account = sObjectMgr->GetPlayerAccountIdByGUID(receiver_guid); if (!receiver && !rc_account) // sender not exist { @@ -156,7 +156,7 @@ void MailDraft::SendReturnToSender(uint32 /*sender_acc*/, uint32 sender_guid, u // owner in data will set at mail receive and item extracting PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER); stmt->setUInt32(0, receiver_guid); - stmt->setUInt32(1, item->GetGUIDLow()); + stmt->setUInt32(1, item->GetGUID().GetCounter()); trans->Append(stmt); } } @@ -178,7 +178,7 @@ void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, return; Player* pReceiver = receiver.GetPlayer(); // can be nullptr - Player* pSender = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(sender.GetSenderId(), 0, HIGHGUID_PLAYER)); + Player* pSender = ObjectAccessor::FindPlayerByLowGUID(sender.GetSenderId()); if (pReceiver) prepareItems(pReceiver, trans); // generate mail template items @@ -233,7 +233,7 @@ void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, Item* pItem = mailItemIter->second; stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_MAIL_ITEM); stmt->setUInt32(0, mailId); - stmt->setUInt32(1, pItem->GetGUIDLow()); + stmt->setUInt32(1, pItem->GetGUID().GetCounter()); stmt->setUInt32(2, receiver.GetPlayerGUIDLow()); trans->Append(stmt); } @@ -257,7 +257,7 @@ void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) { Item* item = mailItemIter->second; - m->AddItem(item->GetGUIDLow(), item->GetEntry()); + m->AddItem(item->GetGUID().GetCounter(), item->GetEntry()); } m->messageType = sender.GetMailMessageType(); diff --git a/src/server/game/Mails/Mail.h b/src/server/game/Mails/Mail.h index 09f84cd07b..88cfb5d69d 100644 --- a/src/server/game/Mails/Mail.h +++ b/src/server/game/Mails/Mail.h @@ -92,20 +92,20 @@ private: class MailReceiver { public: // Constructors - explicit MailReceiver(uint32 receiver_lowguid) : m_receiver(nullptr), m_receiver_lowguid(receiver_lowguid) {} + explicit MailReceiver(ObjectGuid::LowType receiver_lowguid) : m_receiver(nullptr), m_receiver_lowguid(receiver_lowguid) {} MailReceiver(Player* receiver); - MailReceiver(Player* receiver, uint32 receiver_lowguid); + MailReceiver(Player* receiver, ObjectGuid::LowType receiver_lowguid); public: // Accessors [[nodiscard]] Player* GetPlayer() const { return m_receiver; } - [[nodiscard]] uint32 GetPlayerGUIDLow() const { return m_receiver_lowguid; } + [[nodiscard]] ObjectGuid::LowType GetPlayerGUIDLow() const { return m_receiver_lowguid; } private: Player* m_receiver; - uint32 m_receiver_lowguid; + ObjectGuid::LowType m_receiver_lowguid; }; class MailDraft { - typedef std::map<uint32, Item*> MailItemMap; + typedef std::map<ObjectGuid, Item*> MailItemMap; public: // Constructors explicit MailDraft(uint16 mailTemplateId, bool need_items = true) @@ -126,7 +126,7 @@ public: // modifiers MailDraft& AddCOD(uint32 COD) { m_COD = COD; return *this; } public: // finishers - void SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, SQLTransaction& trans); + void SendReturnToSender(uint32 sender_acc, ObjectGuid::LowType sender_guid, ObjectGuid::LowType receiver_guid, SQLTransaction& trans); void SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked = MAIL_CHECK_MASK_NONE, uint32 deliver_delay = 0, uint32 custom_expiration = 0, bool deleteMailItemsFromDB = false, bool sendMail = true); private: @@ -146,7 +146,7 @@ private: struct MailItemInfo { - uint32 item_guid; + ObjectGuid::LowType item_guid; uint32 item_template; }; typedef std::vector<MailItemInfo> MailItemInfoVec; @@ -158,7 +158,7 @@ struct Mail uint8 stationery; uint16 mailTemplateId; uint32 sender; - uint32 receiver; + ObjectGuid::LowType receiver; std::string subject; std::string body; std::vector<MailItemInfo> items; @@ -170,7 +170,7 @@ struct Mail uint32 checked; MailState state; - void AddItem(uint32 itemGuidLow, uint32 item_template) + void AddItem(ObjectGuid::LowType itemGuidLow, uint32 item_template) { MailItemInfo mii; mii.item_guid = itemGuidLow; @@ -178,7 +178,7 @@ struct Mail items.push_back(mii); } - bool RemoveItem(uint32 item_guid) + bool RemoveItem(ObjectGuid::LowType item_guid) { for (MailItemInfoVec::iterator itr = items.begin(); itr != items.end(); ++itr) { diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 73bf418030..9797fbff68 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -43,9 +43,9 @@ u_map_magic MapLiquidMagic = { {'M', 'L', 'I', 'Q'} }; Map::~Map() { - sScriptMgr->OnDestroyMap(this); + // UnloadAll must be called before deleting the map - UnloadAll(); + sScriptMgr->OnDestroyMap(this); while (!i_worldObjects.empty()) { @@ -300,6 +300,25 @@ void Map::AddToGrid(DynamicObject* obj, Cell const& cell) obj->SetCurrentCell(cell); } +template<> +void Map::AddToGrid(Corpse* obj, Cell const& cell) +{ + NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); + // Corpses are a special object type - they can be added to grid via a call to AddToMap + // or loaded through ObjectGridLoader. + // Both corpses loaded from database and these freshly generated by Player::CreateCoprse are added to _corpsesByCell + // ObjectGridLoader loads all corpses from _corpsesByCell even if they were already added to grid before it was loaded + // so we need to explicitly check it here (Map::AddToGrid is only called from Player::BuildPlayerRepop, not from ObjectGridLoader) + // to avoid failing an assertion in GridObject::AddToGrid + if (grid->isGridObjectDataLoaded()) + { + if (obj->IsWorldObject()) + grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj); + else + grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj); + } +} + template<class T> void Map::SwitchGridContainers(T* /*obj*/, bool /*on*/) { @@ -312,7 +331,8 @@ void Map::SwitchGridContainers(Creature* obj, bool on) CellCoord p = acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); if (!p.IsCoordValid()) { - LOG_ERROR("server", "Map::SwitchGridContainers: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); + LOG_ERROR("server", "Map::SwitchGridContainers: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", + obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; } @@ -321,7 +341,7 @@ void Map::SwitchGridContainers(Creature* obj, bool on) return; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("maps", "Switch object " SZFMTD " from grid[%u, %u] %d", obj->GetGUID(), cell.GridX(), cell.GridY(), on); + LOG_DEBUG("maps", "Switch object %s from grid[%u, %u] %d", obj->GetGUID().ToString().c_str(), cell.GridX(), cell.GridY(), on); #endif NGridType* ngrid = getNGrid(cell.GridX(), cell.GridY()); ASSERT(ngrid != nullptr); @@ -351,7 +371,8 @@ void Map::SwitchGridContainers(GameObject* obj, bool on) CellCoord p = acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); if (!p.IsCoordValid()) { - LOG_ERROR("server", "Map::SwitchGridContainers: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); + LOG_ERROR("server", "Map::SwitchGridContainers: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", + obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; } @@ -359,7 +380,7 @@ void Map::SwitchGridContainers(GameObject* obj, bool on) if (!IsGridLoaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y))) return; - //TC_LOG_DEBUG(LOG_FILTER_MAPS, "Switch object " UI64FMTD " from grid[%u, %u] %u", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y, on); + //TC_LOG_DEBUG(LOG_FILTER_MAPS, "Switch object %s from grid[%u, %u] %u", obj->GetGUID().ToString().c_str(), cell.data.Part.grid_x, cell.data.Part.grid_y, on); NGridType* ngrid = getNGrid(cell.GridX(), cell.GridY()); ASSERT(ngrid != nullptr); @@ -389,14 +410,9 @@ void Map::DeleteFromWorld(T* obj) template<> void Map::DeleteFromWorld(Player* player) { - sObjectAccessor->RemoveObject(player); + ObjectAccessor::RemoveObject(player); - // pussywizard: optimization - std::string charName = player->GetName(); - std::transform(charName.begin(), charName.end(), charName.begin(), ::tolower); - sObjectAccessor->playerNameToPlayerPointer.erase(charName); - - sObjectAccessor->RemoveUpdateObject(player); //TODO: I do not know why we need this, it should be removed in ~Object anyway + RemoveUpdateObject(player); //TODO: I do not know why we need this, it should be removed in ~Object anyway delete player; } @@ -454,8 +470,6 @@ bool Map::EnsureGridLoaded(const Cell& cell) ObjectGridLoader loader(*grid, this, cell); loader.LoadN(); - // Add resurrectable corpses to world object list in grid - sObjectAccessor->AddCorpsesToGrid(GridCoord(cell.GridX(), cell.GridY()), grid->GetGridType(cell.CellX(), cell.CellY()), this); Balance(); return true; //} @@ -481,7 +495,8 @@ bool Map::AddPlayerToMap(Player* player) CellCoord cellCoord = acore::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()); if (!cellCoord.IsCoordValid()) { - LOG_ERROR("server", "Map::Add: Player (GUID: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); + LOG_ERROR("server", "Map::Add: Player (%s) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", + player->GetGUID().ToString().c_str(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); return false; } @@ -501,6 +516,9 @@ bool Map::AddPlayerToMap(Player* player) player->m_clientGUIDs.clear(); player->UpdateObjectVisibility(false); + if (player->IsAlive()) + ConvertCorpseToBones(player->GetGUID()); + sScriptMgr->OnPlayerEnterMap(this, player); return true; } @@ -540,7 +558,8 @@ bool Map::AddToMap(T* obj, bool checkTransport) ASSERT(cellCoord.IsCoordValid()); if (!cellCoord.IsCoordValid()) { - LOG_ERROR("server", "Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); + LOG_ERROR("server", "Map::Add: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", + obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); return false; //Should delete object } @@ -588,7 +607,8 @@ bool Map::AddToMap(MotionTransport* obj, bool /*checkTransport*/) CellCoord cellCoord = acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); if (!cellCoord.IsCoordValid()) { - LOG_ERROR("server", "Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); + LOG_ERROR("server", "Map::Add: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", + obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); return false; //Should delete object } @@ -830,6 +850,8 @@ void Map::Update(const uint32 t_diff, const uint32 s_diff, bool /*thread*/) transport->Update(t_diff); } + SendObjectUpdates(); + ///- Process necessary scripts if (!m_scriptSchedule.empty()) { @@ -845,8 +867,6 @@ void Map::Update(const uint32 t_diff, const uint32 s_diff, bool /*thread*/) HandleDelayedVisibility(); sScriptMgr->OnMapUpdate(this, t_diff); - - BuildAndSendUpdateForObjects(); // pussywizard } void Map::HandleDelayedVisibility() @@ -1263,6 +1283,20 @@ void Map::UnloadAll() } _transports.clear(); + + for (auto& cellCorpsePair : _corpsesByCell) + { + for (Corpse* corpse : cellCorpsePair.second) + { + corpse->RemoveFromWorld(); + corpse->ResetMap(); + delete corpse; + } + } + + _corpsesByCell.clear(); + _corpsesByPlayer.clear(); + _corpseBones.clear(); } // ***************************** @@ -2333,7 +2367,7 @@ void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpa void Map::SendInitSelf(Player* player) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creating player data for himself %u", player->GetGUIDLow()); + LOG_DEBUG("server", "Creating player data for himself %s", player->GetGUID().ToString().c_str()); #endif UpdateData data; @@ -2378,9 +2412,9 @@ void Map::SendRemoveTransports(Player* player) (*itr)->BuildOutOfRangeUpdateBlock(&transData); // pussywizard: remove static transports from client - for (Player::ClientGUIDs::const_iterator it = player->m_clientGUIDs.begin(); it != player->m_clientGUIDs.end(); ) + for (GuidUnorderedSet::const_iterator it = player->m_clientGUIDs.begin(); it != player->m_clientGUIDs.end(); ) { - if (IS_TRANSPORT_GUID(*it)) + if ((*it).IsTransport()) { transData.AddOutOfRangeGUID(*it); it = player->m_clientGUIDs.erase(it); @@ -2404,6 +2438,29 @@ inline void Map::setNGrid(NGridType* grid, uint32 x, uint32 y) i_grids[x][y] = grid; } +void Map::SendObjectUpdates() +{ + UpdateDataMapType update_players; + UpdatePlayerSet player_set; + + while (!_updateObjects.empty()) + { + Object* obj = *_updateObjects.begin(); + ASSERT(obj->IsInWorld()); + + _updateObjects.erase(_updateObjects.begin()); + obj->BuildUpdate(update_players, player_set); + } + + WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 + for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) + { + iter->second.BuildPacket(&packet); + iter->first->GetSession()->SendPacket(&packet); + packet.clear(); // clean the string + } +} + void Map::DelayedUpdate(const uint32 t_diff) { for (_transportsUpdateIter = _transports.begin(); _transportsUpdateIter != _transports.end();) @@ -2427,7 +2484,7 @@ void Map::AddObjectToRemoveList(WorldObject* obj) obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links i_objectsToRemove.insert(obj); - //LOG_DEBUG("maps", "Object (GUID: %u TypeId: %u) added to removing list.", obj->GetGUIDLow(), obj->GetTypeId()); + //LOG_DEBUG("maps", "Object (%s) added to removing list.", obj->GetGUID().ToString().c_str()); } void Map::AddObjectToSwitchList(WorldObject* obj, bool on) @@ -2485,7 +2542,7 @@ void Map::RemoveAllObjectsInRemoveList() { Corpse* corpse = ObjectAccessor::GetCorpse(*obj, obj->GetGUID()); if (!corpse) - LOG_ERROR("server", "Tried to delete corpse/bones %u that is not in map.", obj->GetGUIDLow()); + LOG_ERROR("server", "Tried to delete corpse/bones %s that is not in map.", obj->GetGUID().ToString().c_str()); else RemoveFromMap(corpse, true); break; @@ -2651,7 +2708,8 @@ bool InstanceMap::CanEnter(Player* player, bool loginCheck) { if (!loginCheck && player->GetMapRef().getTarget() == this) { - LOG_ERROR("server", "InstanceMap::CanEnter - player %s(%u) already in map %d, %d, %d!", player->GetName().c_str(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); + LOG_ERROR("server", "InstanceMap::CanEnter - player %s (%s) already in map %d, %d, %d!", + player->GetName().c_str(), player->GetGUID().ToString().c_str(), GetId(), GetInstanceId(), GetSpawnMode()); ABORT(); return false; } @@ -2736,25 +2794,27 @@ bool InstanceMap::AddPlayerToMap(Player* player) } // check for existing instance binds - InstancePlayerBind* playerBind = sInstanceSaveMgr->PlayerGetBoundInstance(player->GetGUIDLow(), GetId(), Difficulty(GetSpawnMode())); + InstancePlayerBind* playerBind = sInstanceSaveMgr->PlayerGetBoundInstance(player->GetGUID(), GetId(), Difficulty(GetSpawnMode())); if (playerBind && playerBind->perm) { if (playerBind->save != mapSave) { - LOG_ERROR("server", "InstanceMap::Add: player %s(%d) is permanently bound to instance %d, %d, %d, %d but he is being put into instance %d, %d, %d, %d", player->GetName().c_str(), player->GetGUIDLow(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->CanReset(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->CanReset()); + LOG_ERROR("server", "InstanceMap::Add: player %s (%s) is permanently bound to instance %d, %d, %d, %d but he is being put into instance %d, %d, %d, %d", + player->GetName().c_str(), player->GetGUID().ToString().c_str(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), + playerBind->save->CanReset(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->CanReset()); return false; } } else { - playerBind = sInstanceSaveMgr->PlayerBindToInstance(player->GetGUIDLow(), mapSave, false, player); + playerBind = sInstanceSaveMgr->PlayerBindToInstance(player->GetGUID(), mapSave, false, player); // pussywizard: bind lider also if not yet bound if (Group* g = player->GetGroup()) if (g->GetLeaderGUID() != player->GetGUID()) - if (!sInstanceSaveMgr->PlayerGetBoundInstance(GUID_LOPART(g->GetLeaderGUID()), mapSave->GetMapId(), mapSave->GetDifficulty())) + if (!sInstanceSaveMgr->PlayerGetBoundInstance(g->GetLeaderGUID(), mapSave->GetMapId(), mapSave->GetDifficulty())) { - sInstanceSaveMgr->PlayerCreateBoundInstancesMaps(GUID_LOPART(g->GetLeaderGUID())); - sInstanceSaveMgr->PlayerBindToInstance(GUID_LOPART(g->GetLeaderGUID()), mapSave, false, ObjectAccessor::FindPlayerInOrOutOfWorld(g->GetLeaderGUID())); + sInstanceSaveMgr->PlayerCreateBoundInstancesMaps(g->GetLeaderGUID()); + sInstanceSaveMgr->PlayerBindToInstance(g->GetLeaderGUID(), mapSave, false, ObjectAccessor::FindConnectedPlayer(g->GetLeaderGUID())); } } @@ -2857,7 +2917,7 @@ void InstanceMap::CreateInstanceScript(bool load, std::string data, uint32 compl /* Returns true if there are no players in the instance */ -bool InstanceMap::Reset(uint8 method, std::list<uint32>* globalResetSkipList) +bool InstanceMap::Reset(uint8 method, GuidList* globalResetSkipList) { if (method == INSTANCE_RESET_GLOBAL) { @@ -2865,7 +2925,7 @@ bool InstanceMap::Reset(uint8 method, std::list<uint32>* globalResetSkipList) for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) { // teleport players that are no longer bound (can be still bound if extended id) - if (!globalResetSkipList || std::find(globalResetSkipList->begin(), globalResetSkipList->end(), itr->GetSource()->GetGUIDLow()) == globalResetSkipList->end()) + if (!globalResetSkipList || std::find(globalResetSkipList->begin(), globalResetSkipList->end(), itr->GetSource()->GetGUID()) == globalResetSkipList->end()) itr->GetSource()->RepopAtGraveyard(); } @@ -2926,14 +2986,14 @@ void InstanceMap::PermBindAllPlayers() // players inside an instance cannot be bound to other instances // some players may already be permanently bound, in this case nothing happens - InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(player->GetGUIDLow(), save->GetMapId(), save->GetDifficulty()); + InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(player->GetGUID(), save->GetMapId(), save->GetDifficulty()); if (!bind || !bind->perm) { WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); data << uint32(0); player->GetSession()->SendPacket(&data); - sInstanceSaveMgr->PlayerBindToInstance(player->GetGUIDLow(), save, true, player); + sInstanceSaveMgr->PlayerBindToInstance(player->GetGUID(), save, true, player); } // Xinef: Difficulty change prevention @@ -2947,7 +3007,10 @@ void InstanceMap::UnloadAll() ASSERT(!HavePlayers()); if (m_resetAfterUnload == true) + { DeleteRespawnTimes(); + DeleteCorpseData(); + } Map::UnloadAll(); } @@ -3010,7 +3073,7 @@ bool BattlegroundMap::CanEnter(Player* player, bool loginCheck) { if (!loginCheck && player->GetMapRef().getTarget() == this) { - LOG_ERROR("server", "BGMap::CanEnter - player %u is already in map!", player->GetGUIDLow()); + LOG_ERROR("server", "BGMap::CanEnter - player %s is already in map!", player->GetGUID().ToString().c_str()); ABORT(); return false; } @@ -3058,43 +3121,38 @@ void BattlegroundMap::RemoveAllPlayers() player->TeleportTo(player->GetEntryPoint()); } -Player* Map::GetPlayer(uint64 guid) +Corpse* Map::GetCorpse(ObjectGuid const guid) { - return ObjectAccessor::GetObjectInMap(guid, this, (Player*)nullptr); + return _objectsStore.Find<Corpse>(guid); } -Creature* Map::GetCreature(uint64 guid) +Creature* Map::GetCreature(ObjectGuid const guid) { - return ObjectAccessor::GetObjectInMap(guid, this, (Creature*)nullptr); + return _objectsStore.Find<Creature>(guid); } -GameObject* Map::GetGameObject(uint64 guid) +GameObject* Map::GetGameObject(ObjectGuid const guid) { - return ObjectAccessor::GetObjectInMap(guid, this, (GameObject*)nullptr); + return _objectsStore.Find<GameObject>(guid); } -Transport* Map::GetTransport(uint64 guid) +Pet* Map::GetPet(ObjectGuid const guid) { - if (GUID_HIPART(guid) != HIGHGUID_MO_TRANSPORT && GUID_HIPART(guid) != HIGHGUID_TRANSPORT) - return nullptr; - - GameObject* go = GetGameObject(guid); - return go ? go->ToTransport() : nullptr; + return _objectsStore.Find<Pet>(guid); } -DynamicObject* Map::GetDynamicObject(uint64 guid) +Transport* Map::GetTransport(ObjectGuid guid) { - return ObjectAccessor::GetObjectInMap(guid, this, (DynamicObject*)nullptr); -} + if (guid.GetHigh() != HighGuid::Mo_Transport && guid.GetHigh() != HighGuid::Transport) + return nullptr; -Pet* Map::GetPet(uint64 guid) -{ - return ObjectAccessor::GetObjectInMap(guid, this, (Pet*)nullptr); + GameObject* go = GetGameObject(guid); + return go ? go->ToTransport() : nullptr; } -Corpse* Map::GetCorpse(uint64 guid) +DynamicObject* Map::GetDynamicObject(ObjectGuid guid) { - return ObjectAccessor::GetObjectInMap(guid, this, (Corpse*)nullptr); + return _objectsStore.Find<DynamicObject>(guid); } void Map::UpdateIteratorBack(Player* player) @@ -3103,12 +3161,12 @@ void Map::UpdateIteratorBack(Player* player) m_mapRefIter = m_mapRefIter->nocheck_prev(); } -void Map::SaveCreatureRespawnTime(uint32 dbGuid, time_t& respawnTime) +void Map::SaveCreatureRespawnTime(ObjectGuid::LowType spawnId, time_t& respawnTime) { if (!respawnTime) { // Delete only - RemoveCreatureRespawnTime(dbGuid); + RemoveCreatureRespawnTime(spawnId); return; } @@ -3116,33 +3174,33 @@ void Map::SaveCreatureRespawnTime(uint32 dbGuid, time_t& respawnTime) if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod()) respawnTime = now + YEAR; - _creatureRespawnTimes[dbGuid] = respawnTime; + _creatureRespawnTimes[spawnId] = respawnTime; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CREATURE_RESPAWN); - stmt->setUInt32(0, dbGuid); + stmt->setUInt32(0, spawnId); stmt->setUInt32(1, uint32(respawnTime)); stmt->setUInt16(2, GetId()); stmt->setUInt32(3, GetInstanceId()); CharacterDatabase.Execute(stmt); } -void Map::RemoveCreatureRespawnTime(uint32 dbGuid) +void Map::RemoveCreatureRespawnTime(ObjectGuid::LowType spawnId) { - _creatureRespawnTimes.erase(dbGuid); + _creatureRespawnTimes.erase(spawnId); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN); - stmt->setUInt32(0, dbGuid); + stmt->setUInt32(0, spawnId); stmt->setUInt16(1, GetId()); stmt->setUInt32(2, GetInstanceId()); CharacterDatabase.Execute(stmt); } -void Map::SaveGORespawnTime(uint32 dbGuid, time_t& respawnTime) +void Map::SaveGORespawnTime(ObjectGuid::LowType spawnId, time_t& respawnTime) { if (!respawnTime) { // Delete only - RemoveGORespawnTime(dbGuid); + RemoveGORespawnTime(spawnId); return; } @@ -3150,22 +3208,22 @@ void Map::SaveGORespawnTime(uint32 dbGuid, time_t& respawnTime) if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod()) respawnTime = now + YEAR; - _goRespawnTimes[dbGuid] = respawnTime; + _goRespawnTimes[spawnId] = respawnTime; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GO_RESPAWN); - stmt->setUInt32(0, dbGuid); + stmt->setUInt32(0, spawnId); stmt->setUInt32(1, uint32(respawnTime)); stmt->setUInt16(2, GetId()); stmt->setUInt32(3, GetInstanceId()); CharacterDatabase.Execute(stmt); } -void Map::RemoveGORespawnTime(uint32 dbGuid) +void Map::RemoveGORespawnTime(ObjectGuid::LowType spawnId) { - _goRespawnTimes.erase(dbGuid); + _goRespawnTimes.erase(spawnId); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN); - stmt->setUInt32(0, dbGuid); + stmt->setUInt32(0, spawnId); stmt->setUInt16(1, GetId()); stmt->setUInt32(2, GetInstanceId()); CharacterDatabase.Execute(stmt); @@ -3181,10 +3239,10 @@ void Map::LoadRespawnTimes() do { Field* fields = result->Fetch(); - uint32 loguid = fields[0].GetUInt32(); + ObjectGuid::LowType lowguid = fields[0].GetUInt32(); uint32 respawnTime = fields[1].GetUInt32(); - _creatureRespawnTimes[loguid] = time_t(respawnTime); + _creatureRespawnTimes[lowguid] = time_t(respawnTime); } while (result->NextRow()); } @@ -3196,10 +3254,10 @@ void Map::LoadRespawnTimes() do { Field* fields = result->Fetch(); - uint32 loguid = fields[0].GetUInt32(); + ObjectGuid::LowType lowguid = fields[0].GetUInt32(); uint32 respawnTime = fields[1].GetUInt32(); - _goRespawnTimes[loguid] = time_t(respawnTime); + _goRespawnTimes[lowguid] = time_t(respawnTime); } while (result->NextRow()); } } @@ -3299,7 +3357,8 @@ void Map::LogEncounterFinished(EncounterCreditType type, uint32 creditEntry) auraStr += buffer2; } - snprintf(buffer, 16384, "%s (guid: %u, acc: %u, ip: %s, guild: %u), xyz: (%.1f, %.1f, %.1f), auras: %s\n", p->GetName().c_str(), p->GetGUIDLow(), p->GetSession()->GetAccountId(), p->GetSession()->GetRemoteAddress().c_str(), p->GetGuildId(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), auraStr.c_str()); + snprintf(buffer, 16384, "%s (%s, acc: %u, ip: %s, guild: %u), xyz: (%.1f, %.1f, %.1f), auras: %s\n", + p->GetName().c_str(), p->GetGUID().ToString().c_str(), p->GetSession()->GetAccountId(), p->GetSession()->GetRemoteAddress().c_str(), p->GetGuildId(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), auraStr.c_str()); playersInfo += buffer; } CleanStringForMysqlQuery(playersInfo); @@ -3322,15 +3381,15 @@ void Map::AllTransportsRemovePassengers() (*itr)->RemovePassenger(*((*itr)->GetPassengers().begin()), true); } -time_t Map::GetLinkedRespawnTime(uint64 guid) const +time_t Map::GetLinkedRespawnTime(ObjectGuid guid) const { - uint64 linkedGuid = sObjectMgr->GetLinkedRespawnGuid(guid); - switch (GUID_HIPART(linkedGuid)) + ObjectGuid linkedGuid = sObjectMgr->GetLinkedRespawnGuid(guid); + switch (linkedGuid.GetHigh()) { - case HIGHGUID_UNIT: - return GetCreatureRespawnTime(GUID_LOPART(linkedGuid)); - case HIGHGUID_GAMEOBJECT: - return GetGORespawnTime(GUID_LOPART(linkedGuid)); + case HighGuid::Unit: + return GetCreatureRespawnTime(linkedGuid.GetCounter()); + case HighGuid::GameObject: + return GetGORespawnTime(linkedGuid.GetCounter()); default: break; } @@ -3338,6 +3397,114 @@ time_t Map::GetLinkedRespawnTime(uint64 guid) const return time_t(0); } +void Map::AddCorpse(Corpse* corpse) +{ + corpse->SetMap(this); + + _corpsesByCell[corpse->GetCellCoord().GetId()].insert(corpse); + if (corpse->GetType() != CORPSE_BONES) + _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse; + else + _corpseBones.insert(corpse); +} + +void Map::RemoveCorpse(Corpse* corpse) +{ + ASSERT(corpse); + + corpse->DestroyForNearbyPlayers(); + if (corpse->IsInGrid()) + RemoveFromMap(corpse, false); + else + { + corpse->RemoveFromWorld(); + corpse->ResetMap(); + } + + _corpsesByCell[corpse->GetCellCoord().GetId()].erase(corpse); + if (corpse->GetType() != CORPSE_BONES) + _corpsesByPlayer.erase(corpse->GetOwnerGUID()); + else + _corpseBones.erase(corpse); +} + +Corpse* Map::ConvertCorpseToBones(ObjectGuid const ownerGuid, bool insignia /*= false*/) +{ + Corpse* corpse = GetCorpseByPlayer(ownerGuid); + if (!corpse) + return nullptr; + + RemoveCorpse(corpse); + + // remove corpse from DB + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + corpse->DeleteFromDB(trans); + CharacterDatabase.CommitTransaction(trans); + + Corpse* bones = NULL; + + // create the bones only if the map and the grid is loaded at the corpse's location + // ignore bones creating option in case insignia + if ((insignia || + (IsBattlegroundOrArena() ? sWorld->getBoolConfig(CONFIG_DEATH_BONES_BG_OR_ARENA) : sWorld->getBoolConfig(CONFIG_DEATH_BONES_WORLD))) && + !IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY())) + { + // Create bones, don't change Corpse + bones = new Corpse(); + bones->Create(corpse->GetGUID().GetCounter()); + + for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type + bones->SetUInt32Value(i, corpse->GetUInt32Value(i)); + + bones->SetCellCoord(corpse->GetCellCoord()); + bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation()); + bones->SetPhaseMask(corpse->GetPhaseMask(), false); + + bones->SetUInt32Value(CORPSE_FIELD_FLAGS, CORPSE_FLAG_UNK2 | CORPSE_FLAG_BONES); + bones->SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid::Empty); + + for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i) + if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i)) + bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0); + + AddCorpse(bones); + + // add bones in grid store if grid loaded where corpse placed + AddToMap(bones); + } + + // all references to the corpse should be removed at this point + delete corpse; + + return bones; +} + +void Map::RemoveOldCorpses() +{ + time_t now = time(nullptr); + + std::vector<ObjectGuid> corpses; + corpses.reserve(_corpsesByPlayer.size()); + + for (auto const& p : _corpsesByPlayer) + if (p.second->IsExpired(now)) + corpses.push_back(p.first); + + for (ObjectGuid const& ownerGuid : corpses) + ConvertCorpseToBones(ownerGuid); + + std::vector<Corpse*> expiredBones; + for (Corpse* bones : _corpseBones) + if (bones->IsExpired(now)) + expiredBones.push_back(bones); + + for (Corpse* bones : expiredBones) + { + RemoveCorpse(bones); + delete bones; + } +} + void Map::SendZoneDynamicInfo(Player* player) { uint32 zoneId = GetZoneId(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); @@ -3630,3 +3797,47 @@ bool Map::CheckCollisionAndGetValidCoords(const WorldObject* source, float start return failOnCollision ? !collided : true; } + +void Map::LoadCorpseData() +{ + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSES); + stmt->setUInt32(0, GetId()); + stmt->setUInt32(1, GetInstanceId()); + + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ? + PreparedQueryResult result = CharacterDatabase.Query(stmt); + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + CorpseType type = CorpseType(fields[13].GetUInt8()); + uint32 guid = fields[16].GetUInt32(); + if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES) + { + LOG_ERROR("server", "Corpse (guid: %u) have wrong corpse type (%u), not loading.", guid, type); + continue; + } + + Corpse* corpse = new Corpse(type); + + if (!corpse->LoadCorpseFromDB(GenerateLowGuid<HighGuid::Corpse>(), fields)) + { + delete corpse; + continue; + } + + AddCorpse(corpse); + } while (result->NextRow()); +} + +void Map::DeleteCorpseData() +{ + // DELETE FROM corpse WHERE mapId = ? AND instanceId = ? + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSES_FROM_MAP); + stmt->setUInt32(0, GetId()); + stmt->setUInt32(1, GetInstanceId()); + CharacterDatabase.Execute(stmt); +} diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index dab380a4ff..f60d32071f 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -17,11 +17,13 @@ #include "GridRefManager.h" #include "MapRefManager.h" #include "ObjectDefines.h" +#include "ObjectGuid.h" #include "PathGenerator.h" #include "SharedDefines.h" #include "Timer.h" #include <bitset> #include <list> +#include <memory> #include <mutex> #include <shared_mutex> @@ -54,9 +56,9 @@ namespace acore struct ScriptAction { - uint64 sourceGUID; - uint64 targetGUID; - uint64 ownerGUID; // owner of source if source is item + ObjectGuid sourceGUID; + ObjectGuid targetGUID; + ObjectGuid ownerGUID; // owner of source if source is item ScriptInfo const* script; // pointer to static script data }; @@ -340,8 +342,6 @@ public: // pussywizard: movemaps, mmaps [[nodiscard]] std::shared_mutex& GetMMapLock() const { return *(const_cast<std::shared_mutex*>(&MMapLock)); } // pussywizard: - std::unordered_set<Object*> i_objectsToUpdate; - void BuildAndSendUpdateForObjects(); // definition in ObjectAccessor.cpp, below ObjectAccessor::Update, because it does the same for a map std::unordered_set<Unit*> i_objectsForDelayedVisibility; void HandleDelayedVisibility(); @@ -451,13 +451,39 @@ public: TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, Unit* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0); GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport = true); void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr); - Player* GetPlayer(uint64 guid); - Creature* GetCreature(uint64 guid); - GameObject* GetGameObject(uint64 guid); - Transport* GetTransport(uint64 guid); - DynamicObject* GetDynamicObject(uint64 guid); - Pet* GetPet(uint64 guid); - Corpse* GetCorpse(uint64 guid); + + Corpse* GetCorpse(ObjectGuid const guid); + Creature* GetCreature(ObjectGuid const guid); + GameObject* GetGameObject(ObjectGuid const guid); + Transport* GetTransport(ObjectGuid const guid); + DynamicObject* GetDynamicObject(ObjectGuid const guid); + Pet* GetPet(ObjectGuid const guid); + + MapStoredObjectTypesContainer& GetObjectsStore() { return _objectsStore; } + + typedef std::unordered_multimap<ObjectGuid::LowType, Creature*> CreatureBySpawnIdContainer; + CreatureBySpawnIdContainer& GetCreatureBySpawnIdStore() { return _creatureBySpawnIdStore; } + + typedef std::unordered_multimap<ObjectGuid::LowType, GameObject*> GameObjectBySpawnIdContainer; + GameObjectBySpawnIdContainer& GetGameObjectBySpawnIdStore() { return _gameobjectBySpawnIdStore; } + + std::unordered_set<Corpse*> const* GetCorpsesInCell(uint32 cellId) const + { + auto itr = _corpsesByCell.find(cellId); + if (itr != _corpsesByCell.end()) + return &itr->second; + + return nullptr; + } + + Corpse* GetCorpseByPlayer(ObjectGuid const& ownerGuid) const + { + auto itr = _corpsesByPlayer.find(ownerGuid); + if (itr != _corpsesByPlayer.end()) + return itr->second; + + return nullptr; + } MapInstanced* ToMapInstanced() { if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); else return nullptr; } [[nodiscard]] const MapInstanced* ToMapInstanced() const { if (Instanceable()) return (const MapInstanced*)((MapInstanced*)this); else return nullptr; } @@ -488,33 +514,40 @@ public: /* RESPAWN TIMES */ - [[nodiscard]] time_t GetLinkedRespawnTime(uint64 guid) const; - [[nodiscard]] time_t GetCreatureRespawnTime(uint32 dbGuid) const + [[nodiscard]] time_t GetLinkedRespawnTime(ObjectGuid guid) const; + [[nodiscard]] time_t GetCreatureRespawnTime(ObjectGuid::LowType dbGuid) const { - std::unordered_map<uint32 /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid); + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid); if (itr != _creatureRespawnTimes.end()) return itr->second; return time_t(0); } - [[nodiscard]] time_t GetGORespawnTime(uint32 dbGuid) const + [[nodiscard]] time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const { - std::unordered_map<uint32 /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid); + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid); if (itr != _goRespawnTimes.end()) return itr->second; return time_t(0); } - void SaveCreatureRespawnTime(uint32 dbGuid, time_t& respawnTime); - void RemoveCreatureRespawnTime(uint32 dbGuid); - void SaveGORespawnTime(uint32 dbGuid, time_t& respawnTime); - void RemoveGORespawnTime(uint32 dbGuid); + void SaveCreatureRespawnTime(ObjectGuid::LowType dbGuid, time_t& respawnTime); + void RemoveCreatureRespawnTime(ObjectGuid::LowType dbGuid); + void SaveGORespawnTime(ObjectGuid::LowType dbGuid, time_t& respawnTime); + void RemoveGORespawnTime(ObjectGuid::LowType dbGuid); void LoadRespawnTimes(); void DeleteRespawnTimes(); [[nodiscard]] time_t GetInstanceResetPeriod() const { return _instanceResetPeriod; } + void LoadCorpseData(); + void DeleteCorpseData(); + void AddCorpse(Corpse* corpse); + void RemoveCorpse(Corpse* corpse); + Corpse* ConvertCorpseToBones(ObjectGuid const ownerGuid, bool insignia = false); + void RemoveOldCorpses(); + static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId); void SendInitTransports(Player* player); @@ -539,6 +572,23 @@ public: DataMap CustomData; + template<HighGuid high> + inline ObjectGuid::LowType GenerateLowGuid() + { + static_assert(ObjectGuidTraits<high>::MapSpecific, "Only map specific guid can be generated in Map context"); + return GetGuidSequenceGenerator<high>().Generate(); + } + + void AddUpdateObject(Object* obj) + { + _updateObjects.insert(obj); + } + + void RemoveUpdateObject(Object* obj) + { + _updateObjects.erase(obj); + } + private: void LoadMapAndVMap(int gx, int gy); void LoadVMap(int gx, int gy); @@ -579,6 +629,8 @@ private: void UpdateActiveCells(const float& x, const float& y, const uint32 t_diff); + void SendObjectUpdates(); + protected: std::mutex Lock; std::mutex GridLock; @@ -611,7 +663,7 @@ private: Creature* _GetScriptCreature(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const; WorldObject* _GetScriptWorldObject(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const; void _ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const; - GameObject* _FindGameObject(WorldObject* pWorldObject, uint32 guid) const; + GameObject* _FindGameObject(WorldObject* pWorldObject, ObjectGuid::LowType guid) const; //used for fast base_map (e.g. MapInstanced class object) search for //InstanceMaps and BattlegroundMaps... @@ -658,11 +710,31 @@ private: m_activeNonPlayers.erase(obj); } - std::unordered_map<uint32 /*dbGUID*/, time_t> _creatureRespawnTimes; - std::unordered_map<uint32 /*dbGUID*/, time_t> _goRespawnTimes; + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t> _creatureRespawnTimes; + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t> _goRespawnTimes; ZoneDynamicInfoMap _zoneDynamicInfo; uint32 _defaultLight; + + template<HighGuid high> + inline ObjectGuidGeneratorBase& GetGuidSequenceGenerator() + { + auto itr = _guidGenerators.find(high); + if (itr == _guidGenerators.end()) + itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first; + + return *itr->second; + } + + std::map<HighGuid, std::unique_ptr<ObjectGuidGeneratorBase>> _guidGenerators; + MapStoredObjectTypesContainer _objectsStore; + CreatureBySpawnIdContainer _creatureBySpawnIdStore; + GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore; + std::unordered_map<uint32/*cellId*/, std::unordered_set<Corpse*>> _corpsesByCell; + std::unordered_map<ObjectGuid, Corpse*> _corpsesByPlayer; + std::unordered_set<Corpse*> _corpseBones; + + std::unordered_set<Object*> _updateObjects; }; enum InstanceResetMethod @@ -684,7 +756,7 @@ public: void AfterPlayerUnlinkFromMap() override; void Update(const uint32, const uint32, bool thread = true) override; void CreateInstanceScript(bool load, std::string data, uint32 completedEncounterMask); - bool Reset(uint8 method, std::list<uint32>* globalSkipList = nullptr); + bool Reset(uint8 method, GuidList* globalSkipList = nullptr); [[nodiscard]] uint32 GetScriptId() const { return i_script_id; } [[nodiscard]] std::string const& GetScriptName() const; [[nodiscard]] InstanceScript* GetInstanceScript() { return instance_data; } diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp index de2ddd0ae5..1499e0874d 100644 --- a/src/server/game/Maps/MapInstanced.cpp +++ b/src/server/game/Maps/MapInstanced.cpp @@ -202,6 +202,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, ASSERT(map->IsDungeon()); map->LoadRespawnTimes(); + map->LoadCorpseData(); if (save) map->CreateInstanceScript(true, save->GetInstanceData(), save->GetCompletedEncounterMask()); diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index dca34904a1..63dda6853c 100644 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -85,6 +85,7 @@ Map* MapManager::CreateBaseMap(uint32 id) { map = new Map(id, 0, REGULAR_DIFFICULTY); map->LoadRespawnTimes(); + map->LoadCorpseData(); } i_maps[id] = map; @@ -184,10 +185,10 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) if (!player->IsAlive()) { - if (Corpse* corpse = player->GetCorpse()) + if (player->HasCorpse()) { // let enter in ghost mode in instance that connected to inner instance with corpse - uint32 corpseMap = corpse->GetMapId(); + uint32 corpseMap = player->GetCorpseLocation().GetMapId(); do { if (corpseMap == mapid) @@ -209,8 +210,6 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("maps", "MAP: Player '%s' has corpse in instance '%s' and can enter.", player->GetName().c_str(), mapName); #endif - player->ResurrectPlayer(0.5f, false); - player->SpawnCorpseBones(); } else { @@ -234,7 +233,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) if (entry->IsDungeon() && (!group || !group->isLFGGroup() || !group->IsLfgRandomInstance())) { uint32 instaceIdToCheck = 0; - if (InstanceSave* save = sInstanceSaveMgr->PlayerGetInstanceSave(player->GetGUIDLow(), mapid, player->GetDifficulty(entry->IsRaid()))) + if (InstanceSave* save = sInstanceSaveMgr->PlayerGetInstanceSave(player->GetGUID(), mapid, player->GetDifficulty(entry->IsRaid()))) instaceIdToCheck = save->GetInstanceId(); // instaceIdToCheck can be 0 if save not found - means no bind so the instance is new @@ -281,8 +280,6 @@ void MapManager::Update(uint32 diff) if (m_updater.activated()) m_updater.wait(); - sObjectAccessor->ProcessDelayedCorpseActions(); - if (mapUpdateStep < 3) { for (iter = i_maps.begin(); iter != i_maps.end(); ++iter) @@ -296,8 +293,6 @@ void MapManager::Update(uint32 diff) ++mapUpdateStep; } - sObjectAccessor->Update(0); - if (mapUpdateStep == 3 && i_timer[3].Passed()) { mapUpdateStep = 0; diff --git a/src/server/game/Maps/MapManager.h b/src/server/game/Maps/MapManager.h index c9816c57b2..e8d3e52d0b 100644 --- a/src/server/game/Maps/MapManager.h +++ b/src/server/game/Maps/MapManager.h @@ -12,6 +12,8 @@ #include "Map.h" #include "MapUpdater.h" #include "Object.h" +#include "MapInstanced.h" + #include <mutex> class Transport; @@ -120,6 +122,12 @@ public: MapUpdater* GetMapUpdater() { return &m_updater; } + template<typename Worker> + void DoForAllMaps(Worker&& worker); + + template<typename Worker> + void DoForAllMapsWithMapId(uint32 mapId, Worker&& worker); + private: typedef std::unordered_map<uint32, Map*> MapMapType; typedef std::vector<bool> InstanceIds; @@ -140,6 +148,45 @@ private: MapUpdater m_updater; }; +template<typename Worker> +void MapManager::DoForAllMaps(Worker&& worker) +{ + std::lock_guard<std::mutex> guard(Lock); + + for (auto& mapPair : i_maps) + { + Map* map = mapPair.second; + if (MapInstanced* mapInstanced = map->ToMapInstanced()) + { + MapInstanced::InstancedMaps& instances = mapInstanced->GetInstancedMaps(); + for (auto& instancePair : instances) + worker(instancePair.second); + } + else + worker(map); + } +} + +template<typename Worker> +inline void MapManager::DoForAllMapsWithMapId(uint32 mapId, Worker&& worker) +{ + std::lock_guard<std::mutex> guard(Lock); + + auto itr = i_maps.find(mapId); + if (itr != i_maps.end()) + { + Map* map = itr->second; + if (MapInstanced* mapInstanced = map->ToMapInstanced()) + { + MapInstanced::InstancedMaps& instances = mapInstanced->GetInstancedMaps(); + for (auto& p : instances) + worker(p.second); + } + else + worker(map); + } +} + #define sMapMgr MapManager::instance() #endif diff --git a/src/server/game/Maps/TransportMgr.cpp b/src/server/game/Maps/TransportMgr.cpp index bae872d01b..9ef4de6bb1 100644 --- a/src/server/game/Maps/TransportMgr.cpp +++ b/src/server/game/Maps/TransportMgr.cpp @@ -344,7 +344,7 @@ void TransportMgr::AddPathNodeToTransport(uint32 transportEntry, uint32 timeSeg, animNode.Path[timeSeg] = node; } -MotionTransport* TransportMgr::CreateTransport(uint32 entry, uint32 guid /*= 0*/, Map* map /*= nullptr*/) +MotionTransport* TransportMgr::CreateTransport(uint32 entry, ObjectGuid::LowType guid /*= 0*/, Map* map /*= nullptr*/) { // instance case, execute GetGameObjectEntry hook if (map) @@ -377,7 +377,8 @@ MotionTransport* TransportMgr::CreateTransport(uint32 entry, uint32 guid /*= 0*/ float o = tInfo->keyFrames.begin()->InitialOrientation; // initialize the gameobject base - uint32 guidLow = guid ? guid : sObjectMgr->GenerateLowGuid(HIGHGUID_MO_TRANSPORT); + ObjectGuid::LowType guidLow = guid ? guid : sObjectMgr->GetGenerator<HighGuid::Mo_Transport>().Generate(); + if (!trans->CreateMoTrans(guidLow, entry, mapId, x, y, z, o, 255)) { delete trans; @@ -401,6 +402,7 @@ MotionTransport* TransportMgr::CreateTransport(uint32 entry, uint32 guid /*= 0*/ // xinef: transports are active so passengers can be relocated (grids must be loaded) trans->setActive(true); + HashMapHolder<MotionTransport>::Insert(trans); trans->GetMap()->AddToMap<MotionTransport>(trans); return trans; } @@ -422,7 +424,7 @@ void TransportMgr::SpawnContinentTransports() do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); if (TransportTemplate const* tInfo = GetTransportTemplate(entry)) diff --git a/src/server/game/Maps/TransportMgr.h b/src/server/game/Maps/TransportMgr.h index 847694abdb..08da087e7e 100644 --- a/src/server/game/Maps/TransportMgr.h +++ b/src/server/game/Maps/TransportMgr.h @@ -98,7 +98,7 @@ public: void LoadTransportTemplates(); // Creates a transport using given GameObject template entry - MotionTransport* CreateTransport(uint32 entry, uint32 guid = 0, Map* map = nullptr); + MotionTransport* CreateTransport(uint32 entry, ObjectGuid::LowType guid = 0, Map* map = nullptr); // Spawns all continent transports, used at core startup void SpawnContinentTransports(); diff --git a/src/server/game/Maps/ZoneScript.h b/src/server/game/Maps/ZoneScript.h index bf031e3fde..5420957dae 100644 --- a/src/server/game/Maps/ZoneScript.h +++ b/src/server/game/Maps/ZoneScript.h @@ -18,8 +18,8 @@ public: ZoneScript() {} virtual ~ZoneScript() {} - virtual uint32 GetCreatureEntry(uint32 /*guidlow*/, CreatureData const* data) { return data->id; } - virtual uint32 GetGameObjectEntry(uint32 /*guidlow*/, uint32 entry) { return entry; } + virtual uint32 GetCreatureEntry(ObjectGuid::LowType /*guidlow*/, CreatureData const* data) { return data->id; } + virtual uint32 GetGameObjectEntry(ObjectGuid::LowType /*guidlow*/, uint32 entry) { return entry; } virtual void OnCreatureCreate(Creature*) { } virtual void OnCreatureRemove(Creature*) { } @@ -30,6 +30,9 @@ public: virtual void OnUnitDeath(Unit*) { } //All-purpose data storage 64 bit + virtual ObjectGuid GetGuidData(uint32 /*DataId*/) const { return ObjectGuid::Empty; } + virtual void SetGuidData(uint32 /*DataId*/, ObjectGuid /*Value*/) {} + virtual uint64 GetData64(uint32 /*DataId*/) const { return 0; } virtual void SetData64(uint32 /*DataId*/, uint64 /*Value*/) {} diff --git a/src/server/game/Misc/AsyncAuctionListing.h b/src/server/game/Misc/AsyncAuctionListing.h index 6b810efd76..e09729397d 100644 --- a/src/server/game/Misc/AsyncAuctionListing.h +++ b/src/server/game/Misc/AsyncAuctionListing.h @@ -4,11 +4,12 @@ #include "Common.h" #include "EventProcessor.h" #include "WorldPacket.h" +#include "ObjectGuid.h" class AuctionListOwnerItemsDelayEvent : public BasicEvent { public: - AuctionListOwnerItemsDelayEvent(uint64 _creatureGuid, uint64 guid, bool o) : creatureGuid(_creatureGuid), playerguid(guid), owner(o) {} + AuctionListOwnerItemsDelayEvent(ObjectGuid _creatureGuid, ObjectGuid guid, bool o) : creatureGuid(_creatureGuid), playerguid(guid), owner(o) {} ~AuctionListOwnerItemsDelayEvent() override {} bool Execute(uint64 e_time, uint32 p_time) override; @@ -16,22 +17,22 @@ public: bool getOwner() { return owner; } private: - uint64 creatureGuid; - uint64 playerguid; + ObjectGuid creatureGuid; + ObjectGuid playerguid; bool owner; }; class AuctionListItemsDelayEvent { public: - AuctionListItemsDelayEvent(uint32 msTimer, uint64 playerguid, uint64 creatureguid, std::string searchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint8 usable, uint32 auctionSlotID, uint32 auctionMainCategory, uint32 auctionSubCategory, uint32 quality, uint8 getAll) : + AuctionListItemsDelayEvent(uint32 msTimer, ObjectGuid playerguid, ObjectGuid creatureguid, std::string searchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint8 usable, uint32 auctionSlotID, uint32 auctionMainCategory, uint32 auctionSubCategory, uint32 quality, uint8 getAll) : _msTimer(msTimer), _playerguid(playerguid), _creatureguid(creatureguid), _searchedname(searchedname), _listfrom(listfrom), _levelmin(levelmin), _levelmax(levelmax), _usable(usable), _auctionSlotID(auctionSlotID), _auctionMainCategory(auctionMainCategory), _auctionSubCategory(auctionSubCategory), _quality(quality), _getAll(getAll) { } bool Execute(); uint32 _msTimer; - uint64 _playerguid; - uint64 _creatureguid; + ObjectGuid _playerguid; + ObjectGuid _creatureguid; std::string _searchedname; uint32 _listfrom; uint8 _levelmin; diff --git a/src/server/game/Misc/BanManager.cpp b/src/server/game/Misc/BanManager.cpp index 2ebe2e6b13..fa346b3f7f 100644 --- a/src/server/game/Misc/BanManager.cpp +++ b/src/server/game/Misc/BanManager.cpp @@ -210,7 +210,7 @@ BanReturn BanManager::BanCharacter(std::string const& CharacterName, std::string { Player* target = ObjectAccessor::FindPlayerByName(CharacterName, false); uint32 DurationSecs = TimeStringToSecs(Duration); - uint32 TargetGUID = 0; + ObjectGuid TargetGUID; /// Pick a player to ban if not online if (!target) @@ -220,15 +220,15 @@ BanReturn BanManager::BanCharacter(std::string const& CharacterName, std::string return BAN_NOTFOUND; } else - TargetGUID = target->GetGUIDLow(); + TargetGUID = target->GetGUID(); // make sure there is only one active ban PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_BAN); - stmt->setUInt32(0, TargetGUID); + stmt->setUInt32(0, TargetGUID.GetCounter()); CharacterDatabase.Execute(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_BAN); - stmt->setUInt32(0, TargetGUID); + stmt->setUInt32(0, TargetGUID.GetCounter()); stmt->setUInt32(1, DurationSecs); stmt->setString(2, Author); stmt->setString(3, Reason); @@ -297,19 +297,19 @@ bool BanManager::RemoveBanIP(std::string const& IP) bool BanManager::RemoveBanCharacter(std::string const& CharacterName) { Player* pBanned = ObjectAccessor::FindPlayerByName(CharacterName, false); - uint32 guid = 0; + ObjectGuid guid; /// Pick a player to ban if not online if (!pBanned) guid = sWorld->GetGlobalPlayerGUID(CharacterName); else - guid = pBanned->GetGUIDLow(); + guid = pBanned->GetGUID(); if (!guid) return false; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_BAN); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, guid.GetCounter()); CharacterDatabase.Execute(stmt); return true; } diff --git a/src/server/game/Misc/WhoListCache.cpp b/src/server/game/Misc/WhoListCache.cpp index e39eccf466..f9e9737564 100644 --- a/src/server/game/Misc/WhoListCache.cpp +++ b/src/server/game/Misc/WhoListCache.cpp @@ -13,7 +13,7 @@ void WhoListCacheMgr::Update() m_whoOpcodeList.reserve(sWorld->GetPlayerCount() + 1); std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock()); - HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers(); + HashMapHolder<Player>::MapType const& m = ObjectAccessor::GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { if (!itr->second->FindMap() || itr->second->GetSession()->PlayerLoading()) @@ -43,4 +43,4 @@ void WhoListCacheMgr::Update() m_whoOpcodeList.push_back( WhoListPlayerInfo(itr->second->GetTeamId(), itr->second->GetSession()->GetSecurity(), itr->second->getLevel(), itr->second->getClass(), itr->second->getRace(), (itr->second->IsSpectator() ? 4395 /*Dalaran*/ : itr->second->GetZoneId()), itr->second->getGender(), wpname, wgname, aname, pname, gname) ); } -}
\ No newline at end of file +} diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 2ac64f3eb4..8a65ef6178 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -3479,8 +3479,8 @@ enum GroupJoinBattlegroundResult ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND = -8, // You can't do that in a battleground. ERR_BATTLEGROUND_JOIN_XP_GAIN = -9, // wtf, doesn't exist in client... ERR_BATTLEGROUND_JOIN_RANGE_INDEX = -10, // Cannot join the queue unless all members of your party are in the same battleground level range. - ERR_BATTLEGROUND_JOIN_TIMED_OUT = -11, // %s was unavailable to join the queue. (uint64 guid exist in client cache) - ERR_BATTLEGROUND_JOIN_FAILED = -12, // Join as a group failed (uint64 guid doesn't exist in client cache) + ERR_BATTLEGROUND_JOIN_TIMED_OUT = -11, // %s was unavailable to join the queue. (ObjectGuid guid exist in client cache) + ERR_BATTLEGROUND_JOIN_FAILED = -12, // Join as a group failed (ObjectGuid guid doesn't exist in client cache) ERR_LFG_CANT_USE_BATTLEGROUND = -13, // You cannot queue for a battleground or arena while using the dungeon system. ERR_IN_RANDOM_BG = -14, // Can't do that while in a Random Battleground queue. ERR_IN_NON_RANDOM_BG = -15 // Can't queue for Random Battleground while in another Battleground queue. diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index bf7d35c1c5..b1e6b33a0f 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -241,7 +241,7 @@ void MotionMaster::MoveRandom(float wanderDistance) if (_owner->GetTypeId() == TYPEID_UNIT) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (GUID: %u) start moving random", _owner->GetGUIDLow()); + LOG_DEBUG("server", "Creature (%s) start moving random", _owner->GetGUID().ToString().c_str()); #endif Mutate(new RandomMovementGenerator<Creature>(wanderDistance), MOTION_SLOT_IDLE); } @@ -254,7 +254,7 @@ void MotionMaster::MoveTargetedHome() if (_owner->GetTypeId() == TYPEID_UNIT && !_owner->ToCreature()->GetCharmerOrOwnerGUID()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (Entry: %u GUID: %u) targeted home", _owner->GetEntry(), _owner->GetGUIDLow()); + LOG_DEBUG("server", "Creature (%s) targeted home", _owner->GetGUID().ToString().c_str()); #endif Mutate(new HomeMovementGenerator<Creature>(), MOTION_SLOT_ACTIVE); } @@ -266,20 +266,20 @@ void MotionMaster::MoveTargetedHome() return; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Pet or controlled creature (Entry: %u GUID: %u) targeting home", _owner->GetEntry(), _owner->GetGUIDLow()); + LOG_DEBUG("server", "Pet or controlled creature (%s) targeting home", _owner->GetGUID().ToString().c_str()); #endif Unit* target = _owner->ToCreature()->GetCharmerOrOwner(); if (target) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Following %s (GUID: %u)", target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : ((Creature*)target)->GetDBTableGUIDLow()); + LOG_DEBUG("server", "Following %s (%s)", target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetGUID().ToString().c_str()); #endif Mutate(new FollowMovementGenerator<Creature>(target, PET_FOLLOW_DIST, _owner->GetFollowAngle()), MOTION_SLOT_ACTIVE); } } else { - LOG_ERROR("server", "Player (GUID: %u) attempt targeted home", _owner->GetGUIDLow()); + LOG_ERROR("server", "Player (%s) attempt targeted home", _owner->GetGUID().ToString().c_str()); } } @@ -292,14 +292,14 @@ void MotionMaster::MoveConfused() if (_owner->GetTypeId() == TYPEID_PLAYER) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player (GUID: %u) move confused", _owner->GetGUIDLow()); + LOG_DEBUG("server", "Player (%s) move confused", _owner->GetGUID().ToString().c_str()); #endif Mutate(new ConfusedMovementGenerator<Player>(), MOTION_SLOT_CONTROLLED); } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (Entry: %u GUID: %u) move confused", _owner->GetEntry(), _owner->GetGUIDLow()); + LOG_DEBUG("server", "Creature (%s) move confused", _owner->GetGUID().ToString().c_str()); #endif Mutate(new ConfusedMovementGenerator<Creature>(), MOTION_SLOT_CONTROLLED); } @@ -316,20 +316,16 @@ void MotionMaster::MoveChase(Unit* target, std::optional<ChaseRange> dist, std: if (_owner->GetTypeId() == TYPEID_PLAYER) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player (GUID: %u) chase to %s (GUID: %u)", - _owner->GetGUIDLow(), - target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", - target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow()); + LOG_DEBUG("server", "Player (%s) chase to %s (%s)", + _owner->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetGUID().ToString().c_str()); #endif Mutate(new ChaseMovementGenerator<Player>(target, dist, angle), MOTION_SLOT_ACTIVE); } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (Entry: %u GUID: %u) chase to %s (GUID: %u)", - _owner->GetEntry(), _owner->GetGUIDLow(), - target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", - target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow()); + LOG_DEBUG("server", "Creature (%s) chase to %s (%s)", + _owner->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetGUID().ToString().c_str()); #endif Mutate(new ChaseMovementGenerator<Creature>(target, dist, angle), MOTION_SLOT_ACTIVE); } @@ -394,19 +390,16 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlo if (_owner->GetTypeId() == TYPEID_PLAYER) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player (GUID: %u) follow to %s (GUID: %u)", _owner->GetGUIDLow(), - target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", - target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow()); + LOG_DEBUG("server", "Player (%s) follow to %s (%s)", + _owner->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetGUID().ToString().c_str()); #endif Mutate(new FollowMovementGenerator<Player>(target, dist, angle), slot); } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (Entry: %u GUID: %u) follow to %s (GUID: %u)", - _owner->GetEntry(), _owner->GetGUIDLow(), - target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", - target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow()); + LOG_DEBUG("server", "Creature (%s) follow to %s (%s)", + _owner->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetGUID().ToString().c_str()); #endif Mutate(new FollowMovementGenerator<Creature>(target, dist, angle), slot); } @@ -421,15 +414,14 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generate if (_owner->GetTypeId() == TYPEID_PLAYER) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player (GUID: %u) targeted point (Id: %u X: %f Y: %f Z: %f)", _owner->GetGUIDLow(), id, x, y, z); + LOG_DEBUG("server", "Player (%s) targeted point (Id: %u X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), id, x, y, z); #endif Mutate(new PointMovementGenerator<Player>(id, x, y, z, 0.0f, orientation, nullptr, generatePath, forceDestination), slot); } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (Entry: %u GUID: %u) targeted point (ID: %u X: %f Y: %f Z: %f)", - _owner->GetEntry(), _owner->GetGUIDLow(), id, x, y, z); + LOG_DEBUG("server", "Creature (%s) targeted point (ID: %u X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), id, x, y, z); #endif Mutate(new PointMovementGenerator<Creature>(id, x, y, z, 0.0f, orientation, nullptr, generatePath, forceDestination), slot); } @@ -558,7 +550,7 @@ void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ) void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id, Unit const* target) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Unit (GUID: %u) jump to point (X: %f Y: %f Z: %f)", _owner->GetGUIDLow(), x, y, z); + LOG_DEBUG("server", "Unit (%s) jump to point (X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z); #endif if (speedXY <= 0.1f) @@ -632,15 +624,14 @@ void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id, if (_owner->GetTypeId() == TYPEID_PLAYER) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player (GUID: %u) charge point (X: %f Y: %f Z: %f)", _owner->GetGUIDLow(), x, y, z); + LOG_DEBUG("server", "Player (%s) charge point (X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z); #endif Mutate(new PointMovementGenerator<Player>(id, x, y, z, speed, orientation, path, generatePath, generatePath), MOTION_SLOT_CONTROLLED); } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (Entry: %u GUID: %u) charge point (X: %f Y: %f Z: %f)", - _owner->GetEntry(), _owner->GetGUIDLow(), x, y, z); + LOG_DEBUG("server", "Creature (%s) charge point (X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z); #endif Mutate(new PointMovementGenerator<Creature>(id, x, y, z, speed, orientation, path, generatePath, generatePath), MOTION_SLOT_CONTROLLED); } @@ -654,13 +645,12 @@ void MotionMaster::MoveSeekAssistance(float x, float y, float z) if (_owner->GetTypeId() == TYPEID_PLAYER) { - LOG_ERROR("server", "Player (GUID: %u) attempt to seek assistance", _owner->GetGUIDLow()); + LOG_ERROR("server", "Player (%s) attempt to seek assistance", _owner->GetGUID().ToString().c_str()); } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (Entry: %u GUID: %u) seek assistance (X: %f Y: %f Z: %f)", - _owner->GetEntry(), _owner->GetGUIDLow(), x, y, z); + LOG_DEBUG("server", "Creature (%s) seek assistance (X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z); #endif _owner->AttackStop(); _owner->CastStop(0, false); @@ -677,13 +667,12 @@ void MotionMaster::MoveSeekAssistanceDistract(uint32 time) if (_owner->GetTypeId() == TYPEID_PLAYER) { - LOG_ERROR("server", "Player (GUID: %u) attempt to call distract after assistance", _owner->GetGUIDLow()); + LOG_ERROR("server", "Player (%s) attempt to call distract after assistance", _owner->GetGUID().ToString().c_str()); } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (Entry: %u GUID: %u) is distracted after assistance call (Time: %u)", - _owner->GetEntry(), _owner->GetGUIDLow(), time); + LOG_DEBUG("server", "Creature (%s) is distracted after assistance call (Time: %u)", _owner->GetGUID().ToString().c_str(), time); #endif Mutate(new AssistanceDistractMovementGenerator(time), MOTION_SLOT_ACTIVE); } @@ -701,20 +690,16 @@ void MotionMaster::MoveFleeing(Unit* enemy, uint32 time) if (_owner->GetTypeId() == TYPEID_PLAYER) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player (GUID: %u) flee from %s (GUID: %u)", _owner->GetGUIDLow(), - enemy->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", - enemy->GetTypeId() == TYPEID_PLAYER ? enemy->GetGUIDLow() : enemy->ToCreature()->GetDBTableGUIDLow()); + LOG_DEBUG("server", "Player (%s) flee from %s (%s)", + _owner->GetGUID().ToString().c_str(), enemy->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", enemy->GetGUID().ToString().c_str()); #endif Mutate(new FleeingMovementGenerator<Player>(enemy->GetGUID()), MOTION_SLOT_CONTROLLED); } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (Entry: %u GUID: %u) flee from %s (GUID: %u)%s", - _owner->GetEntry(), _owner->GetGUIDLow(), - enemy->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", - enemy->GetTypeId() == TYPEID_PLAYER ? enemy->GetGUIDLow() : enemy->ToCreature()->GetDBTableGUIDLow(), - time ? " for a limited time" : ""); + LOG_DEBUG("server", "Creature (%s) flee from %s (%s) %s", + _owner->GetGUID().ToString().c_str(), enemy->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", enemy->GetGUID().ToString().c_str(), time ? " for a limited time" : ""); #endif if (time) Mutate(new TimedFleeingMovementGenerator(enemy->GetGUID(), time), MOTION_SLOT_CONTROLLED); @@ -744,8 +729,7 @@ void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode) } else { - LOG_ERROR("server", "Creature (Entry: %u GUID: %u) attempt taxi to (Path %u node %u)", - _owner->GetEntry(), _owner->GetGUIDLow(), path, pathnode); + LOG_ERROR("server", "Creature (%s) attempt taxi to (Path %u node %u)", _owner->GetGUID().ToString().c_str(), path, pathnode); } } @@ -761,15 +745,14 @@ void MotionMaster::MoveDistract(uint32 timer) /*if (_owner->GetTypeId() == TYPEID_PLAYER) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Player (GUID: %u) distracted (timer: %u)", _owner->GetGUIDLow(), timer); + LOG_DEBUG("server", "Player (%s) distracted (timer: %u)", _owner->GetGUID().ToString().c_str(), timer); #endif } else { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "Creature (Entry: %u GUID: %u) (timer: %u)", + LOG_DEBUG("server", "Creature (%s) (timer: %u)", _owner->GetGUID().ToString().c_str(), timer); #endif - _owner->GetEntry(), _owner->GetGUIDLow(), timer); }*/ DistractMovementGenerator* mgen = new DistractMovementGenerator(timer); @@ -831,9 +814,8 @@ void MotionMaster::MovePath(uint32 path_id, bool repeatable) Mutate(new WaypointMovementGenerator<Creature>(path_id, repeatable), MOTION_SLOT_IDLE); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "%s (GUID: %u) start moving over path(Id:%u, repeatable: %s)", - _owner->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature", - _owner->GetGUIDLow(), path_id, repeatable ? "YES" : "NO"); + LOG_DEBUG("server", "%s (%s) start moving over path(Id:%u, repeatable: %s)", + _owner->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature", _owner->GetGUID().ToString().c_str(), path_id, repeatable ? "YES" : "NO"); #endif } diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h index bf2d75a577..8cc69425e5 100644 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h @@ -13,7 +13,7 @@ template<class T> class FleeingMovementGenerator : public MovementGeneratorMedium< T, FleeingMovementGenerator<T> > { public: - FleeingMovementGenerator(uint64 fright) : i_frightGUID(fright), i_nextCheckTime(0) {} + FleeingMovementGenerator(ObjectGuid fright) : i_frightGUID(fright), i_nextCheckTime(0) {} void DoInitialize(T*); void DoFinalize(T*); @@ -38,14 +38,14 @@ private: float i_last_distance_from_caster; float i_to_distance_from_caster; float i_cur_angle; - uint64 i_frightGUID; + ObjectGuid i_frightGUID; TimeTracker i_nextCheckTime; }; class TimedFleeingMovementGenerator : public FleeingMovementGenerator<Creature> { public: - TimedFleeingMovementGenerator(uint64 fright, uint32 time) : + TimedFleeingMovementGenerator(ObjectGuid fright, uint32 time) : FleeingMovementGenerator<Creature>(fright), i_totalFleeTime(time) {} diff --git a/src/server/game/Movement/MovementGenerators/PathGenerator.cpp b/src/server/game/Movement/MovementGenerators/PathGenerator.cpp index 8b1c7d38a6..861076455e 100644 --- a/src/server/game/Movement/MovementGenerators/PathGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PathGenerator.cpp @@ -369,7 +369,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con // this is probably an error state, but we'll leave it // and hopefully recover on the next Update // we still need to copy our preffix - LOG_ERROR("server", "PathGenerator::BuildPolyPath: Path Build failed %u", _source->GetGUIDLow()); + LOG_ERROR("server", "PathGenerator::BuildPolyPath: Path Build failed %s", _source->GetGUID().ToString().c_str()); } // new path = prefix + suffix - overlap @@ -470,7 +470,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con if (!_polyLength || dtStatusFailed(dtResult)) { // only happens if we passed bad data to findPath(), or navmesh is messed up - LOG_ERROR("server", "PathGenerator::BuildPolyPath: %u Path Build failed: 0 length path", _source->GetGUIDLow()); + LOG_ERROR("server", "PathGenerator::BuildPolyPath: %s Path Build failed: 0 length path", _source->GetGUID().ToString().c_str()); BuildShortcut(); _type = PATHFIND_NOPATH; return; @@ -479,7 +479,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con if (!_polyLength) { - LOG_ERROR("server", "PathGenerator::BuildPolyPath: %u Path Build failed: 0 length path", _source->GetGUIDLow()); + LOG_ERROR("server", "PathGenerator::BuildPolyPath: %s Path Build failed: 0 length path", _source->GetGUID().ToString().c_str()); BuildShortcut(); _type = PATHFIND_NOPATH; return; @@ -509,7 +509,7 @@ void PathGenerator::BuildPointPath(const float* startPoint, const float* endPoin if (_useRaycast) { // _straightLine uses raycast and it currently doesn't support building a point path, only a 2-point path with start and hitpoint/end is returned - LOG_ERROR("server", "PathGenerator::BuildPointPath() called with _useRaycast for unit %u", _source->GetGUIDLow()); + LOG_ERROR("server", "PathGenerator::BuildPointPath() called with _useRaycast for unit %s", _source->GetGUID().ToString().c_str()); BuildShortcut(); _type = PATHFIND_NOPATH; return; @@ -893,7 +893,8 @@ dtStatus PathGenerator::FindSmoothPath(float const* startPos, float const* endPo npolys = FixupCorridor(polys, npolys, MAX_PATH_LENGTH, visited, nvisited); if (dtStatusFailed(_navMeshQuery->getPolyHeight(polys[0], result, &result[1]))) - LOG_DEBUG("maps", "PathGenerator::FindSmoothPath: Cannot find height at position X: %f Y: %f Z: %f for %u", result[2], result[0], result[1], _source->GetGUIDLow()); + LOG_DEBUG("maps", "PathGenerator::FindSmoothPath: Cannot find height at position X: %f Y: %f Z: %f for %s", + result[2], result[0], result[1], _source->GetGUID().ToString().c_str()); result[1] += 0.5f; dtVcopy(iterPos, result); diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp index 967f46c316..39ac661cd9 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp @@ -202,7 +202,7 @@ void RandomMovementGenerator<Creature>::DoInitialize(Creature* creature) if (!_wanderDistance) _wanderDistance = creature->GetWanderDistance(); - _nextMoveTime.Reset(creature->GetDBTableGUIDLow() && creature->GetWanderDistance() == _wanderDistance ? urand(1, 5000) : 0); + _nextMoveTime.Reset(creature->GetSpawnId() && creature->GetWanderDistance() == _wanderDistance ? urand(1, 5000) : 0); _wanderDistance = std::max((creature->GetWanderDistance() == _wanderDistance && creature->GetInstanceId() == 0) ? (creature->CanFly() ? MIN_WANDER_DISTANCE_AIR : MIN_WANDER_DISTANCE_GROUND) : 0.0f, _wanderDistance); if (G3D::fuzzyEq(_initialPosition.GetExactDist2d(0.0f, 0.0f), 0.0f)) diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index 529beb24a5..e088885305 100644 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -222,7 +222,7 @@ void ChaseMovementGenerator<T>::MovementInform(T* owner) // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle if (CreatureAI* AI = owner->ToCreature()->AI()) - AI->MovementInform(CHASE_MOTION_TYPE, i_target.getTarget()->GetGUIDLow()); + AI->MovementInform(CHASE_MOTION_TYPE, i_target.getTarget()->GetGUID().GetCounter()); } //-----------------------------------------------// @@ -365,7 +365,7 @@ void FollowMovementGenerator<Creature>::_updateSpeed(Creature* owner) { // pet only sync speed with owner /// Make sure we are not in the process of a map change (IsInWorld) - if (!IS_PLAYER_GUID(owner->GetOwnerGUID()) || !owner->IsInWorld() || !i_target.isValid() || i_target->GetGUID() != owner->GetOwnerGUID()) + if (!owner->GetOwnerGUID().IsPlayer() || !owner->IsInWorld() || !i_target.isValid() || i_target->GetGUID() != owner->GetOwnerGUID()) return; owner->UpdateSpeed(MOVE_RUN, true); @@ -402,7 +402,7 @@ void FollowMovementGenerator<T>::MovementInform(T* owner) // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle if (CreatureAI* AI = owner->ToCreature()->AI()) - AI->MovementInform(FOLLOW_MOTION_TYPE, i_target.getTarget()->GetGUIDLow()); + AI->MovementInform(FOLLOW_MOTION_TYPE, i_target.getTarget()->GetGUID().GetCounter()); } //-----------------------------------------------// diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index fb158d26af..f66236562d 100644 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -27,7 +27,8 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature* creature) if (!i_path) { // No movement found for entry - LOG_ERROR("sql.sql", "WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path id: %u", creature->GetName().c_str(), creature->GetEntry(), creature->GetGUIDLow(), path_id); + LOG_ERROR("sql.sql", "WaypointMovementGenerator::LoadPath: creature %s (%s) doesn't have waypoint path id: %u", + creature->GetName().c_str(), creature->GetGUID().ToString().c_str(), path_id); return; } @@ -65,7 +66,8 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature* creature) if (i_path->at(i_currentNode)->event_id && urand(0, 99) < i_path->at(i_currentNode)->event_chance) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("maps.script", "Creature movement start script %u at point %u for " UI64FMTD ".", i_path->at(i_currentNode)->event_id, i_currentNode, creature->GetGUID()); + LOG_DEBUG("maps.script", "Creature movement start script %u at point %u for %s.", + i_path->at(i_currentNode)->event_id, i_currentNode, creature->GetGUID().ToString().c_str()); #endif creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE); creature->GetMap()->ScriptsStart(sWaypointScripts, i_path->at(i_currentNode)->event_id, creature, nullptr); @@ -363,7 +365,8 @@ bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/) { if (i_currentNode >= i_path.size()) { - LOG_INFO("misc", "TAXI NODE WAS GREATER THAN PATH SIZE, GUID: %u, POINTID: %u, NODESIZE: %lu, CURRENT: %u", player->GetGUIDLow(), pointId, i_path.size(), i_currentNode); + LOG_INFO("misc", "TAXI NODE WAS GREATER THAN PATH SIZE, %s, POINTID: %u, NODESIZE: %lu, CURRENT: %u", + player->GetGUID().ToString().c_str(), pointId, i_path.size(), i_currentNode); player->CleanupAfterTaxiFlight(); return false; } diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index a44efd65af..cf4416c508 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -191,7 +191,7 @@ namespace Movement #define CHECK(exp) \ if (!(exp))\ {\ - LOG_ERROR("server", "MoveSplineInitArgs::Validate: expression '%s' failed for GUID: %u Entry: %u", #exp, unit->GetTypeId() == TYPEID_PLAYER ? unit->GetGUIDLow() : unit->ToCreature()->GetDBTableGUIDLow(), unit->GetEntry());\ + LOG_ERROR("server", "MoveSplineInitArgs::Validate: expression '%s' failed for GUID: %u Entry: %u", #exp, unit->GetTypeId() == TYPEID_PLAYER ? unit->GetGUID().GetCounter() : unit->ToCreature()->GetSpawnId(), unit->GetEntry());\ return false;\ } CHECK(path.size() > 1); diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index f0c48b6001..d7359e0440 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -119,11 +119,11 @@ namespace Movement move_spline.Initialize(args); WorldPacket data(SMSG_MONSTER_MOVE, 64); - data.append(unit->GetPackGUID()); + data << unit->GetPackGUID(); if (transport) { data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT); - data.appendPackGUID(unit->GetTransGUID()); + data << unit->GetTransGUID().WriteAsPacked(); data << int8(unit->GetTransSeat()); } @@ -170,11 +170,11 @@ namespace Movement move_spline.Initialize(args); WorldPacket data(SMSG_MONSTER_MOVE, 64); - data.append(unit->GetPackGUID()); + data << unit->GetPackGUID(); if (transport) { data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT); - data.appendPackGUID(unit->GetTransGUID()); + data << unit->GetTransGUID().WriteAsPacked(); data << int8(unit->GetTransSeat()); } @@ -194,7 +194,7 @@ namespace Movement void MoveSplineInit::SetFacing(const Unit* target) { args.flags.EnableFacingTarget(); - args.facing.target = target->GetGUID(); + args.facing.target = target->GetGUID().GetRawValue(); } void MoveSplineInit::SetFacing(float angle) diff --git a/src/server/game/Movement/Spline/MoveSplineInitArgs.h b/src/server/game/Movement/Spline/MoveSplineInitArgs.h index f087da3a4d..bc4c4ad406 100644 --- a/src/server/game/Movement/Spline/MoveSplineInitArgs.h +++ b/src/server/game/Movement/Spline/MoveSplineInitArgs.h @@ -22,8 +22,8 @@ namespace Movement { float x, y, z; } f; - uint64 target; - float angle; + uint64 target; + float angle; FacingInfo(float o) : angle(o) {} FacingInfo(uint64 t) : target(t) {} diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index 9bfb4913a3..f9f98c9de1 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -17,7 +17,7 @@ #include "WorldPacket.h" OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP* pvp): - m_capturePointGUID(0), m_capturePoint(nullptr), m_maxValue(0.0f), m_minValue(0.0f), m_maxSpeed(0), + m_capturePointSpawnId(0), m_capturePoint(nullptr), m_maxValue(0.0f), m_minValue(0.0f), m_maxSpeed(0), m_value(0), m_team(TEAM_NEUTRAL), m_OldState(OBJECTIVESTATE_NEUTRAL), m_State(OBJECTIVESTATE_NEUTRAL), m_neutralValuePct(0), m_PvP(pvp) { } @@ -53,7 +53,7 @@ void OPvPCapturePoint::SendChangePhase() SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); } -void OPvPCapturePoint::AddGO(uint32 type, uint32 guid, uint32 entry) +void OPvPCapturePoint::AddGO(uint32 type, ObjectGuid::LowType guid, uint32 entry) { if (!entry) { @@ -62,11 +62,11 @@ void OPvPCapturePoint::AddGO(uint32 type, uint32 guid, uint32 entry) return; entry = data->id; } - m_Objects[type] = MAKE_NEW_GUID(guid, entry, HIGHGUID_GAMEOBJECT); + m_Objects[type] = guid; m_ObjectTypes[m_Objects[type]] = type; } -void OPvPCapturePoint::AddCre(uint32 type, uint32 guid, uint32 entry) +void OPvPCapturePoint::AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry) { if (!entry) { @@ -75,13 +75,13 @@ void OPvPCapturePoint::AddCre(uint32 type, uint32 guid, uint32 entry) return; entry = data->id; } - m_Creatures[type] = MAKE_NEW_GUID(guid, entry, HIGHGUID_UNIT); + m_Creatures[type] = guid; m_CreatureTypes[m_Creatures[type]] = type; } bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3) { - if (uint32 guid = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3)) + if (ObjectGuid::LowType guid = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3)) { AddGO(type, guid, entry); return true; @@ -92,7 +92,7 @@ bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay) { - if (uint32 guid = sObjectMgr->AddCreData(entry, map, x, y, z, o, spawntimedelay)) + if (ObjectGuid::LowType guid = sObjectMgr->AddCreData(entry, map, x, y, z, o, spawntimedelay)) { AddCre(type, guid, entry); return true; @@ -115,10 +115,9 @@ bool OPvPCapturePoint::SetCapturePointData(uint32 entry, uint32 map, float x, fl return false; } - uint32 lowguid = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3); - if (!lowguid) + m_capturePointSpawnId = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3); + if (!m_capturePointSpawnId) return false; - m_capturePointGUID = MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT); // get the needed values from goinfo m_maxValue = (float)goinfo->capturePoint.maxTime; @@ -130,7 +129,8 @@ bool OPvPCapturePoint::SetCapturePointData(uint32 entry, uint32 map, float x, fl bool OPvPCapturePoint::DelCreature(uint32 type) { - if (!m_Creatures[type]) + ObjectGuid::LowType spawnId = m_Creatures[type]; + if (!spawnId) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("outdoorpvp", "opvp creature type %u was already deleted", type); @@ -138,20 +138,20 @@ bool OPvPCapturePoint::DelCreature(uint32 type) return false; } - Creature* cr = HashMapHolder<Creature>::Find(m_Creatures[type]); - if (!cr) + auto bounds = m_PvP->GetMap()->GetCreatureBySpawnIdStore().equal_range(spawnId); + for (auto itr = bounds.first; itr != bounds.second;) { // can happen when closing the core - m_Creatures[type] = 0; - return false; + Creature* c = itr->second; + ++itr; + // Don't save respawn time + c->SetRespawnTime(0); + c->RemoveCorpse(); + c->AddObjectToRemoveList(); } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) LOG_DEBUG("outdoorpvp", "deleting opvp creature type %u", type); #endif - uint32 guid = cr->GetDBTableGUIDLow(); - // Don't save respawn time - cr->SetRespawnTime(0); - cr->RemoveCorpse(); // explicit removal from map // beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted // so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed @@ -159,13 +159,12 @@ bool OPvPCapturePoint::DelCreature(uint32 type) // map->Remove(cr, false); // delete respawn time for this creature PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN); - stmt->setUInt32(0, guid); - stmt->setUInt16(1, cr->GetMapId()); + stmt->setUInt32(0, spawnId); + stmt->setUInt16(1, m_PvP->GetMap()->GetId()); stmt->setUInt32(2, 0); // instance id, always 0 for world maps CharacterDatabase.Execute(stmt); - cr->AddObjectToRemoveList(); - sObjectMgr->DeleteCreatureData(guid); + sObjectMgr->DeleteCreatureData(spawnId); m_CreatureTypes[m_Creatures[type]] = 0; m_Creatures[type] = 0; return true; @@ -173,19 +172,21 @@ bool OPvPCapturePoint::DelCreature(uint32 type) bool OPvPCapturePoint::DelObject(uint32 type) { - if (!m_Objects[type]) + ObjectGuid::LowType spawnId = m_Objects[type]; + if (!spawnId) return false; - GameObject* obj = HashMapHolder<GameObject>::Find(m_Objects[type]); - if (!obj) + auto bounds = m_PvP->GetMap()->GetGameObjectBySpawnIdStore().equal_range(spawnId); + for (auto itr = bounds.first; itr != bounds.second;) { - m_Objects[type] = 0; - return false; + GameObject* go = itr->second; + ++itr; + // Don't save respawn time + go->SetRespawnTime(0); + go->Delete(); } - uint32 guid = obj->GetDBTableGUIDLow(); - obj->SetRespawnTime(0); // not save respawn time - obj->Delete(); - sObjectMgr->DeleteGOData(guid); + + sObjectMgr->DeleteGOData(spawnId); m_ObjectTypes[m_Objects[type]] = 0; m_Objects[type] = 0; return true; @@ -193,8 +194,8 @@ bool OPvPCapturePoint::DelObject(uint32 type) bool OPvPCapturePoint::DelCapturePoint() { - sObjectMgr->DeleteGOData(GUID_LOPART(m_capturePointGUID)); - m_capturePointGUID = 0; + sObjectMgr->DeleteGOData(m_capturePointSpawnId); + m_capturePointSpawnId = 0; if (m_capturePoint) { @@ -207,15 +208,30 @@ bool OPvPCapturePoint::DelCapturePoint() void OPvPCapturePoint::DeleteSpawns() { - for (std::map<uint32, uint64>::iterator i = m_Objects.begin(); i != m_Objects.end(); ++i) + for (std::map<uint32, ObjectGuid::LowType>::iterator i = m_Objects.begin(); i != m_Objects.end(); ++i) DelObject(i->first); - for (std::map<uint32, uint64>::iterator i = m_Creatures.begin(); i != m_Creatures.end(); ++i) + for (std::map<uint32, ObjectGuid::LowType>::iterator i = m_Creatures.begin(); i != m_Creatures.end(); ++i) DelCreature(i->first); DelCapturePoint(); } void OutdoorPvP::DeleteSpawns() { + // Remove script from any registered gameobjects/creatures + for (auto itr = m_GoScriptStore.begin(); itr != m_GoScriptStore.end(); ++itr) + { + if (GameObject* go = itr->second) + go->ClearZoneScript(); + } + m_GoScriptStore.clear(); + + for (auto itr = m_CreatureScriptStore.begin(); itr != m_CreatureScriptStore.end(); ++itr) + { + if (Creature* creature = itr->second) + creature->ClearZoneScript(); + } + m_CreatureScriptStore.clear(); + for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) { itr->second->DeleteSpawns(); @@ -224,7 +240,7 @@ void OutdoorPvP::DeleteSpawns() m_capturePoints.clear(); } -OutdoorPvP::OutdoorPvP() : m_TypeId(0), m_sendUpdate(true) { } +OutdoorPvP::OutdoorPvP() : m_TypeId(0), m_sendUpdate(true), m_map(nullptr) { } OutdoorPvP::~OutdoorPvP() { @@ -276,7 +292,7 @@ bool OPvPCapturePoint::Update(uint32 diff) { for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) { - uint64 playerGuid = *itr; + ObjectGuid playerGuid = *itr; ++itr; if (Player* player = ObjectAccessor::FindPlayer(playerGuid)) @@ -407,7 +423,7 @@ void OPvPCapturePoint::SendUpdateWorldState(uint32 field, uint32 value) } } -void OPvPCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid) +void OPvPCapturePoint::SendObjectiveComplete(uint32 id, ObjectGuid guid) { uint32 team; switch (m_State) @@ -492,19 +508,19 @@ bool OPvPCapturePoint::HandleCustomSpell(Player* player, uint32 /*spellId*/, Gam return false; } -bool OutdoorPvP::HandleOpenGo(Player* player, uint64 guid) +bool OutdoorPvP::HandleOpenGo(Player* player, GameObject* go) { for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - if (itr->second->HandleOpenGo(player, guid) >= 0) + if (itr->second->HandleOpenGo(player, go) >= 0) return true; return false; } -bool OutdoorPvP::HandleGossipOption(Player* player, uint64 guid, uint32 id) +bool OutdoorPvP::HandleGossipOption(Player* player, Creature* creature, uint32 id) { for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - if (itr->second->HandleGossipOption(player, guid, id)) + if (itr->second->HandleGossipOption(player, creature, id)) return true; return false; @@ -528,7 +544,7 @@ bool OutdoorPvP::HandleDropFlag(Player* player, uint32 id) return false; } -bool OPvPCapturePoint::HandleGossipOption(Player* /*player*/, uint64 /*guid*/, uint32 /*id*/) +bool OPvPCapturePoint::HandleGossipOption(Player* /*player*/, Creature* /*creature*/, uint32 /*id*/) { return false; } @@ -543,9 +559,9 @@ bool OPvPCapturePoint::HandleDropFlag(Player* /*player*/, uint32 /*id*/) return false; } -int32 OPvPCapturePoint::HandleOpenGo(Player* /*player*/, uint64 guid) +int32 OPvPCapturePoint::HandleOpenGo(Player* /*player*/, GameObject* go) { - std::map<uint64, uint32>::iterator itr = m_ObjectTypes.find(guid); + std::map<ObjectGuid::LowType, uint32>::iterator itr = m_ObjectTypes.find(go->GetSpawnId()); if (itr != m_ObjectTypes.end()) { return itr->second; @@ -604,18 +620,43 @@ void OutdoorPvP::TeamApplyBuff(TeamId teamId, uint32 spellId, uint32 spellId2, P void OutdoorPvP::OnGameObjectCreate(GameObject* go) { + GoScriptPair sp(go->GetGUID().GetCounter(), go); + m_GoScriptStore.insert(sp); + if (go->GetGoType() != GAMEOBJECT_TYPE_CAPTURE_POINT) return; - if (OPvPCapturePoint* cp = GetCapturePoint(go->GetDBTableGUIDLow())) + if (OPvPCapturePoint* cp = GetCapturePoint(go->GetSpawnId())) cp->m_capturePoint = go; } void OutdoorPvP::OnGameObjectRemove(GameObject* go) { + m_GoScriptStore.erase(go->GetGUID().GetCounter()); + if (go->GetGoType() != GAMEOBJECT_TYPE_CAPTURE_POINT) return; - if (OPvPCapturePoint* cp = GetCapturePoint(go->GetDBTableGUIDLow())) + if (OPvPCapturePoint* cp = GetCapturePoint(go->GetSpawnId())) cp->m_capturePoint = nullptr; } + +void OutdoorPvP::OnCreatureCreate(Creature* creature) +{ + CreatureScriptPair sp(creature->GetGUID().GetCounter(), creature); + m_CreatureScriptStore.insert(sp); +} + +void OutdoorPvP::OnCreatureRemove(Creature* creature) +{ + m_CreatureScriptStore.erase(creature->GetGUID().GetCounter()); +} + +void OutdoorPvP::SetMapFromZone(uint32 zone) +{ + AreaTableEntry const* areaTable = sAreaTableStore.LookupEntry(zone); + ASSERT(areaTable); + Map* map = sMapMgr->CreateBaseMap(areaTable->mapid); + ASSERT(!map->Instanceable()); + m_map = map; +} diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h index 7b03656ba6..aa367adb0c 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.h +++ b/src/server/game/OutdoorPvP/OutdoorPvP.h @@ -72,7 +72,7 @@ class Unit; struct GossipMenuItems; class OutdoorPvP; -typedef std::set<uint64> PlayerSet; +typedef GuidSet PlayerSet; class OPvPCapturePoint { @@ -87,7 +87,7 @@ public: void SendUpdateWorldState(uint32 field, uint32 value); // send kill notify to players in the controlling faction - void SendObjectiveComplete(uint32 id, uint64 guid); + void SendObjectiveComplete(uint32 id, ObjectGuid guid = ObjectGuid::Empty); // used when player is activated/inactivated in the area virtual bool HandlePlayerEnter(Player* player); @@ -98,7 +98,7 @@ public: virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go); - virtual int32 HandleOpenGo(Player* player, uint64 guid); + virtual int32 HandleOpenGo(Player* player, GameObject* go); // returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update. virtual bool Update(uint32 diff); @@ -109,7 +109,7 @@ public: virtual void SendChangePhase(); - virtual bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid); + virtual bool HandleGossipOption(Player* player, Creature* creature, uint32 gossipid); virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso); @@ -117,12 +117,12 @@ public: virtual void DeleteSpawns(); - uint64 m_capturePointGUID; + ObjectGuid::LowType m_capturePointSpawnId; GameObject* m_capturePoint; - void AddGO(uint32 type, uint32 guid, uint32 entry = 0); - void AddCre(uint32 type, uint32 guid, uint32 entry = 0); + void AddGO(uint32 type, ObjectGuid::LowType guid, uint32 entry = 0); + void AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry = 0); bool SetCapturePointData(uint32 entry, uint32 map, float x, float y, float z, float o = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); @@ -165,10 +165,10 @@ protected: // map to store the various gameobjects and creatures spawned by the objective // type, guid - std::map<uint32, uint64> m_Objects; - std::map<uint32, uint64> m_Creatures; - std::map<uint64, uint32> m_ObjectTypes; - std::map<uint64, uint32> m_CreatureTypes; + std::map<uint32, ObjectGuid::LowType> m_Objects; + std::map<uint32, ObjectGuid::LowType> m_Creatures; + std::map<ObjectGuid::LowType, uint32> m_ObjectTypes; + std::map<ObjectGuid::LowType, uint32> m_CreatureTypes; }; // base class for specific outdoor pvp handlers @@ -186,7 +186,9 @@ public: // deletes all gos/creatures spawned by the pvp void DeleteSpawns(); - typedef std::map<uint32/*lowguid*/, OPvPCapturePoint*> OPvPCapturePointMap; + typedef std::map<ObjectGuid::LowType/*lowguid*/, OPvPCapturePoint*> OPvPCapturePointMap; + typedef std::pair<ObjectGuid::LowType, GameObject*> GoScriptPair; + typedef std::pair<ObjectGuid::LowType, Creature*> CreatureScriptPair; virtual void FillInitialWorldStates(WorldPacket& /*data*/) {} @@ -197,14 +199,15 @@ public: virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go); // called on go use - virtual bool HandleOpenGo(Player* player, uint64 guid); + virtual bool HandleOpenGo(Player* player, GameObject* go); // setup stuff virtual bool SetupOutdoorPvP() {return true;} void OnGameObjectCreate(GameObject* go) override; void OnGameObjectRemove(GameObject* go) override; - void OnCreatureCreate(Creature*) override {} + void OnCreatureCreate(Creature* creature) override; + void OnCreatureRemove(Creature* creature) override; // send world state update to all players present void SendUpdateWorldState(uint32 field, uint32 value); @@ -226,12 +229,14 @@ public: virtual bool HandleDropFlag(Player* player, uint32 spellId); - virtual bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid); + virtual bool HandleGossipOption(Player* player, Creature* creature, uint32 gossipid); virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso); void TeamApplyBuff(TeamId teamId, uint32 spellId, uint32 spellId2 = 0, Player* sameMapPlr = nullptr); + Map* GetMap() const { return m_map; } + protected: // the map of the objectives belonging to this outdoorpvp OPvPCapturePointMap m_capturePoints; @@ -254,12 +259,12 @@ protected: void AddCapturePoint(OPvPCapturePoint* cp) { - m_capturePoints[GUID_LOPART(cp->m_capturePointGUID)] = cp; + m_capturePoints[cp->m_capturePointSpawnId] = cp; } - OPvPCapturePoint* GetCapturePoint(uint32 lowguid) const + OPvPCapturePoint* GetCapturePoint(ObjectGuid::LowType spawnId) const { - OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid); + OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(spawnId); if (itr != m_capturePoints.end()) return itr->second; return nullptr; @@ -270,6 +275,13 @@ protected: bool HasPlayer(Player const* player) const; void TeamCastSpell(TeamId team, int32 spellId, Player* sameMapPlr = nullptr); + + // Hack to store map because this code is just shit + void SetMapFromZone(uint32 zone); + std::map<ObjectGuid::LowType, GameObject*> m_GoScriptStore; + std::map<ObjectGuid::LowType, Creature*> m_CreatureScriptStore; + + Map* m_map; }; #endif /*OUTDOOR_PVP_H_*/ diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp index e7d4786f75..e84a9463a6 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp @@ -122,7 +122,7 @@ void OutdoorPvPMgr::HandlePlayerEnterZone(Player* player, uint32 zoneid) itr->second->HandlePlayerEnterZone(player, zoneid); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("outdoorpvp", "Player %u entered outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId()); + LOG_DEBUG("outdoorpvp", "Player %s entered outdoorpvp id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId()); #endif } @@ -140,7 +140,7 @@ void OutdoorPvPMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneid) itr->second->HandlePlayerLeaveZone(player, zoneid); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("outdoorpvp", "Player %u left outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId()); + LOG_DEBUG("outdoorpvp", "Player %s left outdoorpvp id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId()); #endif } @@ -186,23 +186,23 @@ ZoneScript* OutdoorPvPMgr::GetZoneScript(uint32 zoneId) return nullptr; } -bool OutdoorPvPMgr::HandleOpenGo(Player* player, uint64 guid) +bool OutdoorPvPMgr::HandleOpenGo(Player* player, GameObject* go) { std::lock_guard<std::mutex> guard(_lock); // pussywizard for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr) { - if ((*itr)->HandleOpenGo(player, guid)) + if ((*itr)->HandleOpenGo(player, go)) return true; } return false; } -void OutdoorPvPMgr::HandleGossipOption(Player* player, uint64 guid, uint32 gossipid) +void OutdoorPvPMgr::HandleGossipOption(Player* player, Creature* creature, uint32 gossipid) { std::lock_guard<std::mutex> guard(_lock); // pussywizard for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr) { - if ((*itr)->HandleGossipOption(player, guid, gossipid)) + if ((*itr)->HandleGossipOption(player, creature, gossipid)) return; } } diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h index 08b46a2d04..94e40ec1d1 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h +++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h @@ -55,7 +55,7 @@ public: bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go); // handle custom go if registered - bool HandleOpenGo(Player* player, uint64 guid); + bool HandleOpenGo(Player* player, GameObject* go); ZoneScript* GetZoneScript(uint32 zoneId); @@ -63,7 +63,7 @@ public: void Update(uint32 diff); - void HandleGossipOption(Player* player, uint64 guid, uint32 gossipid); + void HandleGossipOption(Player* player, Creature* creatured, uint32 gossipid); bool CanTalkTo(Player* player, Creature* creature, GossipMenuItems const& gso); diff --git a/src/server/game/Petitions/PetitionMgr.cpp b/src/server/game/Petitions/PetitionMgr.cpp index a497824685..e414f96309 100644 --- a/src/server/game/Petitions/PetitionMgr.cpp +++ b/src/server/game/Petitions/PetitionMgr.cpp @@ -39,7 +39,7 @@ void PetitionMgr::LoadPetitions() do { Field* fields = result->Fetch(); - AddPetition(fields[1].GetUInt32(), fields[0].GetUInt32(), fields[2].GetString(), fields[3].GetUInt8()); + AddPetition(ObjectGuid::Create<HighGuid::Item>(fields[1].GetUInt32()), ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()), fields[2].GetString(), fields[3].GetUInt8()); ++count; } while (result->NextRow()); @@ -64,7 +64,7 @@ void PetitionMgr::LoadSignatures() do { Field* fields = result->Fetch(); - AddSignature(fields[0].GetUInt32(), fields[2].GetUInt32(), fields[1].GetUInt32()); + AddSignature(ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt32()), fields[2].GetUInt32(), ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32())); ++count; } while (result->NextRow()); @@ -72,28 +72,28 @@ void PetitionMgr::LoadSignatures() LOG_INFO("server", " "); } -void PetitionMgr::AddPetition(uint32 petitionId, uint32 ownerGuid, std::string const& name, uint8 type) +void PetitionMgr::AddPetition(ObjectGuid petitionGUID, ObjectGuid ownerGuid, std::string const& name, uint8 type) { - Petition& p = PetitionStore[petitionId]; - p.petitionGuid = petitionId; + Petition& p = PetitionStore[petitionGUID]; + p.petitionGuid = petitionGUID; p.ownerGuid = ownerGuid; p.petitionName = name; p.petitionType = type; - Signatures& s = SignatureStore[petitionId]; - s.petitionGuid = petitionId; + Signatures& s = SignatureStore[petitionGUID]; + s.petitionGuid = petitionGUID; s.signatureMap.clear(); } -void PetitionMgr::RemovePetition(uint32 petitionId) +void PetitionMgr::RemovePetition(ObjectGuid petitionGUID) { - PetitionStore.erase(petitionId); + PetitionStore.erase(petitionGUID); // remove signatures - SignatureStore.erase(petitionId); + SignatureStore.erase(petitionGUID); } -void PetitionMgr::RemovePetitionByOwnerAndType(uint32 ownerGuid, uint8 type) +void PetitionMgr::RemovePetitionByOwnerAndType(ObjectGuid ownerGuid, uint8 type) { for (PetitionContainer::iterator itr = PetitionStore.begin(); itr != PetitionStore.end();) { @@ -108,15 +108,15 @@ void PetitionMgr::RemovePetitionByOwnerAndType(uint32 ownerGuid, uint8 type) } } -Petition const* PetitionMgr::GetPetition(uint32 petitionId) const +Petition const* PetitionMgr::GetPetition(ObjectGuid petitionGUID) const { - PetitionContainer::const_iterator itr = PetitionStore.find(petitionId); + PetitionContainer::const_iterator itr = PetitionStore.find(petitionGUID); if (itr != PetitionStore.end()) return &itr->second; return nullptr; } -Petition const* PetitionMgr::GetPetitionByOwnerWithType(uint32 ownerGuid, uint8 type) const +Petition const* PetitionMgr::GetPetitionByOwnerWithType(ObjectGuid ownerGuid, uint8 type) const { for (PetitionContainer::const_iterator itr = PetitionStore.begin(); itr != PetitionStore.end(); ++itr) if (itr->second.ownerGuid == ownerGuid && itr->second.petitionType == type) @@ -125,21 +125,21 @@ Petition const* PetitionMgr::GetPetitionByOwnerWithType(uint32 ownerGuid, uint8 return nullptr; } -void PetitionMgr::AddSignature(uint32 petitionId, uint32 accountId, uint32 playerGuid) +void PetitionMgr::AddSignature(ObjectGuid petitionGUID, uint32 accountId, ObjectGuid playerGuid) { - Signatures& s = SignatureStore[petitionId]; + Signatures& s = SignatureStore[petitionGUID]; s.signatureMap[playerGuid] = accountId; } -Signatures const* PetitionMgr::GetSignature(uint32 petitionId) const +Signatures const* PetitionMgr::GetSignature(ObjectGuid petitionGUID) const { - SignatureContainer::const_iterator itr = SignatureStore.find(petitionId); + SignatureContainer::const_iterator itr = SignatureStore.find(petitionGUID); if (itr != SignatureStore.end()) return &itr->second; return nullptr; } -void PetitionMgr::RemoveSignaturesByPlayer(uint32 playerGuid) +void PetitionMgr::RemoveSignaturesByPlayer(ObjectGuid playerGuid) { for (SignatureContainer::iterator itr = SignatureStore.begin(); itr != SignatureStore.end(); ++itr) { @@ -149,7 +149,7 @@ void PetitionMgr::RemoveSignaturesByPlayer(uint32 playerGuid) } } -void PetitionMgr::RemoveSignaturesByPlayerAndType(uint32 playerGuid, uint8 type) +void PetitionMgr::RemoveSignaturesByPlayerAndType(ObjectGuid playerGuid, uint8 type) { for (SignatureContainer::iterator itr = SignatureStore.begin(); itr != SignatureStore.end(); ++itr) { diff --git a/src/server/game/Petitions/PetitionMgr.h b/src/server/game/Petitions/PetitionMgr.h index 175f1223d3..55183af210 100644 --- a/src/server/game/Petitions/PetitionMgr.h +++ b/src/server/game/Petitions/PetitionMgr.h @@ -6,6 +6,8 @@ Xinef #define _PETITIONMGR_H #include "Common.h" +#include "ObjectGuid.h" + #include <map> #define CHARTER_DISPLAY_ID 16161 @@ -19,24 +21,24 @@ enum CharterItemIDs ARENA_TEAM_CHARTER_5v5 = 23562 }; -typedef std::map<uint32, uint32> SignatureMap; +typedef std::map<ObjectGuid, uint32> SignatureMap; struct Petition { - uint32 petitionGuid; - uint32 ownerGuid; + ObjectGuid petitionGuid; + ObjectGuid ownerGuid; uint8 petitionType; std::string petitionName; }; struct Signatures { - uint32 petitionGuid; + ObjectGuid petitionGuid; SignatureMap signatureMap; }; -typedef std::map<uint32, Signatures> SignatureContainer; -typedef std::map<uint32, Petition> PetitionContainer; +typedef std::map<ObjectGuid, Signatures> SignatureContainer; +typedef std::map<ObjectGuid, Petition> PetitionContainer; class PetitionMgr { @@ -51,18 +53,18 @@ public: void LoadSignatures(); // Petitions - void AddPetition(uint32 petitionId, uint32 ownerGuid, std::string const& name, uint8 type); - void RemovePetition(uint32 petitionId); - void RemovePetitionByOwnerAndType(uint32 ownerGuid, uint8 type); - Petition const* GetPetition(uint32 petitionId) const; - Petition const* GetPetitionByOwnerWithType(uint32 ownerGuid, uint8 type) const; + void AddPetition(ObjectGuid petitionGUID, ObjectGuid ownerGuid, std::string const& name, uint8 type); + void RemovePetition(ObjectGuid petitionGUID); + void RemovePetitionByOwnerAndType(ObjectGuid ownerGuid, uint8 type); + Petition const* GetPetition(ObjectGuid petitionGUID) const; + Petition const* GetPetitionByOwnerWithType(ObjectGuid ownerGuid, uint8 type) const; PetitionContainer* GetPetitionStore() { return &PetitionStore; } // Signatures - void AddSignature(uint32 petitionId, uint32 accountId, uint32 playerGuid); - void RemoveSignaturesByPlayer(uint32 playerGuid); - void RemoveSignaturesByPlayerAndType(uint32 playerGuid, uint8 type); - Signatures const* GetSignature(uint32 petitionId) const; + void AddSignature(ObjectGuid petitionGUID, uint32 accountId, ObjectGuid playerGuid); + void RemoveSignaturesByPlayer(ObjectGuid playerGuid); + void RemoveSignaturesByPlayerAndType(ObjectGuid playerGuid, uint8 type); + Signatures const* GetSignature(ObjectGuid petitionGUID) const; SignatureContainer* GetSignatureStore() { return &SignatureStore; } protected: diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index da3555608e..193a5de289 100644 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -173,7 +173,7 @@ PoolObject* PoolGroup<T>::RollOne(ActivePoolData& spawns, uint32 triggerFrom) // If no guid is passed, the pool is just removed (event end case) // If guid is filled, cache will be used and no removal will occur, it just fill the cache template<class T> -void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, uint32 guid) +void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, ObjectGuid::LowType guid) { for (size_t i = 0; i < EqualChanced.size(); ++i) { @@ -204,27 +204,45 @@ void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, uint32 guid) // Method that is actualy doing the removal job on one creature template<> -void PoolGroup<Creature>::Despawn1Object(uint32 guid) +void PoolGroup<Creature>::Despawn1Object(ObjectGuid::LowType guid) { if (CreatureData const* data = sObjectMgr->GetCreatureData(guid)) { sObjectMgr->RemoveCreatureFromGrid(guid, data); - if (Creature* creature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT), (Creature*)nullptr)) - creature->AddObjectToRemoveList(); + Map* map = sMapMgr->CreateBaseMap(data->mapid); + if (!map->Instanceable()) + { + auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(guid); + for (auto itr = creatureBounds.first; itr != creatureBounds.second;) + { + Creature* creature = itr->second; + ++itr; + creature->AddObjectToRemoveList(); + } + } } } // Same on one gameobject template<> -void PoolGroup<GameObject>::Despawn1Object(uint32 guid) +void PoolGroup<GameObject>::Despawn1Object(ObjectGuid::LowType guid) { if (GameObjectData const* data = sObjectMgr->GetGOData(guid)) { sObjectMgr->RemoveGameobjectFromGrid(guid, data); - if (GameObject* pGameobject = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)nullptr)) - pGameobject->AddObjectToRemoveList(); + Map* map = sMapMgr->CreateBaseMap(data->mapid); + if (!map->Instanceable()) + { + auto gameobjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(guid); + for (auto itr = gameobjectBounds.first; itr != gameobjectBounds.second;) + { + GameObject* go = itr->second; + ++itr; + go->AddObjectToRemoveList(); + } + } } } @@ -502,20 +520,16 @@ void PoolGroup<Quest>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 // Method that does the respawn job on the specified creature template <> -void PoolGroup<Creature>::ReSpawn1Object(PoolObject* obj) +void PoolGroup<Creature>::ReSpawn1Object(PoolObject* /*obj*/) { - if (CreatureData const* data = sObjectMgr->GetCreatureData(obj->guid)) - if (Creature* creature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_UNIT), (Creature*)nullptr)) - creature->GetMap()->AddToMap(creature); + // Creature is still on map, nothing to do } // Method that does the respawn job on the specified gameobject template <> -void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* obj) +void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* /*obj*/) { - if (GameObjectData const* data = sObjectMgr->GetGOData(obj->guid)) - if (GameObject* pGameobject = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)nullptr)) - pGameobject->GetMap()->AddToMap(pGameobject); + // Gameobject is still on map, nothing to do } // Nothing to do for a child Pool @@ -603,9 +617,9 @@ void PoolMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 pool_id = fields[1].GetUInt32(); - float chance = fields[2].GetFloat(); + float chance = fields[2].GetFloat(); CreatureData const* data = sObjectMgr->GetCreatureData(guid); if (!data) @@ -661,9 +675,9 @@ void PoolMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 pool_id = fields[1].GetUInt32(); - float chance = fields[2].GetFloat(); + float chance = fields[2].GetFloat(); GameObjectData const* data = sObjectMgr->GetGOData(guid); if (!data) diff --git a/src/server/game/Pools/PoolMgr.h b/src/server/game/Pools/PoolMgr.h index e41cd2c3df..1d25eaa928 100644 --- a/src/server/game/Pools/PoolMgr.h +++ b/src/server/game/Pools/PoolMgr.h @@ -65,8 +65,8 @@ public: void AddEntry(PoolObject& poolitem, uint32 maxentries); bool CheckPool() const; PoolObject* RollOne(ActivePoolData& spawns, uint32 triggerFrom); - void DespawnObject(ActivePoolData& spawns, uint32 guid = 0); - void Despawn1Object(uint32 guid); + void DespawnObject(ActivePoolData& spawns, ObjectGuid::LowType guid = 0); + void Despawn1Object(ObjectGuid::LowType guid); void SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 triggerFrom); void Spawn1Object(PoolObject* obj); diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index 90c8ee8360..395e2d75b6 100644 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -504,7 +504,7 @@ void ReputationMgr::LoadFromDB(PreparedQueryResult result) // Set initial reputations (so everything is nifty before DB data load) Initialize(); - //QueryResult* result = CharacterDatabase.PQuery("SELECT faction, standing, flags FROM character_reputation WHERE guid = '%u'", GetGUIDLow()); + //QueryResult* result = CharacterDatabase.PQuery("SELECT faction, standing, flags FROM character_reputation WHERE guid = '%u'", GetGUID().GetCounter()); if (result) { @@ -568,12 +568,12 @@ void ReputationMgr::SaveToDB(SQLTransaction& trans) if (itr->second.needSave) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REPUTATION_BY_FACTION); - stmt->setUInt32(0, _player->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); stmt->setUInt16(1, uint16(itr->second.ID)); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_REPUTATION_BY_FACTION); - stmt->setUInt32(0, _player->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); stmt->setUInt16(1, uint16(itr->second.ID)); stmt->setInt32(2, itr->second.Standing); stmt->setUInt16(3, uint16(itr->second.Flags)); diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 1b5ade8111..cff17ff53d 100644 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -28,9 +28,9 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O return; // prepare static data - uint64 sourceGUID = source ? source->GetGUID() : uint64(0); //some script commands doesn't have source - uint64 targetGUID = target ? target->GetGUID() : uint64(0); - uint64 ownerGUID = (source && source->GetTypeId() == TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : uint64(0); + ObjectGuid sourceGUID = source ? source->GetGUID() : ObjectGuid::Empty; //some script commands doesn't have source + ObjectGuid targetGUID = target ? target->GetGUID() : ObjectGuid::Empty; + ObjectGuid ownerGUID = (source && source->GetTypeId() == TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : ObjectGuid::Empty; ///- Schedule script execution for all scripts in the script map ScriptMap const* s2 = &(s->second); @@ -63,9 +63,9 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou // NOTE: script record _must_ exist until command executed // prepare static data - uint64 sourceGUID = source ? source->GetGUID() : uint64(0); - uint64 targetGUID = target ? target->GetGUID() : uint64(0); - uint64 ownerGUID = (source && source->GetTypeId() == TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : uint64(0); + ObjectGuid sourceGUID = source ? source->GetGUID() : ObjectGuid::Empty; + ObjectGuid targetGUID = target ? target->GetGUID() : ObjectGuid::Empty; + ObjectGuid ownerGUID = (source && source->GetTypeId() == TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : ObjectGuid::Empty; ScriptAction sa; sa.sourceGUID = sourceGUID; @@ -101,10 +101,10 @@ inline Player* Map::_GetScriptPlayerSourceOrTarget(Object* source, Object* targe player = source->ToPlayer(); if (!player) - LOG_ERROR("server", "%s neither source nor target object is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.", + LOG_ERROR("server", "%s neither source nor target object is player (source: TypeId: %u, Entry: %u, GUID: %s; target: TypeId: %u, Entry: %u, GUID: %s), skipping.", scriptInfo->GetDebugInfo().c_str(), - source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0, - target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0); + source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUID().ToString().c_str() : "", + target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUID().ToString().c_str() : ""); } return player; } @@ -134,10 +134,10 @@ inline Creature* Map::_GetScriptCreatureSourceOrTarget(Object* source, Object* t } if (!creature) - LOG_ERROR("server", "%s neither source nor target are creatures (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.", + LOG_ERROR("server", "%s neither source nor target are creatures (source: TypeId: %u, Entry: %u, GUID: %s; target: TypeId: %u, Entry: %u, GUID: %s), skipping.", scriptInfo->GetDebugInfo().c_str(), - source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0, - target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0); + source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUID().ToString().c_str() : "", + target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUID().ToString().c_str() : ""); } return creature; } @@ -148,8 +148,8 @@ inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* s if (!obj) LOG_ERROR("server", "%s %s object is nullptr.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target"); else if (!obj->isType(TYPEMASK_UNIT)) - LOG_ERROR("server", "%s %s object is not unit (TypeId: %u, Entry: %u, GUID: %u), skipping.", - scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow()); + LOG_ERROR("server", "%s %s object is not unit (TypeId: %u, Entry: %u, GUID: %s), skipping.", + scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString().c_str()); else { unit = obj->ToUnit(); @@ -169,8 +169,8 @@ inline Player* Map::_GetScriptPlayer(Object* obj, bool isSource, const ScriptInf { player = obj->ToPlayer(); if (!player) - LOG_ERROR("server", "%s %s object is not a player (TypeId: %u, Entry: %u, GUID: %u).", - scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow()); + LOG_ERROR("server", "%s %s object is not a player (%s).", + scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetGUID().ToString().c_str()); } return player; } @@ -184,8 +184,8 @@ inline Creature* Map::_GetScriptCreature(Object* obj, bool isSource, const Scrip { creature = obj->ToCreature(); if (!creature) - LOG_ERROR("server", "%s %s object is not a creature (TypeId: %u, Entry: %u, GUID: %u).", scriptInfo->GetDebugInfo().c_str(), - isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow()); + LOG_ERROR("server", "%s %s object is not a creature (%s).", scriptInfo->GetDebugInfo().c_str(), + isSource ? "source" : "target", obj->GetGUID().ToString().c_str()); } return creature; } @@ -200,8 +200,8 @@ inline WorldObject* Map::_GetScriptWorldObject(Object* obj, bool isSource, const { pWorldObject = dynamic_cast<WorldObject*>(obj); if (!pWorldObject) - LOG_ERROR("server", "%s %s object is not a world object (TypeId: %u, Entry: %u, GUID: %u).", - scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow()); + LOG_ERROR("server", "%s %s object is not a world object (%s).", + scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetGUID().ToString().c_str()); } return pWorldObject; } @@ -209,7 +209,7 @@ inline WorldObject* Map::_GetScriptWorldObject(Object* obj, bool isSource, const inline void Map::_ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const { bool bOpen = false; - uint32 guid = scriptInfo->ToggleDoor.GOGuid; + ObjectGuid::LowType guid = scriptInfo->ToggleDoor.GOGuid; int32 nTimeToToggle = std::max(15, int32(scriptInfo->ToggleDoor.ResetDelay)); switch (scriptInfo->command) { @@ -227,22 +227,20 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script else if (!source) LOG_ERROR("server", "%s source object is nullptr.", scriptInfo->GetDebugInfo().c_str()); else if (!source->isType(TYPEMASK_UNIT)) - LOG_ERROR("server", "%s source object is not unit (TypeId: %u, Entry: %u, GUID: %u), skipping.", scriptInfo->GetDebugInfo().c_str(), - source->GetTypeId(), source->GetEntry(), source->GetGUIDLow()); + LOG_ERROR("server", "%s source object is not unit (%s), skipping.", scriptInfo->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str()); else { WorldObject* wSource = dynamic_cast <WorldObject*> (source); if (!wSource) - LOG_ERROR("server", "%s source object could not be casted to world object (TypeId: %u, Entry: %u, GUID: %u), skipping.", - scriptInfo->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow()); + LOG_ERROR("server", "%s source object could not be casted to world object (%s), skipping.", scriptInfo->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str()); else { GameObject* pDoor = _FindGameObject(wSource, guid); if (!pDoor) LOG_ERROR("server", "%s gameobject was not found (guid: %u).", scriptInfo->GetDebugInfo().c_str(), guid); else if (pDoor->GetGoType() != GAMEOBJECT_TYPE_DOOR) - LOG_ERROR("server", "%s gameobject is not a door (GoType: %u, Entry: %u, GUID: %u).", - scriptInfo->GetDebugInfo().c_str(), pDoor->GetGoType(), pDoor->GetEntry(), pDoor->GetGUIDLow()); + LOG_ERROR("server", "%s gameobject is not a door (%s).", + scriptInfo->GetDebugInfo().c_str(), pDoor->GetGUID().ToString().c_str()); else if (bOpen == (pDoor->GetGoState() == GO_STATE_READY)) { pDoor->UseDoorOrButton(nTimeToToggle); @@ -258,20 +256,13 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script } } -inline GameObject* Map::_FindGameObject(WorldObject* searchObject, uint32 guid) const +inline GameObject* Map::_FindGameObject(WorldObject* searchObject, ObjectGuid::LowType guid) const { - GameObject* gameobject = nullptr; + auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid); + if (bounds.first == bounds.second) + return nullptr; - CellCoord p(acore::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY())); - Cell cell(p); - - acore::GameObjectWithDbGUIDCheck goCheck(guid); - acore::GameObjectSearcher<acore::GameObjectWithDbGUIDCheck> checker(searchObject, gameobject, goCheck); - - TypeContainerVisitor<acore::GameObjectSearcher<acore::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker); - cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange()); - - return gameobject; + return bounds.first->second; } /// Process queued scripts @@ -290,38 +281,35 @@ void Map::ScriptsProcess() Object* source = nullptr; if (step.sourceGUID) { - switch (GUID_HIPART(step.sourceGUID)) + switch (step.sourceGUID.GetHigh()) { - case HIGHGUID_ITEM: // as well as HIGHGUID_CONTAINER - if (Player* player = GetPlayer(step.ownerGUID)) + case HighGuid::Item: // as well as HIGHGUID_CONTAINER + if (Player* player = ObjectAccessor::GetPlayer(this, step.ownerGUID)) source = player->GetItemByGuid(step.sourceGUID); break; - case HIGHGUID_UNIT: - case HIGHGUID_VEHICLE: + case HighGuid::Unit: + case HighGuid::Vehicle: source = GetCreature(step.sourceGUID); break; - case HIGHGUID_PET: + case HighGuid::Pet: source = GetPet(step.sourceGUID); break; - case HIGHGUID_PLAYER: - source = GetPlayer(step.sourceGUID); + case HighGuid::Player: + source = HashMapHolder<Player>::Find(step.sourceGUID); break; - case HIGHGUID_TRANSPORT: - case HIGHGUID_GAMEOBJECT: + case HighGuid::Transport: + case HighGuid::GameObject: source = GetGameObject(step.sourceGUID); break; - case HIGHGUID_CORPSE: + case HighGuid::Corpse: source = GetCorpse(step.sourceGUID); break; - case HIGHGUID_MO_TRANSPORT: - { - GameObject* go = GetGameObject(step.sourceGUID); - source = go ? go->ToTransport() : nullptr; - break; - } + case HighGuid::Mo_Transport: + source = GetTransport(step.sourceGUID); + break; default: - LOG_ERROR("server", "%s source with unsupported high guid (GUID: " UI64FMTD ", high guid: %u).", - step.script->GetDebugInfo().c_str(), step.sourceGUID, GUID_HIPART(step.sourceGUID)); + LOG_ERROR("server", "%s source with unsupported high guid (%s).", + step.script->GetDebugInfo().c_str(), step.sourceGUID.ToString().c_str()); break; } } @@ -329,34 +317,31 @@ void Map::ScriptsProcess() WorldObject* target = nullptr; if (step.targetGUID) { - switch (GUID_HIPART(step.targetGUID)) + switch (step.targetGUID.GetHigh()) { - case HIGHGUID_UNIT: - case HIGHGUID_VEHICLE: + case HighGuid::Unit: + case HighGuid::Vehicle: target = GetCreature(step.targetGUID); break; - case HIGHGUID_PET: + case HighGuid::Pet: target = GetPet(step.targetGUID); break; - case HIGHGUID_PLAYER: // empty GUID case also - target = GetPlayer(step.targetGUID); + case HighGuid::Player: // empty GUID case also + target = HashMapHolder<Player>::Find(step.targetGUID); break; - case HIGHGUID_TRANSPORT: - case HIGHGUID_GAMEOBJECT: + case HighGuid::Transport: + case HighGuid::GameObject: target = GetGameObject(step.targetGUID); break; - case HIGHGUID_CORPSE: + case HighGuid::Corpse: target = GetCorpse(step.targetGUID); break; - case HIGHGUID_MO_TRANSPORT: - { - GameObject* go = GetGameObject(step.targetGUID); - target = go ? go->ToTransport() : nullptr; - break; - } + case HighGuid::Mo_Transport: + target = GetTransport(step.targetGUID); + break; default: - LOG_ERROR("server", "%s target with unsupported high guid (GUID: " UI64FMTD ", high guid: %u).", - step.script->GetDebugInfo().c_str(), step.targetGUID, GUID_HIPART(step.targetGUID)); + LOG_ERROR("server", "%s target with unsupported high guid (%s).", + step.script->GetDebugInfo().c_str(), step.targetGUID.ToString().c_str()); break; } } @@ -392,8 +377,8 @@ void Map::ScriptsProcess() case CHAT_TYPE_WHISPER: case CHAT_MSG_RAID_BOSS_WHISPER: { - uint64 targetGUID = target ? target->GetGUID() : 0; - if (!targetGUID || !IS_PLAYER_GUID(targetGUID)) + ObjectGuid targetGUID = target ? target->GetGUID() : ObjectGuid::Empty; + if (!targetGUID || !targetGUID.IsPlayer()) LOG_ERROR("server", "%s attempt to whisper to non-player unit, skipping.", step.script->GetDebugInfo().c_str()); else player->Whisper(text, LANG_UNIVERSAL, targetGUID); @@ -409,7 +394,7 @@ void Map::ScriptsProcess() // Source or target must be Creature. if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script)) { - uint64 targetGUID = target ? target->GetGUID() : 0; + ObjectGuid targetGUID = target ? target->GetGUID() : ObjectGuid::Empty; switch (step.script->Talk.ChatType) { case CHAT_TYPE_SAY: @@ -425,13 +410,13 @@ void Map::ScriptsProcess() cSource->MonsterTextEmote(step.script->Talk.TextID, target, true); break; case CHAT_TYPE_WHISPER: - if (!targetGUID || !IS_PLAYER_GUID(targetGUID)) + if (!targetGUID || !targetGUID.IsPlayer()) LOG_ERROR("server", "%s attempt to whisper to non-player unit, skipping.", step.script->GetDebugInfo().c_str()); else cSource->MonsterWhisper(step.script->Talk.TextID, target->ToPlayer()); break; case CHAT_MSG_RAID_BOSS_WHISPER: - if (!targetGUID || !IS_PLAYER_GUID(targetGUID)) + if (!targetGUID || !targetGUID.IsPlayer()) LOG_ERROR("server", "%s attempt to raidbosswhisper to non-player unit, skipping.", step.script->GetDebugInfo().c_str()); else cSource->MonsterWhisper(step.script->Talk.TextID, target->ToPlayer(), true); @@ -460,9 +445,8 @@ void Map::ScriptsProcess() { // Validate field number. if (step.script->FieldSet.FieldID <= OBJECT_FIELD_ENTRY || step.script->FieldSet.FieldID >= cSource->GetValuesCount()) - LOG_ERROR("server", "%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u) specified, skipping.", - step.script->GetDebugInfo().c_str(), step.script->FieldSet.FieldID, - cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUIDLow()); + LOG_ERROR("server", "%s wrong field %u (max count: %u) in object (%s) specified, skipping.", + step.script->GetDebugInfo().c_str(), step.script->FieldSet.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString().c_str()); else cSource->SetUInt32Value(step.script->FieldSet.FieldID, step.script->FieldSet.FieldValue); } @@ -489,9 +473,8 @@ void Map::ScriptsProcess() { // Validate field number. if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount()) - LOG_ERROR("server", "%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u) specified, skipping.", - step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID, - cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUIDLow()); + LOG_ERROR("server", "%s wrong field %u (max count: %u) in object (%s) specified, skipping.", + step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString().c_str()); else cSource->SetFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue); } @@ -503,9 +486,8 @@ void Map::ScriptsProcess() { // Validate field number. if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount()) - LOG_ERROR("server", "%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u) specified, skipping.", - step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID, - cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUIDLow()); + LOG_ERROR("server", "%s wrong field %u (max count: %u) in object (%s) specified, skipping.", + step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString().c_str()); else cSource->RemoveFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue); } @@ -546,8 +528,7 @@ void Map::ScriptsProcess() { if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER) { - LOG_ERROR("server", "%s source is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.", - step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow()); + LOG_ERROR("server", "%s source is not unit, gameobject or player (%s), skipping.", step.script->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str()); break; } worldObject = dynamic_cast<WorldObject*>(source); @@ -559,17 +540,15 @@ void Map::ScriptsProcess() { if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER) { - LOG_ERROR("server", "%s target is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.", - step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow()); + LOG_ERROR("server", "%s target is not unit, gameobject or player (%s), skipping.", step.script->GetDebugInfo().c_str(), target->GetGUID().ToString().c_str()); break; } worldObject = dynamic_cast<WorldObject*>(target); } else { - LOG_ERROR("server", "%s neither source nor target is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.", - step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow(), - target->GetTypeId(), target->GetEntry(), target->GetGUIDLow()); + LOG_ERROR("server", "%s neither source nor target is player (source: %s; target: %s), skipping.", + step.script->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str()); break; } } @@ -591,7 +570,7 @@ void Map::ScriptsProcess() if (step.script->KillCredit.Flags & SF_KILLCREDIT_REWARD_GROUP) player->RewardPlayerAndGroupAtEvent(step.script->KillCredit.CreatureEntry, player); else - player->KilledMonsterCredit(step.script->KillCredit.CreatureEntry, 0); + player->KilledMonsterCredit(step.script->KillCredit.CreatureEntry); } break; @@ -680,8 +659,7 @@ void Map::ScriptsProcess() if (target->GetTypeId() != TYPEID_GAMEOBJECT) { - LOG_ERROR("server", "%s target object is not gameobject (TypeId: %u, Entry: %u, GUID: %u), skipping.", - step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow()); + LOG_ERROR("server", "%s target object is not gameobject (%s), skipping.", step.script->GetDebugInfo().c_str(), target->GetGUID().ToString().c_str()); break; } @@ -823,22 +801,15 @@ void Map::ScriptsProcess() } Creature* cTarget = nullptr; - WorldObject* wSource = dynamic_cast <WorldObject*> (source); - if (wSource) //using grid searcher - { - CellCoord p(acore::ComputeCellCoord(wSource->GetPositionX(), wSource->GetPositionY())); - Cell cell(p); - - acore::CreatureWithDbGUIDCheck target_check(step.script->CallScript.CreatureEntry); - acore::CreatureSearcher<acore::CreatureWithDbGUIDCheck> checker(wSource, cTarget, target_check); - - TypeContainerVisitor<acore::CreatureSearcher <acore::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker); - cell.Visit(p, unit_checker, *wSource->GetMap(), *wSource, wSource->GetGridActivationRange()); - } - else //check hashmap holders + auto creatureBounds = _creatureBySpawnIdStore.equal_range(step.script->CallScript.CreatureEntry); + if (creatureBounds.first != creatureBounds.second) { - if (CreatureData const* data = sObjectMgr->GetCreatureData(step.script->CallScript.CreatureEntry)) - cTarget = ObjectAccessor::GetObjectInWorld<Creature>(data->mapid, data->posX, data->posY, MAKE_NEW_GUID(step.script->CallScript.CreatureEntry, data->id, HIGHGUID_UNIT), cTarget); + // Prefer alive (last respawned) creature + auto creatureItr = std::find_if(creatureBounds.first, creatureBounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair) + { + return pair.second->IsAlive(); + }); + cTarget = creatureItr != creatureBounds.second ? creatureItr->second : creatureBounds.first->second; } if (!cTarget) @@ -866,8 +837,7 @@ void Map::ScriptsProcess() if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script)) { if (cSource->isDead()) - LOG_ERROR("server", "%s creature is already dead (Entry: %u, GUID: %u)", - step.script->GetDebugInfo().c_str(), cSource->GetEntry(), cSource->GetGUIDLow()); + LOG_ERROR("server", "%s creature is already dead (%s)", step.script->GetDebugInfo().c_str(), cSource->GetGUID().ToString().c_str()); else { cSource->setDeathState(JUST_DIED); diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index dbbab7b36d..659cccd8af 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -362,7 +362,7 @@ void ScriptMgr::CreateSpellScriptLoaders(uint32 spellId, std::vector<std::pair<S } } -void ScriptMgr::OnBeforePlayerDurabilityRepair(Player* player, uint64 npcGUID, uint64 itemGUID, float& discountMod, uint8 guildBank) +void ScriptMgr::OnBeforePlayerDurabilityRepair(Player* player, ObjectGuid npcGUID, ObjectGuid itemGUID, float& discountMod, uint8 guildBank) { FOREACH_SCRIPT(PlayerScript)->OnBeforeDurabilityRepair(player, npcGUID, itemGUID, discountMod, guildBank); } @@ -1528,7 +1528,7 @@ void ScriptMgr::OnPlayerEmote(Player* player, uint32 emote) FOREACH_SCRIPT(PlayerScript)->OnEmote(player, emote); } -void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, uint64 guid) +void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, ObjectGuid guid) { #ifdef ELUNA sEluna->OnTextEmote(player, textEmote, emoteNum, guid); @@ -1586,15 +1586,15 @@ void ScriptMgr::OnPlayerSave(Player* player) FOREACH_SCRIPT(PlayerScript)->OnSave(player); } -void ScriptMgr::OnPlayerDelete(uint64 guid, uint32 accountId) +void ScriptMgr::OnPlayerDelete(ObjectGuid guid, uint32 accountId) { #ifdef ELUNA - sEluna->OnDelete(GUID_LOPART(guid)); + sEluna->OnDelete(guid.GetCounter()); #endif FOREACH_SCRIPT(PlayerScript)->OnDelete(guid, accountId); } -void ScriptMgr::OnPlayerFailedDelete(uint64 guid, uint32 accountId) +void ScriptMgr::OnPlayerFailedDelete(ObjectGuid guid, uint32 accountId) { FOREACH_SCRIPT(PlayerScript)->OnFailedDelete(guid, accountId); } @@ -1710,7 +1710,7 @@ void ScriptMgr::OnGetMaxPersonalArenaRatingRequirement(const Player* player, uin FOREACH_SCRIPT(PlayerScript)->OnGetMaxPersonalArenaRatingRequirement(player, minSlot, maxArenaRating); } -void ScriptMgr::OnLootItem(Player* player, Item* item, uint32 count, uint64 lootguid) +void ScriptMgr::OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid lootguid) { FOREACH_SCRIPT(PlayerScript)->OnLootItem(player, item, count, lootguid); } @@ -1733,7 +1733,7 @@ void ScriptMgr::OnFirstLogin(Player* player) FOREACH_SCRIPT(PlayerScript)->OnFirstLogin(player); } -bool ScriptMgr::CanJoinInBattlegroundQueue(Player* player, uint64 BattlemasterGuid, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, GroupJoinBattlegroundResult& err) +bool ScriptMgr::CanJoinInBattlegroundQueue(Player* player, ObjectGuid BattlemasterGuid, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, GroupJoinBattlegroundResult& err) { bool ret = true; @@ -1885,7 +1885,7 @@ void ScriptMgr::OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool FOREACH_SCRIPT(GuildScript)->OnItemMove(guild, player, pItem, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId); } -void ScriptMgr::OnGuildEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) +void ScriptMgr::OnGuildEvent(Guild* guild, uint8 eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) { #ifdef ELUNA sEluna->OnEvent(guild, eventType, playerGuid1, playerGuid2, newRank); @@ -1893,7 +1893,7 @@ void ScriptMgr::OnGuildEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, FOREACH_SCRIPT(GuildScript)->OnEvent(guild, eventType, playerGuid1, playerGuid2, newRank); } -void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) +void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) { #ifdef ELUNA sEluna->OnBankEvent(guild, eventType, tabId, playerGuid, itemOrMoney, itemStackCount, destTabId); @@ -1902,7 +1902,7 @@ void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uin } // Group -void ScriptMgr::OnGroupAddMember(Group* group, uint64 guid) +void ScriptMgr::OnGroupAddMember(Group* group, ObjectGuid guid) { ASSERT(group); #ifdef ELUNA @@ -1911,7 +1911,7 @@ void ScriptMgr::OnGroupAddMember(Group* group, uint64 guid) FOREACH_SCRIPT(GroupScript)->OnAddMember(group, guid); } -void ScriptMgr::OnGroupInviteMember(Group* group, uint64 guid) +void ScriptMgr::OnGroupInviteMember(Group* group, ObjectGuid guid) { ASSERT(group); #ifdef ELUNA @@ -1920,7 +1920,7 @@ void ScriptMgr::OnGroupInviteMember(Group* group, uint64 guid) FOREACH_SCRIPT(GroupScript)->OnInviteMember(group, guid); } -void ScriptMgr::OnGroupRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, const char* reason) +void ScriptMgr::OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason) { ASSERT(group); #ifdef ELUNA @@ -1929,7 +1929,7 @@ void ScriptMgr::OnGroupRemoveMember(Group* group, uint64 guid, RemoveMethod meth FOREACH_SCRIPT(GroupScript)->OnRemoveMember(group, guid, method, kicker, reason); } -void ScriptMgr::OnGroupChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid) +void ScriptMgr::OnGroupChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid) { ASSERT(group); #ifdef ELUNA @@ -1948,7 +1948,7 @@ void ScriptMgr::OnGroupDisband(Group* group) } // Global -void ScriptMgr::OnGlobalItemDelFromDB(SQLTransaction& trans, uint32 itemGuid) +void ScriptMgr::OnGlobalItemDelFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid) { ASSERT(trans); ASSERT(itemGuid); @@ -1961,7 +1961,7 @@ void ScriptMgr::OnGlobalMirrorImageDisplayItem(const Item* item, uint32& display FOREACH_SCRIPT(GlobalScript)->OnMirrorImageDisplayItem(item, display); } -void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<uint32, uint32>& ap) +void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<ObjectGuid, uint32>& ap) { FOREACH_SCRIPT(GlobalScript)->OnBeforeUpdateArenaPoints(at, ap); } @@ -2052,7 +2052,7 @@ void ScriptMgr::OnPlayerMove(Player* player, MovementInfo movementInfo, uint32 o FOREACH_SCRIPT(MovementHandlerScript)->OnPlayerMove(player, movementInfo, opcode); } -void ScriptMgr::OnBeforeBuyItemFromVendor(Player* player, uint64 vendorguid, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot) +void ScriptMgr::OnBeforeBuyItemFromVendor(Player* player, ObjectGuid vendorguid, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot) { FOREACH_SCRIPT(PlayerScript)->OnBeforeBuyItemFromVendor(player, vendorguid, vendorslot, item, count, bag, slot); } @@ -2229,7 +2229,7 @@ void ScriptMgr::OnBeforeStoreOrEquipNewItem(Player* player, uint32 vendorslot, u FOREACH_SCRIPT(PlayerScript)->OnBeforeStoreOrEquipNewItem(player, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore); } -bool ScriptMgr::CanJoinInArenaQueue(Player* player, uint64 BattlemasterGuid, uint8 arenaslot, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, uint8 IsRated, GroupJoinBattlegroundResult& err) +bool ScriptMgr::CanJoinInArenaQueue(Player* player, ObjectGuid BattlemasterGuid, uint8 arenaslot, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, uint8 IsRated, GroupJoinBattlegroundResult& err) { bool ret = true; @@ -2284,7 +2284,7 @@ bool ScriptMgr::CanSellItem(Player* player, Item* item, Creature* creature) return ret; } -bool ScriptMgr::CanSendMail(Player* player, uint64 receiverGuid, uint64 mailbox, std::string& subject, std::string& body, uint32 money, uint32 COD, Item* item) +bool ScriptMgr::CanSendMail(Player* player, ObjectGuid receiverGuid, ObjectGuid mailbox, std::string& subject, std::string& body, uint32 money, uint32 COD, Item* item) { bool ret = true; @@ -2509,7 +2509,7 @@ void ScriptMgr::OnGetQuestRate(Player* player, float& result) FOREACH_SCRIPT(PlayerScript)->OnGetQuestRate(player, result); } -bool ScriptMgr::PassedQuestKilledMonsterCredit(Player* player, Quest const* qinfo, uint32 entry, uint32 real_entry, uint64 guid) +bool ScriptMgr::PassedQuestKilledMonsterCredit(Player* player, Quest const* qinfo, uint32 entry, uint32 real_entry, ObjectGuid guid) { bool ret = true; @@ -2918,7 +2918,7 @@ bool ScriptMgr::CanResetTalents(Pet* pet) return ret; } -bool ScriptMgr::CanAddMember(ArenaTeam* team, uint64 PlayerGuid) +bool ScriptMgr::CanAddMember(ArenaTeam* team, ObjectGuid PlayerGuid) { bool ret = true; @@ -3012,7 +3012,7 @@ bool ScriptMgr::CanItemApplyEquipSpell(Player* player, Item* item) return ret; } -bool ScriptMgr::CanSendAuctionHello(WorldSession const* session, uint64 guid, Creature* creature) +bool ScriptMgr::CanSendAuctionHello(WorldSession const* session, ObjectGuid guid, Creature* creature) { bool ret = true; diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index a1525b8025..869d77f9b8 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -841,7 +841,7 @@ public: // Both of the below are called on emote opcodes. virtual void OnEmote(Player* /*player*/, uint32 /*emote*/) { } - virtual void OnTextEmote(Player* /*player*/, uint32 /*textEmote*/, uint32 /*emoteNum*/, uint64 /*guid*/) { } + virtual void OnTextEmote(Player* /*player*/, uint32 /*textEmote*/, uint32 /*emoteNum*/, ObjectGuid /*guid*/) { } // Called in Spell::Cast. virtual void OnSpellCast(Player* /*player*/, Spell* /*spell*/, bool /*skipCheck*/) { } @@ -859,10 +859,10 @@ public: virtual void OnCreate(Player* /*player*/) { } // Called when a player is deleted. - virtual void OnDelete(uint64 /*guid*/, uint32 /*accountId*/) { } + virtual void OnDelete(ObjectGuid /*guid*/, uint32 /*accountId*/) { } // Called when a player delete failed. - virtual void OnFailedDelete(uint64 /*guid*/, uint32 /*accountId*/) { } + virtual void OnFailedDelete(ObjectGuid /*guid*/, uint32 /*accountId*/) { } // Called when a player is about to be saved. virtual void OnSave(Player* /*player*/) { } @@ -937,7 +937,7 @@ public: virtual void OnGetMaxPersonalArenaRatingRequirement(const Player* /*player*/, uint32 /*minSlot*/, uint32& /*maxArenaRating*/) const {} //After looting item - virtual void OnLootItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/, uint64 /*lootguid*/) { } + virtual void OnLootItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/, ObjectGuid /*lootguid*/) { } //After creating item (eg profession item creation) virtual void OnCreateItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/) { } @@ -949,10 +949,10 @@ public: [[nodiscard]] virtual bool OnBeforeQuestComplete(Player* /*player*/, uint32 /*quest_id*/) { return true; } // Before durability repair action, you can even modify the discount value - virtual void OnBeforeDurabilityRepair(Player* /*player*/, uint64 /*npcGUID*/, uint64 /*itemGUID*/, float&/*discountMod*/, uint8 /*guildBank*/) { } + virtual void OnBeforeDurabilityRepair(Player* /*player*/, ObjectGuid /*npcGUID*/, ObjectGuid /*itemGUID*/, float&/*discountMod*/, uint8 /*guildBank*/) { } //Before buying something from any vendor - virtual void OnBeforeBuyItemFromVendor(Player* /*player*/, uint64 /*vendorguid*/, uint32 /*vendorslot*/, uint32& /*item*/, uint8 /*count*/, uint8 /*bag*/, uint8 /*slot*/) { }; + virtual void OnBeforeBuyItemFromVendor(Player* /*player*/, ObjectGuid /*vendorguid*/, uint32 /*vendorslot*/, uint32& /*item*/, uint8 /*count*/, uint8 /*bag*/, uint8 /*slot*/) { }; //Before buying something from any vendor virtual void OnBeforeStoreOrEquipNewItem(Player* /*player*/, uint32 /*vendorslot*/, uint32& /*item*/, uint8 /*count*/, uint8 /*bag*/, uint8 /*slot*/, ItemTemplate const* /*pProto*/, Creature* /*pVendor*/, VendorItem const* /*crItem*/, bool /*bStore*/) { }; @@ -971,7 +971,7 @@ public: virtual void OnFirstLogin(Player* /*player*/) { } - [[nodiscard]] virtual bool CanJoinInBattlegroundQueue(Player* /*player*/, uint64 /*BattlemasterGuid*/, BattlegroundTypeId /*BGTypeID*/, uint8 /*joinAsGroup*/, GroupJoinBattlegroundResult& /*err*/) { return true; } + [[nodiscard]] virtual bool CanJoinInBattlegroundQueue(Player* /*player*/, ObjectGuid /*BattlemasterGuid*/, BattlegroundTypeId /*BGTypeID*/, uint8 /*joinAsGroup*/, GroupJoinBattlegroundResult& /*err*/) { return true; } virtual bool ShouldBeRewardedWithMoneyInsteadOfExp(Player* /*player*/) { return false; } // Called before the player's temporary summoned creature has initialized it's stats @@ -986,7 +986,7 @@ public: // Called before loading a player's pet from the DB virtual void OnBeforeLoadPetFromDB(Player* /*player*/, uint32& /*petentry*/, uint32& /*petnumber*/, bool& /*current*/, bool& /*forceLoadFromDB*/) { } - [[nodiscard]] virtual bool CanJoinInArenaQueue(Player* /*player*/, uint64 /*BattlemasterGuid*/, uint8 /*arenaslot*/, BattlegroundTypeId /*BGTypeID*/, uint8 /*joinAsGroup*/, uint8 /*IsRated*/, GroupJoinBattlegroundResult& /*err*/) { return true; } + [[nodiscard]] virtual bool CanJoinInArenaQueue(Player* /*player*/, ObjectGuid /*BattlemasterGuid*/, uint8 /*arenaslot*/, BattlegroundTypeId /*BGTypeID*/, uint8 /*joinAsGroup*/, uint8 /*IsRated*/, GroupJoinBattlegroundResult& /*err*/) { return true; } [[nodiscard]] virtual bool CanBattleFieldPort(Player* /*player*/, uint8 /*arenaType*/, BattlegroundTypeId /*BGTypeID*/, uint8 /*action*/) { return true; } @@ -996,7 +996,7 @@ public: [[nodiscard]] virtual bool CanSellItem(Player* /*player*/, Item* /*item*/, Creature* /*creature*/) { return true; } - [[nodiscard]] virtual bool CanSendMail(Player* /*player*/, uint64 /*receiverGuid*/, uint64 /*mailbox*/, std::string& /*subject*/, std::string& /*body*/, uint32 /*money*/, uint32 /*COD*/, Item* /*item*/) { return true; } + [[nodiscard]] virtual bool CanSendMail(Player* /*player*/, ObjectGuid /*receiverGuid*/, ObjectGuid /*mailbox*/, std::string& /*subject*/, std::string& /*body*/, uint32 /*money*/, uint32 /*COD*/, Item* /*item*/) { return true; } virtual void PetitionBuy(Player* /*player*/, Creature* /*creature*/, uint32& /*charterid*/, uint32& /*cost*/, uint32& /*type*/) { } @@ -1050,7 +1050,7 @@ public: virtual void OnGetQuestRate(Player* /*player*/, float& /*result*/) { } - [[nodiscard]] virtual bool PassedQuestKilledMonsterCredit(Player* /*player*/, Quest const* /*qinfo*/, uint32 /*entry*/, uint32 /*real_entry*/, uint64 /*guid*/) { return true; } + [[nodiscard]] virtual bool PassedQuestKilledMonsterCredit(Player* /*player*/, Quest const* /*qinfo*/, uint32 /*entry*/, uint32 /*real_entry*/, ObjectGuid /*guid*/) { return true; } [[nodiscard]] virtual bool CheckItemInSlotAtLoadInventory(Player* /*player*/, Item* /*item*/, uint8 /*slot*/, uint8& /*err*/, uint16& /*dest*/) { return true; } @@ -1145,9 +1145,9 @@ public: virtual void OnItemMove(Guild* /*guild*/, Player* /*player*/, Item* /*pItem*/, bool /*isSrcBank*/, uint8 /*srcContainer*/, uint8 /*srcSlotId*/, bool /*isDestBank*/, uint8 /*destContainer*/, uint8 /*destSlotId*/) { } - virtual void OnEvent(Guild* /*guild*/, uint8 /*eventType*/, uint32 /*playerGuid1*/, uint32 /*playerGuid2*/, uint8 /*newRank*/) { } + virtual void OnEvent(Guild* /*guild*/, uint8 /*eventType*/, ObjectGuid::LowType /*playerGuid1*/, ObjectGuid::LowType /*playerGuid2*/, uint8 /*newRank*/) { } - virtual void OnBankEvent(Guild* /*guild*/, uint8 /*eventType*/, uint8 /*tabId*/, uint32 /*playerGuid*/, uint32 /*itemOrMoney*/, uint16 /*itemStackCount*/, uint8 /*destTabId*/) { } + virtual void OnBankEvent(Guild* /*guild*/, uint8 /*eventType*/, uint8 /*tabId*/, ObjectGuid::LowType /*playerGuid*/, uint32 /*itemOrMoney*/, uint16 /*itemStackCount*/, uint8 /*destTabId*/) { } [[nodiscard]] virtual bool CanGuildSendBankList(Guild const* /*guild*/, WorldSession* /*session*/, uint8 /*tabId*/, bool /*sendAllSlots*/) { return true; } }; @@ -1161,16 +1161,16 @@ public: [[nodiscard]] bool IsDatabaseBound() const override { return false; } // Called when a member is added to a group. - virtual void OnAddMember(Group* /*group*/, uint64 /*guid*/) { } + virtual void OnAddMember(Group* /*group*/, ObjectGuid /*guid*/) { } // Called when a member is invited to join a group. - virtual void OnInviteMember(Group* /*group*/, uint64 /*guid*/) { } + virtual void OnInviteMember(Group* /*group*/, ObjectGuid /*guid*/) { } // Called when a member is removed from a group. - virtual void OnRemoveMember(Group* /*group*/, uint64 /*guid*/, RemoveMethod /*method*/, uint64 /*kicker*/, const char* /*reason*/) { } + virtual void OnRemoveMember(Group* /*group*/, ObjectGuid /*guid*/, RemoveMethod /*method*/, ObjectGuid /*kicker*/, const char* /*reason*/) { } // Called when the leader of a group is changed. - virtual void OnChangeLeader(Group* /*group*/, uint64 /*newLeaderGuid*/, uint64 /*oldLeaderGuid*/) { } + virtual void OnChangeLeader(Group* /*group*/, ObjectGuid /*newLeaderGuid*/, ObjectGuid /*oldLeaderGuid*/) { } // Called when a group is disbanded. virtual void OnDisband(Group* /*group*/) { } @@ -1188,7 +1188,7 @@ protected: public: // items - virtual void OnItemDelFromDB(SQLTransaction& /*trans*/, uint32 /*itemGuid*/) { } + virtual void OnItemDelFromDB(SQLTransaction& /*trans*/, ObjectGuid::LowType /*itemGuid*/) { } virtual void OnMirrorImageDisplayItem(const Item* /*item*/, uint32& /*display*/) { } // loot @@ -1200,7 +1200,7 @@ public: virtual void OnAfterInitializeLockedDungeons(Player* /*player*/) { } // On Before arena points distribution - virtual void OnBeforeUpdateArenaPoints(ArenaTeam* /*at*/, std::map<uint32, uint32>& /*ap*/) { } + virtual void OnBeforeUpdateArenaPoints(ArenaTeam* /*at*/, std::map<ObjectGuid, uint32>& /*ap*/) { } // Called when a dungeon encounter is updated. virtual void OnAfterUpdateEncounterState(Map* /*map*/, EncounterCreditType /*type*/, uint32 /*creditEntry*/, Unit* /*source*/, Difficulty /*difficulty_fixed*/, DungeonEncounterList const* /*encounters*/, uint32 /*dungeonCompleted*/, bool /*updated*/) { } @@ -1380,7 +1380,7 @@ public: bool IsDatabaseBound() const { return false; } - [[nodiscard]] virtual bool CanAddMember(ArenaTeam* /*team*/, uint64 /*PlayerGuid*/) { return true; } + [[nodiscard]] virtual bool CanAddMember(ArenaTeam* /*team*/, ObjectGuid /*PlayerGuid*/) { return true; } virtual void OnGetPoints(ArenaTeam* /*team*/, uint32 /*memberRating*/, float& /*points*/) { } @@ -1419,7 +1419,7 @@ public: [[nodiscard]] virtual bool CanItemApplyEquipSpell(Player* /*player*/, Item* /*item*/) { return true; } - [[nodiscard]] virtual bool CanSendAuctionHello(WorldSession const* /*session*/, uint64 /*guid*/, Creature* /*creature*/) { return true; } + [[nodiscard]] virtual bool CanSendAuctionHello(WorldSession const* /*session*/, ObjectGuid /*guid*/, Creature* /*creature*/) { return true; } virtual void ValidateSpellAtCastSpell(Player* /*player*/, uint32& /*oldSpellId*/, uint32& /*spellId*/, uint8& /*castCount*/, uint8& /*castFlags*/) { } @@ -1632,15 +1632,15 @@ public: /* PlayerScript */ void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild); void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel); void OnPlayerEmote(Player* player, uint32 emote); - void OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, uint64 guid); + void OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, ObjectGuid guid); void OnPlayerSpellCast(Player* player, Spell* spell, bool skipCheck); void OnPlayerLogin(Player* player); void OnPlayerLoadFromDB(Player* player); void OnPlayerLogout(Player* player); void OnPlayerCreate(Player* player); void OnPlayerSave(Player* player); - void OnPlayerDelete(uint64 guid, uint32 accountId); - void OnPlayerFailedDelete(uint64 guid, uint32 accountId); + void OnPlayerDelete(ObjectGuid guid, uint32 accountId); + void OnPlayerFailedDelete(ObjectGuid guid, uint32 accountId); void OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent); void OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea); void OnPlayerUpdateArea(Player* player, uint32 oldArea, uint32 newArea); @@ -1663,12 +1663,12 @@ public: /* PlayerScript */ void GetCustomGetArenaTeamId(const Player* player, uint8 slot, uint32& teamID) const; void GetCustomArenaPersonalRating(const Player* player, uint8 slot, uint32& rating) const; void OnGetMaxPersonalArenaRatingRequirement(const Player* player, uint32 minSlot, uint32& maxArenaRating) const; - void OnLootItem(Player* player, Item* item, uint32 count, uint64 lootguid); + void OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid lootguid); void OnCreateItem(Player* player, Item* item, uint32 count); void OnQuestRewardItem(Player* player, Item* item, uint32 count); bool OnBeforePlayerQuestComplete(Player* player, uint32 quest_id); - void OnBeforePlayerDurabilityRepair(Player* player, uint64 npcGUID, uint64 itemGUID, float& discountMod, uint8 guildBank); - void OnBeforeBuyItemFromVendor(Player* player, uint64 vendorguid, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot); + void OnBeforePlayerDurabilityRepair(Player* player, ObjectGuid npcGUID, ObjectGuid itemGUID, float& discountMod, uint8 guildBank); + void OnBeforeBuyItemFromVendor(Player* player, ObjectGuid vendorguid, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot); void OnBeforeStoreOrEquipNewItem(Player* player, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore); void OnAfterStoreOrEquipNewItem(Player* player, uint32 vendorslot, Item* item, uint8 count, uint8 bag, uint8 slot, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore); void OnAfterUpdateMaxPower(Player* player, Powers& power, float& value); @@ -1679,18 +1679,18 @@ public: /* PlayerScript */ void OnFirstLogin(Player* player); void OnPlayerCompleteQuest(Player* player, Quest const* quest); void OnBattlegroundDesertion(Player* player, BattlegroundDesertionType const desertionType); - bool CanJoinInBattlegroundQueue(Player* player, uint64 BattlemasterGuid, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, GroupJoinBattlegroundResult& err); + bool CanJoinInBattlegroundQueue(Player* player, ObjectGuid BattlemasterGuid, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, GroupJoinBattlegroundResult& err); bool ShouldBeRewardedWithMoneyInsteadOfExp(Player* player); void OnBeforeTempSummonInitStats(Player* player, TempSummon* tempSummon, uint32& duration); void OnBeforeGuardianInitStatsForLevel(Player* player, Guardian* guardian, CreatureTemplate const* cinfo, PetType& petType); void OnAfterGuardianInitStatsForLevel(Player* player, Guardian* guardian); void OnBeforeLoadPetFromDB(Player* player, uint32& petentry, uint32& petnumber, bool& current, bool& forceLoadFromDB); - bool CanJoinInArenaQueue(Player* player, uint64 BattlemasterGuid, uint8 arenaslot, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, uint8 IsRated, GroupJoinBattlegroundResult& err); + bool CanJoinInArenaQueue(Player* player, ObjectGuid BattlemasterGuid, uint8 arenaslot, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, uint8 IsRated, GroupJoinBattlegroundResult& err); bool CanBattleFieldPort(Player* player, uint8 arenaType, BattlegroundTypeId BGTypeID, uint8 action); bool CanGroupInvite(Player* player, std::string& membername); bool CanGroupAccept(Player* player, Group* group); bool CanSellItem(Player* player, Item* item, Creature* creature); - bool CanSendMail(Player* player, uint64 receiverGuid, uint64 mailbox, std::string& subject, std::string& body, uint32 money, uint32 COD, Item* item); + bool CanSendMail(Player* player, ObjectGuid receiverGuid, ObjectGuid mailbox, std::string& subject, std::string& body, uint32 money, uint32 COD, Item* item); void PetitionBuy(Player* player, Creature* creature, uint32& charterid, uint32& cost, uint32& type); void PetitionShowList(Player* player, Creature* creature, uint32& CharterEntry, uint32& CharterDispayID, uint32& CharterCost); void OnRewardKillRewarder(Player* player, bool isDungeon, float& rate); @@ -1717,7 +1717,7 @@ public: /* PlayerScript */ bool CanSaveEquipNewItem(Player* player, Item* item, uint16 pos, bool update); bool CanApplyEnchantment(Player* player, Item* item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition); void OnGetQuestRate(Player* player, float& result); - bool PassedQuestKilledMonsterCredit(Player* player, Quest const* qinfo, uint32 entry, uint32 real_entry, uint64 guid); + bool PassedQuestKilledMonsterCredit(Player* player, Quest const* qinfo, uint32 entry, uint32 real_entry, ObjectGuid guid); bool CheckItemInSlotAtLoadInventory(Player* player, Item* item, uint8 slot, uint8& err, uint16& dest); bool NotAvoidSatisfy(Player* player, DungeonProgressionRequirements const* ar, uint32 target_map, bool report); bool NotVisibleGloballyFor(Player* player, Player const* u); @@ -1753,23 +1753,23 @@ public: /* GuildScript */ void OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32& amount); void OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId); - void OnGuildEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank); - void OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); + void OnGuildEvent(Guild* guild, uint8 eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank); + void OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); bool CanGuildSendBankList(Guild const* guild, WorldSession* session, uint8 tabId, bool sendAllSlots); public: /* GroupScript */ - void OnGroupAddMember(Group* group, uint64 guid); - void OnGroupInviteMember(Group* group, uint64 guid); - void OnGroupRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, const char* reason); - void OnGroupChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid); + void OnGroupAddMember(Group* group, ObjectGuid guid); + void OnGroupInviteMember(Group* group, ObjectGuid guid); + void OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason); + void OnGroupChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid); void OnGroupDisband(Group* group); bool CanGroupJoinBattlegroundQueue(Group const* group, Player* member, Battleground const* bgTemplate, uint32 MinPlayerCount, bool isRated, uint32 arenaSlot); void OnCreate(Group* group, Player* leader); public: /* GlobalScript */ - void OnGlobalItemDelFromDB(SQLTransaction& trans, uint32 itemGuid); + void OnGlobalItemDelFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid); void OnGlobalMirrorImageDisplayItem(const Item* item, uint32& display); - void OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<uint32, uint32>& ap); + void OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<ObjectGuid, uint32>& ap); void OnAfterRefCount(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, uint32& maxcount, LootStore const& store); void OnBeforeDropAddItem(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, LootStore const& store); void OnItemRoll(Player const* player, LootStoreItem const* LootStoreItem, float& chance, Loot& loot, LootStore const& store); @@ -1874,7 +1874,7 @@ public: /* AchievementScript */ public: /* ArenaScript */ - bool CanAddMember(ArenaTeam* team, uint64 PlayerGuid); + bool CanAddMember(ArenaTeam* team, ObjectGuid PlayerGuid); void OnGetPoints(ArenaTeam* team, uint32 memberRating, float& points); bool CanSaveToDB(ArenaTeam* team); @@ -1891,7 +1891,7 @@ public: /* AchievementScript */ void OnItemCreate(Item* item, ItemTemplate const* itemProto, Player const* owner); bool CanApplySoulboundFlag(Item* item, ItemTemplate const* proto); bool CanItemApplyEquipSpell(Player* player, Item* item); - bool CanSendAuctionHello(WorldSession const* session, uint64 guid, Creature* creature); + bool CanSendAuctionHello(WorldSession const* session, ObjectGuid guid, Creature* creature); void ValidateSpellAtCastSpell(Player* player, uint32& oldSpellId, uint32& spellId, uint8& castCount, uint8& castFlags); void OnPlayerSetPhase(const AuraEffect* auraEff, AuraApplication const* aurApp, uint8 mode, bool apply, uint32& newPhase); void ValidateSpellAtCastSpellResult(Player* player, Unit* mover, Spell* spell, uint32 oldSpellId, uint32 spellId); diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 1dd8817a01..2b9460005b 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -114,7 +114,6 @@ WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 recruiterId(recruiter), isRecruiter(isARecruiter), m_currentVendorEntry(0), - m_currentBankerGUID(0), timeWhoCommandAllowed(0), _calendarEventCreationCooldown(0), _timeSyncClockDeltaQueue(6), @@ -191,9 +190,9 @@ std::string WorldSession::GetPlayerInfo() const } /// Get player guid if available. Use for logging purposes only -uint32 WorldSession::GetGuidLow() const +ObjectGuid::LowType WorldSession::GetGuidLow() const { - return GetPlayer() ? GetPlayer()->GetGUIDLow() : 0; + return GetPlayer() ? GetPlayer()->GetGUID().GetCounter() : 0; } /// Send a packet to the client @@ -472,7 +471,7 @@ void WorldSession::HandleTeleportTimeout(bool updateInSessions) if (!plMover) break; WorldPacket pkt(MSG_MOVE_TELEPORT_ACK, 20); - pkt.append(plMover->GetPackGUID()); + pkt << plMover->GetPackGUID(); pkt << uint32(0); // flags pkt << uint32(0); // time HandleMoveTeleportAck(pkt); @@ -493,7 +492,7 @@ void WorldSession::LogoutPlayer(bool save) if (_player) { - if (uint64 lguid = _player->GetLootGUID()) + if (ObjectGuid lguid = _player->GetLootGUID()) DoLootRelease(lguid); ///- If the player just died before logging out, make him appear as a ghost @@ -540,7 +539,7 @@ void WorldSession::LogoutPlayer(bool save) if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK); - stmt->setUInt32(0, _player->GetGUIDLow()); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); stmt->setUInt8(1, BG_DESERTION_TYPE_INVITE_LOGOUT); CharacterDatabase.Execute(stmt); } @@ -585,7 +584,7 @@ void WorldSession::LogoutPlayer(bool save) for (int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; ++j) { eslot = j - BUYBACK_SLOT_START; - _player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0); + _player->SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), ObjectGuid::Empty); _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0); _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0); } @@ -609,13 +608,14 @@ void WorldSession::LogoutPlayer(bool save) } //! Broadcast a logout message to the player's friends - sSocialMgr->SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), true); - sSocialMgr->RemovePlayerSocial(_player->GetGUIDLow()); + sSocialMgr->SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUID(), true); + sSocialMgr->RemovePlayerSocial(_player->GetGUID()); //! Call script hook before deletion sScriptMgr->OnPlayerLogout(_player); - LOG_INFO("entities.player", "Account: %d (IP: %s) Logout Character:[%s] (GUID: %u) Level: %d", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName().c_str(), _player->GetGUIDLow(), _player->getLevel()); + LOG_INFO("entities.player", "Account: %d (IP: %s) Logout Character:[%s] (%s) Level: %d", + GetAccountId(), GetRemoteAddress().c_str(), _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), _player->getLevel()); //! Remove the player from the world // the player may not be in the world when logging out @@ -865,7 +865,7 @@ void WorldSession::ReadMovementInfo(WorldPacket& data, MovementInfo* mi) if (mi->HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT)) { - data.readPackGUID(mi->transport.guid); + data >> mi->transport.guid.ReadAsPacked(); data >> mi->transport.pos.PositionXYZOStream(); data >> mi->transport.time; @@ -899,8 +899,8 @@ void WorldSession::ReadMovementInfo(WorldPacket& data, MovementInfo* mi) if (check) \ { \ LOG_DEBUG("entities.unit", "WorldSession::ReadMovementInfo: Violation of MovementFlags found (%s). " \ - "MovementFlags: %u, MovementFlags2: %u for player GUID: %u. Mask %u will be removed.", \ - STRINGIZE(check), mi->GetMovementFlags(), mi->GetExtraMovementFlags(), GetPlayer()->GetGUIDLow(), maskToRemove); \ + "MovementFlags: %u, MovementFlags2: %u for player %s. Mask %u will be removed.", \ + STRINGIZE(check), mi->GetMovementFlags(), mi->GetExtraMovementFlags(), GetPlayer()->GetGUID().ToString().c_str(), maskToRemove); \ mi->RemoveMovementFlag((maskToRemove)); \ } \ } @@ -972,7 +972,7 @@ void WorldSession::ReadMovementInfo(WorldPacket& data, MovementInfo* mi) void WorldSession::WriteMovementInfo(WorldPacket* data, MovementInfo* mi) { - data->appendPackGUID(mi->guid); + *data << mi->guid.WriteAsPacked(); *data << mi->flags; *data << mi->flags2; @@ -981,7 +981,7 @@ void WorldSession::WriteMovementInfo(WorldPacket* data, MovementInfo* mi) if (mi->HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT)) { - data->appendPackGUID(mi->transport.guid); + *data << mi->transport.guid.WriteAsPacked(); *data << mi->transport.pos.PositionXYZOStream(); *data << mi->transport.time; @@ -1174,7 +1174,7 @@ void WorldSession::SetPlayer(Player* player) { _player = player; if (_player) - m_GUIDLow = _player->GetGUIDLow(); + m_GUIDLow = _player->GetGUID().GetCounter(); } void WorldSession::InitializeQueryCallbackParameters() @@ -1211,7 +1211,7 @@ void WorldSession::ProcessQueryCallbackPlayer() { uint8 bagIndex = _openWrappedItemCallback.GetFirstParam(); uint8 slot = _openWrappedItemCallback.GetSecondParam(); - uint32 itemLowGUID = _openWrappedItemCallback.GetThirdParam(); + ObjectGuid::LowType itemLowGUID = _openWrappedItemCallback.GetThirdParam(); _openWrappedItemCallback.GetResult(result); HandleOpenWrappedItemCallback(result, bagIndex, slot, itemLowGUID); _openWrappedItemCallback.FreeResult(); @@ -1233,7 +1233,7 @@ void WorldSession::ProcessQueryCallbackPet() //- SendStabledPet if (_sendStabledPetCallback.IsReady()) { - uint64 param = _sendStabledPetCallback.GetParam(); + ObjectGuid param = _sendStabledPetCallback.GetParam(); _sendStabledPetCallback.GetResult(result); SendStablePetCallback(result, param); _sendStabledPetCallback.FreeResult(); diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index f4ffb2fc63..45da8c8e38 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -232,7 +232,7 @@ public: uint32 GetCurrentVendor() const { return m_currentVendorEntry; } void SetCurrentVendor(uint32 vendorEntry) { m_currentVendorEntry = vendorEntry; } - uint32 GetGuidLow() const; + ObjectGuid::LowType GetGuidLow() const; void SetSecurity(AccountTypes security) { _security = security; } std::string const& GetRemoteAddress() { return m_Address; } void SetPlayer(Player* player); @@ -271,38 +271,38 @@ public: /// Handle the authentication waiting queue (to be completed) void SendAuthWaitQue(uint32 position); - //void SendTestCreatureQueryOpcode(uint32 entry, uint64 guid, uint32 testvalue); - void SendNameQueryOpcode(uint64 guid); + //void SendTestCreatureQueryOpcode(uint32 entry, ObjectGuid guid, uint32 testvalue); + void SendNameQueryOpcode(ObjectGuid guid); - void SendTrainerList(uint64 guid); - void SendTrainerList(uint64 guid, std::string const& strTitle); - void SendListInventory(uint64 guid, uint32 vendorEntry = 0); - void SendShowBank(uint64 guid); - bool CanOpenMailBox(uint64 guid); - void SendShowMailBox(uint64 guid); - void SendTabardVendorActivate(uint64 guid); + void SendTrainerList(ObjectGuid guid); + void SendTrainerList(ObjectGuid guid, std::string const& strTitle); + void SendListInventory(ObjectGuid guid, uint32 vendorEntry = 0); + void SendShowBank(ObjectGuid guid); + bool CanOpenMailBox(ObjectGuid guid); + void SendShowMailBox(ObjectGuid guid); + void SendTabardVendorActivate(ObjectGuid guid); void SendSpiritResurrect(); void SendBindPoint(Creature* npc); void SendAttackStop(Unit const* enemy); - void SendBattleGroundList(uint64 guid, BattlegroundTypeId bgTypeId = BATTLEGROUND_RB); + void SendBattleGroundList(ObjectGuid guid, BattlegroundTypeId bgTypeId = BATTLEGROUND_RB); void SendTradeStatus(TradeStatus status); void SendUpdateTrade(bool trader_data = true); void SendCancelTrade(); - void SendPetitionQueryOpcode(uint64 petitionguid); + void SendPetitionQueryOpcode(ObjectGuid petitionguid); // Spell void HandleClientCastFlags(WorldPacket& recvPacket, uint8 castFlags, SpellCastTargets& targets); // Pet - void SendPetNameQuery(uint64 guid, uint32 petnumber); - void SendStablePet(uint64 guid); - void SendStablePetCallback(PreparedQueryResult result, uint64 guid); + void SendPetNameQuery(ObjectGuid guid, uint32 petnumber); + void SendStablePet(ObjectGuid guid); + void SendStablePetCallback(PreparedQueryResult result, ObjectGuid guid); void SendStableResult(uint8 guid); - bool CheckStableMaster(uint64 guid); + bool CheckStableMaster(ObjectGuid guid); // Account Data AccountData* GetAccountData(AccountDataType type) { return &m_accountData[type]; } @@ -324,17 +324,17 @@ public: } } //auction - void SendAuctionHello(uint64 guid, Creature* unit); + void SendAuctionHello(ObjectGuid guid, Creature* unit); void SendAuctionCommandResult(uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError = 0); - void SendAuctionBidderNotification(uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template); + void SendAuctionBidderNotification(uint32 location, uint32 auctionId, ObjectGuid bidder, uint32 bidSum, uint32 diff, uint32 item_template); void SendAuctionOwnerNotification(AuctionEntry* auction); //Item Enchantment - void SendEnchantmentLog(uint64 target, uint64 caster, uint32 itemId, uint32 enchantId); - void SendItemEnchantTimeUpdate(uint64 Playerguid, uint64 Itemguid, uint32 slot, uint32 Duration); + void SendEnchantmentLog(ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId); + void SendItemEnchantTimeUpdate(ObjectGuid Playerguid, ObjectGuid Itemguid, uint32 slot, uint32 Duration); //Taxi - void SendTaxiStatus(uint64 guid); + void SendTaxiStatus(ObjectGuid guid); void SendTaxiMenu(Creature* unit); void SendDoFlight(uint32 mountDisplayId, uint32 path, uint32 pathNode = 0); bool SendLearnNewTaxiNode(Creature* unit); @@ -343,11 +343,11 @@ public: // Guild/Arena Team void SendArenaTeamCommandResult(uint32 team_action, std::string const& team, std::string const& player, uint32 error_id = 0); void SendNotInArenaTeamPacket(uint8 type); - void SendPetitionShowList(uint64 guid); + void SendPetitionShowList(ObjectGuid guid); void BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket* data); - void DoLootRelease(uint64 lguid); + void DoLootRelease(ObjectGuid lguid); // Account mute time time_t m_muteTime; @@ -594,7 +594,7 @@ public: // opcodes handlers void HandleStableRevivePet(WorldPacket& recvPacket); void HandleStableSwapPet(WorldPacket& recvPacket); void HandleStableSwapPetCallback(PreparedQueryResult result, uint32 petId); - void HandleOpenWrappedItemCallback(PreparedQueryResult result, uint8 bagIndex, uint8 slot, uint32 itemLowGUID); + void HandleOpenWrappedItemCallback(PreparedQueryResult result, uint8 bagIndex, uint8 slot, ObjectGuid::LowType itemLowGUID); void HandleLoadActionsSwitchSpec(PreparedQueryResult result); void HandleCharacterAuraFrozen(PreparedQueryResult result); uint8 HandleLoadPetFromDBFirstCallback(PreparedQueryResult result, uint8 asynchLoadType); @@ -620,7 +620,7 @@ public: // opcodes handlers void HandleAuctionSellItem(WorldPacket& recvData); void HandleAuctionRemoveItem(WorldPacket& recvData); void HandleAuctionListOwnerItems(WorldPacket& recvData); - void HandleAuctionListOwnerItemsEvent(uint64 creatureGuid); + void HandleAuctionListOwnerItemsEvent(ObjectGuid creatureGuid); void HandleAuctionPlaceBid(WorldPacket& recvData); void HandleAuctionListPendingSales(WorldPacket& recvData); @@ -736,7 +736,7 @@ public: // opcodes handlers //Pet void HandlePetAction(WorldPacket& recvData); void HandlePetStopAttack(WorldPacket& recvData); - void HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid, uint16 flag, uint64 guid2); + void HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint16 spellid, uint16 flag, ObjectGuid guid2); void HandlePetNameQuery(WorldPacket& recvData); void HandlePetSetAction(WorldPacket& recvData); void HandlePetAbandon(WorldPacket& recvData); @@ -810,7 +810,7 @@ public: // opcodes handlers void SendLfgUpdatePlayer(lfg::LfgUpdateData const& updateData); void SendLfgUpdateParty(lfg::LfgUpdateData const& updateData); - void SendLfgRoleChosen(uint64 guid, uint8 roles); + void SendLfgRoleChosen(ObjectGuid guid, uint8 roles); void SendLfgRoleCheckUpdate(lfg::LfgRoleCheck const& pRoleCheck); void SendLfgLfrList(bool update); void SendLfgJoinResult(lfg::LfgJoinResultData const& joinData); @@ -942,7 +942,7 @@ private: QueryCallback<PreparedQueryResult, std::string> _charRenameCallback; QueryCallback<PreparedQueryResult, uint32> _unstablePetCallback; QueryCallback<PreparedQueryResult, uint32> _stableSwapCallback; - QueryCallback<PreparedQueryResult, uint64> _sendStabledPetCallback; + QueryCallback<PreparedQueryResult, ObjectGuid> _sendStabledPetCallback; QueryCallback<PreparedQueryResult, CharacterCreateInfo*, true> _charCreateCallback; QueryResultHolderFuture _charLoginCallback; @@ -993,21 +993,21 @@ private: // private trade methods void moveItems(Item* myItems[], Item* hisItems[]); - bool CanUseBank(uint64 bankerGUID = 0) const; + bool CanUseBank(ObjectGuid bankerGUID = ObjectGuid::Empty) const; bool recoveryItem(Item* pItem); // EnumData helpers - bool IsLegitCharacterForAccount(uint32 lowGUID) + bool IsLegitCharacterForAccount(ObjectGuid guid) { - return _legitCharacters.find(lowGUID) != _legitCharacters.end(); + return _legitCharacters.find(guid) != _legitCharacters.end(); } // this stores the GUIDs of the characters who can login // characters who failed on Player::BuildEnumData shouldn't login - std::set<uint32> _legitCharacters; + GuidSet _legitCharacters; - uint32 m_GUIDLow; + ObjectGuid::LowType m_GUIDLow; Player* _player; WorldSocket* m_Socket; std::string m_Address; @@ -1040,7 +1040,7 @@ private: bool isRecruiter; LockedQueue<WorldPacket*> _recvQueue; uint32 m_currentVendorEntry; - uint64 m_currentBankerGUID; + ObjectGuid m_currentBankerGUID; time_t timeWhoCommandAllowed; uint32 _offlineTime; bool _kicked; diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 31b4539e0d..23ffd0c341 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -478,7 +478,8 @@ int WorldSocket::handle_input_header(void) if ((header.size < 4) || (header.size > 10240) || (header.cmd > 10240)) { Player* _player = m_Session ? m_Session->GetPlayer() : nullptr; - LOG_ERROR("server", "WorldSocket::handle_input_header(): client (account: %u, char [GUID: %u, name: %s]) sent malformed packet (size: %d, cmd: %d)", m_Session ? m_Session->GetAccountId() : 0, _player ? _player->GetGUIDLow() : 0, _player ? _player->GetName().c_str() : "<none>", header.size, header.cmd); + LOG_ERROR("server", "WorldSocket::handle_input_header(): client (account: %u, char [%s, name: %s]) sent malformed packet (size: %d, cmd: %d)", + m_Session ? m_Session->GetAccountId() : 0, _player ? _player->GetGUID().ToString().c_str() : "", _player ? _player->GetName().c_str() : "<none>", header.size, header.cmd); errno = EINVAL; return -1; @@ -1053,9 +1054,9 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket) if (m_Session && AccountMgr::IsPlayerAccount(m_Session->GetSecurity())) { Player* _player = m_Session->GetPlayer(); - LOG_ERROR("server", "WorldSocket::HandlePing: Player (account: %u, GUID: %u, name: %s) kicked for over-speed pings (address: %s)", + LOG_ERROR("server", "WorldSocket::HandlePing: Player (account: %u, %s, name: %s) kicked for over-speed pings (address: %s)", m_Session->GetAccountId(), - _player ? _player->GetGUIDLow() : 0, + _player ? _player->GetGUID().ToString().c_str() : "", _player ? _player->GetName().c_str() : "<none>", GetRemoteAddress().c_str()); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 7d34ca8632..1077669761 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -387,7 +387,7 @@ AuraEffect::AuraEffect(Aura* base, uint8 effIndex, int32* baseAmount, Unit* cast // Xinef: channel data structure if (caster) if (Spell* spell = caster->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) - m_channelData = new ChannelTargetData(caster->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT), spell->m_targets.HasDst() ? spell->m_targets.GetDst() : nullptr); + m_channelData = new ChannelTargetData(caster->GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT), spell->m_targets.HasDst() ? spell->m_targets.GetDst() : nullptr); } AuraEffect::~AuraEffect() @@ -445,7 +445,7 @@ int32 AuraEffect::CalculateAmount(Unit* caster) // check item enchant aura cast if (!amount && caster) - if (uint64 itemGUID = GetBase()->GetCastItemGUID()) + if (ObjectGuid itemGUID = GetBase()->GetCastItemGUID()) if (Player* playerCaster = caster->ToPlayer()) if (Item* castItem = playerCaster->GetItemByGuid(itemGUID)) if (castItem->GetItemSuffixFactor()) @@ -807,7 +807,7 @@ void AuraEffect::ApplySpellMod(Unit* target, bool apply) case SPELLMOD_EFFECT2: case SPELLMOD_EFFECT3: { - uint64 guid = target->GetGUID(); + ObjectGuid guid = target->GetGUID(); Unit::AuraApplicationMap& auras = target->GetAppliedAuras(); for (Unit::AuraApplicationMap::iterator iter = auras.begin(); iter != auras.end(); ++iter) { @@ -846,7 +846,7 @@ void AuraEffect::ApplySpellMod(Unit* target, bool apply) if (!pet) break; - uint64 petguid = pet->GetGUID(); + ObjectGuid petguid = pet->GetGUID(); Unit::AuraApplicationMap& petauras = pet->GetAppliedAuras(); for (Unit::AuraApplicationMap::iterator iter = petauras.begin(); iter != petauras.end(); ++iter) { @@ -1509,7 +1509,7 @@ void AuraEffect::HandleModInvisibilityDetect(AuraApplication const* aurApp, uint } // call functions which may have additional effects after chainging state of unit - target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(target->GetOwnerGUID())); + target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer()); } void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -1568,11 +1568,11 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode if (!apply && aurApp->GetRemoveMode() == AURA_REMOVE_BY_DEFAULT) { - target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(target->GetOwnerGUID() || target->GetMap()->Instanceable()), true); + target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable(), true); target->bRequestForcedVisibilityUpdate = false; } else - target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(target->GetOwnerGUID()) || target->GetMap()->Instanceable()); + target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable()); } void AuraEffect::HandleModStealthDetect(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -1597,7 +1597,7 @@ void AuraEffect::HandleModStealthDetect(AuraApplication const* aurApp, uint8 mod } // call functions which may have additional effects after chainging state of unit - target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(target->GetOwnerGUID())); + target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer()); } void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -1647,11 +1647,11 @@ void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, boo if (!apply && aurApp->GetRemoveMode() == AURA_REMOVE_BY_DEFAULT) { - target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(target->GetOwnerGUID() || target->GetMap()->Instanceable()), true); + target->UpdateObjectVisibility((target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable()), true); target->bRequestForcedVisibilityUpdate = false; } else - target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(target->GetOwnerGUID() || target->GetMap()->Instanceable())); + target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable()); } void AuraEffect::HandleModStealthLevel(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -1668,7 +1668,7 @@ void AuraEffect::HandleModStealthLevel(AuraApplication const* aurApp, uint8 mode target->m_stealth.AddValue(type, -GetAmount()); // call functions which may have additional effects after chainging state of unit - target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(target->GetOwnerGUID())); + target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer()); } void AuraEffect::HandleDetectAmore(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -1794,7 +1794,7 @@ void AuraEffect::HandlePhase(AuraApplication const* aurApp, uint8 mode, bool app { newPhase = PHASEMASK_NORMAL; if (Creature* creature = target->ToCreature()) - if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetDBTableGUIDLow())) + if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetSpawnId())) newPhase = data->phaseMask; } @@ -1915,7 +1915,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo // remove other shapeshift before applying a new one // xinef: rogue shouldnt be wrapped by this check (shadow dance vs stealth) if (GetSpellInfo()->SpellFamilyName != SPELLFAMILY_ROGUE) - target->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT, 0, GetBase()); + target->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT, ObjectGuid::Empty, GetBase()); // stop handling the effect if it was removed by linked event if (aurApp->GetRemoveMode()) @@ -2298,7 +2298,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode, { // for players, start regeneration after 1s (in polymorph fast regeneration case) // only if caster is Player (after patch 2.4.2) - if (IS_PLAYER_GUID(GetCasterGUID())) + if (GetCasterGUID().IsPlayer()) target->ToPlayer()->setRegenTimerCount(1 * IN_MILLISECONDS); //dismount polymorphed target (after patch 2.4.2) @@ -3731,7 +3731,7 @@ void AuraEffect::HandleAuraModStateImmunity(AuraApplication const* aurApp, uint8 target->ApplySpellImmune(GetId(), IMMUNITY_STATE, GetMiscValue(), apply); if (apply && GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY)) - target->RemoveAurasByType(AuraType(GetMiscValue()), 0, GetBase()); + target->RemoveAurasByType(AuraType(GetMiscValue()), ObjectGuid::Empty, GetBase()); } void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -5180,7 +5180,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool { Unit* caster = GetBase()->GetCaster(); if (caster && caster->GetTypeId() == TYPEID_PLAYER) - caster->ToPlayer()->KilledMonsterCredit(25987, 0); + caster->ToPlayer()->KilledMonsterCredit(25987); } return; } @@ -5569,13 +5569,13 @@ void AuraEffect::HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, boo } else { - uint64 casterGUID = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo, GetEffIndex()) ? GetCasterGUID() : target->GetGUID(); + ObjectGuid casterGUID = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo, GetEffIndex()) ? GetCasterGUID() : target->GetGUID(); target->RemoveAura(triggeredSpellId, casterGUID, 0, aurApp->GetRemoveMode()); } } else if (mode & AURA_EFFECT_HANDLE_REAPPLY && apply) { - uint64 casterGUID = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo, GetEffIndex()) ? GetCasterGUID() : target->GetGUID(); + ObjectGuid casterGUID = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo, GetEffIndex()) ? GetCasterGUID() : target->GetGUID(); // change the stack amount to be equal to stack amount of our aura if (Aura* triggeredAura = target->GetAura(triggeredSpellId, casterGUID)) triggeredAura->ModStackAmount(GetBase()->GetStackAmount() - triggeredAura->GetStackAmount()); @@ -5690,7 +5690,7 @@ void AuraEffect::HandleAuraSetVehicle(AuraApplication const* aurApp, uint8 mode, target->RemoveVehicleKit(); WorldPacket data(SMSG_PLAYER_VEHICLE_DATA, target->GetPackGUID().size() + 4); - data.appendPackGUID(target->GetGUID()); + data << target->GetPackGUID(); data << uint32(apply ? vehicleId : 0); target->SendMessageToSet(&data, true); @@ -5972,7 +5972,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster) case 28820: { // Need remove self if Lightning Shield not active - if (!target->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_SHAMAN, 0x400)) + if (!target->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_SHAMAN, 0x400, 0, 0)) target->RemoveAurasDueToSpell(28820); return; } @@ -6255,8 +6255,8 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const Unit::CalcAbsorbResist(caster, target, GetSpellInfo()->GetSchoolMask(), DOT, damage, &absorb, &resist, GetSpellInfo()); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u", - GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), damage, GetId(), absorb); + LOG_DEBUG("server", "PeriodicTick: %s attacked %s for %u dmg inflicted by %u abs is %u", + GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId(), absorb); #endif Unit::DealDamageMods(target, damage, &absorb); @@ -6351,8 +6351,8 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c damage = target->GetHealth(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u", - GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), damage, GetId(), absorb); + LOG_DEBUG("server", "PeriodicTick: %s health leech of %s for %u dmg inflicted by %u abs is %u", + GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId(), absorb); #endif if (caster) caster->SendSpellNonMeleeDamageLog(target, GetId(), damage + absorb + resist, GetSpellInfo()->GetSchoolMask(), absorb, resist, false, 0, crit); @@ -6498,8 +6498,8 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const damage = Unit::SpellCriticalHealingBonus(caster, GetSpellInfo(), damage, target); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u", - GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), damage, GetId()); + LOG_DEBUG("server", "PeriodicTick: %s heal of %s for %u health inflicted by %u", + GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId()); #endif uint32 absorb = 0; uint32 heal = uint32(damage); @@ -6516,7 +6516,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const if (caster) target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, GetSpellInfo()); - bool haveCastItem = GetBase()->GetCastItemGUID() != 0; + bool haveCastItem = GetBase()->GetCastItemGUID(); // Health Funnel // damage caster for heal amount @@ -6578,8 +6578,8 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u", - GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), drainAmount, GetId()); + LOG_DEBUG("server", "PeriodicTick: %s power leech of %s for %u dmg inflicted by %u", + GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), drainAmount, GetId()); #endif // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) if (PowerType == POWER_MANA) @@ -6645,8 +6645,8 @@ void AuraEffect::HandleObsModPowerAuraTick(Unit* target, Unit* caster) const // ignore negative values (can be result apply spellmods to aura damage uint32 amount = std::max(m_amount, 0) * target->GetMaxPower(PowerType) / 100; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u", - GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), amount, GetId()); + LOG_DEBUG("server", "PeriodicTick: %s energize %s for %u dmg inflicted by %u", + GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), amount, GetId()); #endif SpellPeriodicAuraLogInfo pInfo(this, amount, 0, 0, 0, 0.0f, false); target->SendPeriodicAuraLog(&pInfo); @@ -6684,8 +6684,8 @@ void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) cons target->SendPeriodicAuraLog(&pInfo); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("server", "PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u", - GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), amount, GetId()); + LOG_DEBUG("server", "PeriodicTick: %s energize %s for %u dmg inflicted by %u", + GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), amount, GetId()); #endif int32 gain = target->ModifyPower(PowerType, amount); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index fd951adc4e..12557f282d 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -20,14 +20,14 @@ typedef void(AuraEffect::*pAuraEffectHandler)(AuraApplication const* aurApp, uin class AuraEffect { friend void Aura::_InitEffects(uint8 effMask, Unit* caster, int32* baseAmount); - friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID, bool noPeriodicReset); + friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID, bool noPeriodicReset); friend Aura::~Aura(); private: ~AuraEffect(); explicit AuraEffect(Aura* base, uint8 effIndex, int32* baseAmount, Unit* caster); public: Unit* GetCaster() const { return GetBase()->GetCaster(); } - uint64 GetCasterGUID() const { return GetBase()->GetCasterGUID(); } + ObjectGuid GetCasterGUID() const { return GetBase()->GetCasterGUID(); } Aura* GetBase() const { return m_base; } void GetTargetList(std::list<Unit*>& targetList) const; void GetApplicationList(std::list<AuraApplication*>& applicationList) const; diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index bf119fcd97..c54854904c 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -259,7 +259,7 @@ void AuraApplication::BuildUpdatePacket(ByteBuffer& data, bool remove) const data << uint8(aura->GetSpellInfo()->StackAmount ? aura->GetStackAmount() : aura->GetCharges()); if (!(flags & AFLAG_CASTER)) - data.appendPackGUID(aura->GetCasterGUID()); + data << aura->GetCasterGUID().WriteAsPacked(); if (flags & AFLAG_DURATION) { @@ -273,7 +273,7 @@ void AuraApplication::ClientUpdate(bool remove) _needClientUpdate = false; WorldPacket data(SMSG_AURA_UPDATE); - data.append(GetTarget()->GetPackGUID()); + data << GetTarget()->GetPackGUID(); BuildUpdatePacket(data, remove); if (GetSlot() < MAX_AURAS) @@ -313,7 +313,7 @@ uint8 Aura::BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 avalibleE return effMask & avalibleEffectMask; } -Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, uint64 casterGUID /*= 0*/, bool* refresh /*= nullptr*/, bool periodicReset /*= false*/) +Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/, bool* refresh /*= nullptr*/, bool periodicReset /*= false*/) { ASSERT(spellproto); ASSERT(owner); @@ -339,7 +339,7 @@ Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMas return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID); } -Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, uint64 casterGUID /*= 0*/) +Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/) { ASSERT(spellproto); ASSERT(owner); @@ -351,7 +351,7 @@ Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID); } -Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID) +Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID) { ASSERT(effMask); ASSERT(spellproto); @@ -396,9 +396,9 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne return aura; } -Aura::Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, uint64 casterGUID) : +Aura::Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, ObjectGuid casterGUID) : m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID()), - m_castItemGuid(castItem ? castItem->GetGUID() : 0), m_castItemEntry(castItem ? castItem->GetEntry() : 0), m_applyTime(time(nullptr)), + m_castItemGuid(castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_castItemEntry(castItem ? castItem->GetEntry() : 0), m_applyTime(time(nullptr)), m_owner(owner), m_timeCla(0), m_updateTargetMapInterval(0), m_casterLevel(caster ? caster->getLevel() : m_spellInfo->SpellLevel), m_procCharges(0), m_stackAmount(1), m_isRemoved(false), m_isSingleTarget(false), m_isUsingCharges(false) @@ -504,8 +504,8 @@ void Aura::_UnapplyForTarget(Unit* target, Unit* caster, AuraApplication* auraAp // TODO: Figure out why this happens if (itr == m_applications.end()) { - LOG_ERROR("server", "Aura::_UnapplyForTarget, target:%u, caster:%u, spell:%u was not found in owners application map!", - target->GetGUIDLow(), caster ? caster->GetGUIDLow() : 0, auraApp->GetBase()->GetSpellInfo()->Id); + LOG_ERROR("server", "Aura::_UnapplyForTarget, target:%s, caster:%s, spell:%u was not found in owners application map!", + target->GetGUID().ToString().c_str(), caster ? caster->GetGUID().ToString().c_str() : "", auraApp->GetBase()->GetSpellInfo()->Id); ABORT(); } @@ -1107,9 +1107,6 @@ void Aura::UnregisterSingleTarget() { ASSERT(m_isSingleTarget); Unit* caster = GetCaster(); - // TODO: find a better way to do this. - if (!caster) - caster = ObjectAccessor::GetObjectInOrOutOfWorld(GetCasterGUID(), (Unit*)nullptr); if (!caster) { LOG_INFO("misc", "Aura::UnregisterSingleTarget (A1) - %u, %u, %u, %s", GetId(), GetOwner()->GetTypeId(), GetOwner()->GetEntry(), GetOwner()->GetName().c_str()); @@ -1699,7 +1696,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b WorldPacket data(SMSG_MODIFY_COOLDOWN, 4 + 8 + 4); data << uint32(GetId()); // Spell ID - data << uint64(player->GetGUID()); // Player GUID + data << player->GetGUID(); // Player GUID data << int32(-110000); // Cooldown mod in milliseconds player->SendDirectMessage(&data); } @@ -1719,7 +1716,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b } // Remove Vanish on stealth remove if (GetId() == 1784) - target->RemoveAurasWithFamily(SPELLFAMILY_ROGUE, 0x800, 0, 0, 0); + target->RemoveAurasWithFamily(SPELLFAMILY_ROGUE, 0x800, 0, 0, ObjectGuid::Empty); break; } @@ -2595,7 +2592,7 @@ void Aura::CallScriptAfterEffectProcHandlers(AuraEffect const* aurEff, AuraAppli } } -UnitAura::UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID) +UnitAura::UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID) : Aura(spellproto, owner, caster, castItem, casterGUID) { m_AuraDRGroup = DIMINISHING_NONE; @@ -2698,7 +2695,7 @@ void UnitAura::FillTargetMap(std::map<Unit*, uint8>& targets, Unit* caster) } } -DynObjAura::DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID) +DynObjAura::DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID) : Aura(spellproto, owner, caster, castItem, casterGUID) { LoadScripts(); diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index f4439ebc47..2317cd77ca 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -75,24 +75,24 @@ public: class Aura { - friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID, bool noPeriodicReset); + friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID, bool noPeriodicReset); public: - typedef std::map<uint64, AuraApplication*> ApplicationMap; + typedef std::map<ObjectGuid, AuraApplication*> ApplicationMap; static uint8 BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 avalibleEffectMask, WorldObject* owner); - static Aura* TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, uint64 casterGUID = 0, bool* refresh = nullptr, bool periodicReset = false); - static Aura* TryCreate(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, uint64 casterGUID = 0); - static Aura* Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID); - explicit Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, uint64 casterGUID); + static Aura* TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, ObjectGuid casterGUID = ObjectGuid::Empty, bool* refresh = nullptr, bool periodicReset = false); + static Aura* TryCreate(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, ObjectGuid casterGUID = ObjectGuid::Empty); + static Aura* Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID); + explicit Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, ObjectGuid casterGUID); void _InitEffects(uint8 effMask, Unit* caster, int32* baseAmount); virtual ~Aura(); SpellInfo const* GetSpellInfo() const { return m_spellInfo; } uint32 GetId() const; - uint64 GetCastItemGUID() const { return m_castItemGuid; } + ObjectGuid GetCastItemGUID() const { return m_castItemGuid; } uint32 GetCastItemEntry() const { return m_castItemEntry; } - uint64 GetCasterGUID() const { return m_casterGuid; } + ObjectGuid GetCasterGUID() const { return m_casterGuid; } Unit* GetCaster() const; WorldObject* GetOwner() const { return m_owner; } Unit* GetUnitOwner() const { ASSERT(GetType() == UNIT_AURA_TYPE); return (Unit*)m_owner; } @@ -170,9 +170,9 @@ public: // Helpers for targets ApplicationMap const& GetApplicationMap() {return m_applications;} void GetApplicationList(std::list<AuraApplication*>& applicationList) const; - const AuraApplication* GetApplicationOfTarget (uint64 guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return nullptr; } - AuraApplication* GetApplicationOfTarget (uint64 guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return nullptr; } - bool IsAppliedOnTarget(uint64 guid) const { return m_applications.find(guid) != m_applications.end(); } + const AuraApplication* GetApplicationOfTarget (ObjectGuid guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return nullptr; } + AuraApplication* GetApplicationOfTarget (ObjectGuid guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return nullptr; } + bool IsAppliedOnTarget(ObjectGuid guid) const { return m_applications.find(guid) != m_applications.end(); } void SetNeedClientUpdateForTargets() const; void HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, bool apply, bool onReapply); @@ -229,11 +229,11 @@ private: void _DeleteRemovedApplications(); protected: SpellInfo const* const m_spellInfo; - uint64 const m_casterGuid; - uint64 const m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted + ObjectGuid const m_casterGuid; + ObjectGuid const m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted uint32 const m_castItemEntry; // when deleted, we could retrieve some information from template instead time_t const m_applyTime; - WorldObject* const m_owner; // + WorldObject* const m_owner; int32 m_maxDuration; // Max aura duration int32 m_duration; // Current time @@ -257,9 +257,9 @@ private: class UnitAura : public Aura { - friend Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID); + friend Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID); protected: - explicit UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID); + explicit UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID); public: void _ApplyForTarget(Unit* target, Unit* caster, AuraApplication* aurApp) override; void _UnapplyForTarget(Unit* target, Unit* caster, AuraApplication* aurApp) override; @@ -278,9 +278,9 @@ private: class DynObjAura : public Aura { - friend Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID); + friend Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID); protected: - explicit DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID); + explicit DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID); public: void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT) override; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4562edee10..7bf84ae74c 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -58,14 +58,12 @@ extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS]; SpellDestination::SpellDestination() { _position.Relocate(0, 0, 0, 0); - _transportGUID = 0; _transportOffset.Relocate(0, 0, 0, 0); } SpellDestination::SpellDestination(float x, float y, float z, float orientation, uint32 mapId) { _position.Relocate(x, y, z, orientation); - _transportGUID = 0; _position.m_mapId = mapId; _transportOffset.Relocate(0, 0, 0, 0); } @@ -73,7 +71,6 @@ SpellDestination::SpellDestination(float x, float y, float z, float orientation, SpellDestination::SpellDestination(Position const& pos) { _position.Relocate(pos); - _transportGUID = 0; _transportOffset.Relocate(0, 0, 0, 0); } @@ -108,14 +105,9 @@ SpellCastTargets::SpellCastTargets() : m_elevation(0), m_speed(0), m_strTarget() m_objectTarget = nullptr; m_itemTarget = nullptr; - m_objectTargetGUID = 0; - m_itemTargetGUID = 0; m_itemTargetEntry = 0; m_targetMask = 0; - - // Xinef: Channel data - m_objectTargetGUIDChannel = 0; } SpellCastTargets::~SpellCastTargets() @@ -130,14 +122,14 @@ void SpellCastTargets::Read(ByteBuffer& data, Unit* caster) return; if (m_targetMask & (TARGET_FLAG_UNIT | TARGET_FLAG_UNIT_MINIPET | TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_CORPSE_ENEMY | TARGET_FLAG_CORPSE_ALLY)) - data.readPackGUID(m_objectTargetGUID); + data >> m_objectTargetGUID.ReadAsPacked(); if (m_targetMask & (TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM)) - data.readPackGUID(m_itemTargetGUID); + data >> m_itemTargetGUID.ReadAsPacked(); if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION) { - data.readPackGUID(m_src._transportGUID); + data >> m_src._transportGUID.ReadAsPacked(); if (m_src._transportGUID) data >> m_src._transportOffset.PositionXYZStream(); else @@ -154,7 +146,7 @@ void SpellCastTargets::Read(ByteBuffer& data, Unit* caster) if (m_targetMask & TARGET_FLAG_DEST_LOCATION) { - data.readPackGUID(m_dst._transportGUID); + data >> m_dst._transportGUID.ReadAsPacked(); if (m_dst._transportGUID) data >> m_dst._transportOffset.PositionXYZStream(); else @@ -180,19 +172,19 @@ void SpellCastTargets::Write(ByteBuffer& data) data << uint32(m_targetMask); if (m_targetMask & (TARGET_FLAG_UNIT | TARGET_FLAG_CORPSE_ALLY | TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_CORPSE_ENEMY | TARGET_FLAG_UNIT_MINIPET)) - data.appendPackGUID(m_objectTargetGUID); + data << m_objectTargetGUID.WriteAsPacked(); if (m_targetMask & (TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM)) { if (m_itemTarget) - data.append(m_itemTarget->GetPackGUID()); + data << m_itemTarget->GetPackGUID(); else data << uint8(0); } if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION) { - data.appendPackGUID(m_src._transportGUID); // relative position guid here - transport for example + data << m_src._transportGUID.WriteAsPacked(); // relative position guid here - transport for example if (m_src._transportGUID) data << m_src._transportOffset.PositionXYZStream(); else @@ -201,7 +193,7 @@ void SpellCastTargets::Write(ByteBuffer& data) if (m_targetMask & TARGET_FLAG_DEST_LOCATION) { - data.appendPackGUID(m_dst._transportGUID); // relative position guid here - transport for example + data << m_dst._transportGUID.WriteAsPacked(); // relative position guid here - transport for example if (m_dst._transportGUID) data << m_dst._transportOffset.PositionXYZStream(); else @@ -212,18 +204,20 @@ void SpellCastTargets::Write(ByteBuffer& data) data << m_strTarget; } -uint64 SpellCastTargets::GetUnitTargetGUID() const +ObjectGuid SpellCastTargets::GetUnitTargetGUID() const { - switch (GUID_HIPART(m_objectTargetGUID)) + switch (m_objectTargetGUID.GetHigh()) { - case HIGHGUID_PLAYER: - case HIGHGUID_VEHICLE: - case HIGHGUID_UNIT: - case HIGHGUID_PET: + case HighGuid::Player: + case HighGuid::Vehicle: + case HighGuid::Unit: + case HighGuid::Pet: return m_objectTargetGUID; default: - return 0LL; + break; } + + return ObjectGuid::Empty; } Unit* SpellCastTargets::GetUnitTarget() const @@ -243,17 +237,19 @@ void SpellCastTargets::SetUnitTarget(Unit* target) m_targetMask |= TARGET_FLAG_UNIT; } -uint64 SpellCastTargets::GetGOTargetGUID() const +ObjectGuid SpellCastTargets::GetGOTargetGUID() const { - switch (GUID_HIPART(m_objectTargetGUID)) + switch (m_objectTargetGUID.GetHigh()) { - case HIGHGUID_TRANSPORT: - case HIGHGUID_MO_TRANSPORT: - case HIGHGUID_GAMEOBJECT: + case HighGuid::Transport: + case HighGuid::Mo_Transport: + case HighGuid::GameObject: return m_objectTargetGUID; default: - return 0LL; + break; } + + return ObjectGuid::Empty; } GameObject* SpellCastTargets::GetGOTarget() const @@ -273,15 +269,17 @@ void SpellCastTargets::SetGOTarget(GameObject* target) m_targetMask |= TARGET_FLAG_GAMEOBJECT; } -uint64 SpellCastTargets::GetCorpseTargetGUID() const +ObjectGuid SpellCastTargets::GetCorpseTargetGUID() const { - switch (GUID_HIPART(m_objectTargetGUID)) + switch (m_objectTargetGUID.GetHigh()) { - case HIGHGUID_CORPSE: + case HighGuid::Corpse: return m_objectTargetGUID; default: - return 0LL; + break; } + + return ObjectGuid::Empty; } Corpse* SpellCastTargets::GetCorpseTarget() const @@ -306,7 +304,7 @@ WorldObject* SpellCastTargets::GetObjectTarget() const return m_objectTarget; } -uint64 SpellCastTargets::GetObjectTargetGUID() const +ObjectGuid SpellCastTargets::GetObjectTargetGUID() const { return m_objectTargetGUID; } @@ -314,7 +312,7 @@ uint64 SpellCastTargets::GetObjectTargetGUID() const void SpellCastTargets::RemoveObjectTarget() { m_objectTarget = nullptr; - m_objectTargetGUID = 0LL; + m_objectTargetGUID.Clear(); m_targetMask &= ~(TARGET_FLAG_UNIT_MASK | TARGET_FLAG_CORPSE_MASK | TARGET_FLAG_GAMEOBJECT_MASK); } @@ -331,7 +329,7 @@ void SpellCastTargets::SetItemTarget(Item* item) void SpellCastTargets::SetTradeItemTarget(Player* caster) { - m_itemTargetGUID = uint64(TRADE_SLOT_NONTRADED); + m_itemTargetGUID.Set(uint64(TRADE_SLOT_NONTRADED)); m_itemTargetEntry = 0; m_targetMask |= TARGET_FLAG_TRADE_ITEM; @@ -444,7 +442,7 @@ void SpellCastTargets::RemoveDst() } // Xinef: Channel Data -void SpellCastTargets::SetObjectTargetChannel(uint64 targetGUID) +void SpellCastTargets::SetObjectTargetChannel(ObjectGuid targetGUID) { m_objectTargetGUIDChannel = targetGUID; } @@ -480,7 +478,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 == TRADE_SLOT_NONTRADED) // here it is not guid but slot. Also prevents hacking slots + if (m_itemTargetGUID.GetRawValue() == 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); @@ -515,15 +513,17 @@ void SpellCastTargets::OutDebug() const LOG_INFO("server", "target mask: %u", m_targetMask); if (m_targetMask & (TARGET_FLAG_UNIT_MASK | TARGET_FLAG_CORPSE_MASK | TARGET_FLAG_GAMEOBJECT_MASK)) - LOG_INFO("server", "Object target: " UI64FMTD, m_objectTargetGUID); + LOG_INFO("server", "Object target: %s", m_objectTargetGUID.ToString().c_str()); if (m_targetMask & TARGET_FLAG_ITEM) - LOG_INFO("server", "Item target: " UI64FMTD, m_itemTargetGUID); + LOG_INFO("server", "Item target: %s", m_itemTargetGUID.ToString().c_str()); if (m_targetMask & TARGET_FLAG_TRADE_ITEM) - LOG_INFO("server", "Trade item target: " UI64FMTD, m_itemTargetGUID); + LOG_INFO("server", "Trade item target: %s", m_itemTargetGUID.ToString().c_str()); if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION) - LOG_INFO("server", "Source location: transport guid:" UI64FMTD " trans offset: %s position: %s", m_src._transportGUID, m_src._transportOffset.ToString().c_str(), m_src._position.ToString().c_str()); + LOG_INFO("server", "Source location: transport guid: %s trans offset: %s position: %s", + m_src._transportGUID.ToString().c_str(), m_src._transportOffset.ToString().c_str(), m_src._position.ToString().c_str()); if (m_targetMask & TARGET_FLAG_DEST_LOCATION) - LOG_INFO("server", "Destination location: transport guid:" UI64FMTD " trans offset: %s position: %s", m_dst._transportGUID, m_dst._transportOffset.ToString().c_str(), m_dst._position.ToString().c_str()); + LOG_INFO("server", "Destination location: transport guid: %s trans offset: %s position: %s", + m_dst._transportGUID.ToString().c_str(), m_dst._transportOffset.ToString().c_str(), m_dst._position.ToString().c_str()); if (m_targetMask & TARGET_FLAG_STRING) LOG_INFO("server", "String: %s", m_strTarget.c_str()); LOG_INFO("server", "speed: %f", m_speed); @@ -540,7 +540,7 @@ SpellValue::SpellValue(SpellInfo const* proto) ForcedCritResult = false; } -Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, uint64 originalCasterGUID, bool skipCheck) : +Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID, bool skipCheck) : m_spellInfo(sSpellMgr->GetSpellForDifficultyFromSpell(info, caster)), m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster) , m_spellValue(new SpellValue(m_spellInfo)) @@ -607,7 +607,6 @@ Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, _triggeredCastFlags = TriggerCastFlags(uint32(_triggeredCastFlags) | TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_CAST_DIRECTLY); m_CastItem = nullptr; - m_castItemGUID = 0; unitTarget = nullptr; itemTarget = nullptr; @@ -1141,7 +1140,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar } else { - //TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected unit, got %s, effect %u", m_spellInfo->Id, GetLogNameForGuid(target->GetGUID()), effMask); + //TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected unit, got %s, effect %u", m_spellInfo->Id, target->GetGUID().GetTypeName(), effMask); return; } break; @@ -1151,7 +1150,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar AddGOTarget(gobjTarget, effMask); else { - //TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected gameobject, got %s, effect %u", m_spellInfo->Id, GetLogNameForGuid(target->GetGUID()), effMask); + //TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected gameobject, got %s, effect %u", m_spellInfo->Id, target->GetGUID().GetTypeName(), effMask); return; } break; @@ -2141,7 +2140,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= if (target->IsImmunedToSpellEffect(m_spellInfo, effIndex)) effectMask &= ~(1 << effIndex); - uint64 targetGUID = target->GetGUID(); + ObjectGuid targetGUID = target->GetGUID(); // Lookup target in already in list for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) @@ -2221,7 +2220,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= targetInfo.reflectResult = SPELL_MISS_PARRY; // Increase time interval for reflected spells by 1.5 - m_caster->m_Events.AddEvent(new ReflectEvent(m_caster->GetGUID(), targetInfo.targetGUID, m_spellInfo), m_caster->m_Events.CalculateTime(targetInfo.timeDelay)); + m_caster->m_Events.AddEvent(new ReflectEvent(m_caster, targetInfo.targetGUID, m_spellInfo), m_caster->m_Events.CalculateTime(targetInfo.timeDelay)); targetInfo.timeDelay += targetInfo.timeDelay >> 1; m_spellFlags |= SPELL_FLAG_REFLECTED; @@ -2275,7 +2274,7 @@ void Spell::AddGOTarget(GameObject* go, uint32 effectMask) if (!effectMask) return; - uint64 targetGUID = go->GetGUID(); + ObjectGuid targetGUID = go->GetGUID(); // Lookup target in already in list for (std::list<GOTargetInfo>::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit) @@ -2357,6 +2356,9 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) uint8 mask = target->effectMask; Unit* effectUnit = m_caster->GetGUID() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID); + if (!effectUnit && !target->targetGUID.IsPlayer()) // only players may be targeted across maps + return; + if (!effectUnit || m_spellInfo->Id == 45927) { uint8 farMask = 0; @@ -2370,7 +2372,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) return; // find unit in world // Xinef: FindUnit Access without Map check!!! Intended - effectUnit = ObjectAccessor::FindUnit(target->targetGUID); + effectUnit = ObjectAccessor::FindPlayer(target->targetGUID); if (!effectUnit) return; @@ -2852,7 +2854,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA { bool refresh = false; m_spellAura = Aura::TryRefreshStackOrCreate(aurSpellInfo, effectMask, unit, m_originalCaster, - (aurSpellInfo == m_spellInfo) ? &m_spellValue->EffectBasePoints[0] : &basePoints[0], m_CastItem, 0, &refresh, !(_triggeredCastFlags & TRIGGERED_NO_PERIODIC_RESET)); + (aurSpellInfo == m_spellInfo) ? &m_spellValue->EffectBasePoints[0] : &basePoints[0], m_CastItem, ObjectGuid::Empty, &refresh, !(_triggeredCastFlags & TRIGGERED_NO_PERIODIC_RESET)); // xinef: if aura was not refreshed, add proc ex if (!refresh) @@ -3164,7 +3166,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const } else { - m_castItemGUID = 0; + m_castItemGUID = ObjectGuid::Empty; } InitExplicitTargets(*targets); @@ -3898,7 +3900,7 @@ void Spell::SendSpellCooldown() if (Player* player = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself()) { WorldPacket data(SMSG_SPELL_COOLDOWN, 8 + 1 + 4 + 4); - data << uint64(m_caster->GetGUID()); + data << m_caster->GetGUID(); data << uint8(SPELL_COOLDOWN_FLAG_INCLUDE_GCD); data << uint32(m_spellInfo->Id); data << uint32(m_spellInfo->RecoveryTime); @@ -4064,7 +4066,7 @@ void Spell::finish(bool ok) if (spellInfo && spellInfo->SpellIconID == 2056) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("spells.aura", "Statue %d is unsummoned in spell %d finish", m_caster->GetGUIDLow(), m_spellInfo->Id); + LOG_DEBUG("spells.aura", "Statue %s is unsummoned in spell %d finish", m_caster->GetGUID().ToString().c_str(), m_spellInfo->Id); #endif m_caster->setDeathState(JUST_DIED); return; @@ -4294,11 +4296,11 @@ void Spell::SendSpellStart() WorldPacket data(SMSG_SPELL_START, (8 + 8 + 4 + 4 + 2)); if (m_CastItem) - data.append(m_CastItem->GetPackGUID()); + data << m_CastItem->GetPackGUID(); else - data.append(m_caster->GetPackGUID()); + data << m_caster->GetPackGUID(); - data.append(m_caster->GetPackGUID()); + data << m_caster->GetPackGUID(); data << uint8(m_cast_count); // pending spell cast? data << uint32(m_spellInfo->Id); // spellId data << uint32(castFlags); // cast flags @@ -4367,11 +4369,11 @@ void Spell::SendSpellGo() WorldPacket data(SMSG_SPELL_GO, 150); // guess size if (m_CastItem) - data.append(m_CastItem->GetPackGUID()); + data << m_CastItem->GetPackGUID(); else - data.append(m_caster->GetPackGUID()); + data << m_caster->GetPackGUID(); - data.append(m_caster->GetPackGUID()); + data << m_caster->GetPackGUID(); data << uint8(m_cast_count); // pending spell cast? data << uint32(m_spellInfo->Id); // spellId data << uint32(castFlags); // cast flags @@ -4526,7 +4528,7 @@ void Spell::WriteSpellGoTargets(WorldPacket* data) { if ((*ihit).missCondition == SPELL_MISS_NONE) // Add only hits { - *data << uint64(ihit->targetGUID); + *data << ihit->targetGUID; // Xinef: WTF is this? No channeled spell checked, no anything //m_channelTargetEffectMask |=ihit->effectMask; ++hit; @@ -4535,7 +4537,7 @@ void Spell::WriteSpellGoTargets(WorldPacket* data) for (std::list<GOTargetInfo>::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end() && hit < 255; ++ighit) { - *data << uint64(ighit->targetGUID); // Always hits + *data << ighit->targetGUID; // Always hits ++hit; } @@ -4546,7 +4548,7 @@ void Spell::WriteSpellGoTargets(WorldPacket* data) { if (ihit->missCondition != SPELL_MISS_NONE) // Add only miss { - *data << uint64(ihit->targetGUID); + *data << ihit->targetGUID; *data << uint8(ihit->missCondition); if (ihit->missCondition == SPELL_MISS_REFLECT) *data << uint8(ihit->reflectResult); @@ -4566,7 +4568,7 @@ void Spell::SendLogExecute() { WorldPacket data(SMSG_SPELLLOGEXECUTE, (8 + 4 + 4 + 4 + 4 + 8)); - data.append(m_caster->GetPackGUID()); + data << m_caster->GetPackGUID(); data << uint32(m_spellInfo->Id); @@ -4599,7 +4601,7 @@ void Spell::SendLogExecute() void Spell::ExecuteLogEffectTakeTargetPower(uint8 effIndex, Unit* target, uint32 PowerType, uint32 powerTaken, float gainMultiplier) { InitEffectExecuteData(effIndex); - m_effectExecuteData[effIndex]->append(target->GetPackGUID()); + *m_effectExecuteData[effIndex] << target->GetPackGUID(); *m_effectExecuteData[effIndex] << uint32(powerTaken); *m_effectExecuteData[effIndex] << uint32(PowerType); *m_effectExecuteData[effIndex] << float(gainMultiplier); @@ -4608,21 +4610,21 @@ void Spell::ExecuteLogEffectTakeTargetPower(uint8 effIndex, Unit* target, uint32 void Spell::ExecuteLogEffectExtraAttacks(uint8 effIndex, Unit* victim, uint32 attCount) { InitEffectExecuteData(effIndex); - m_effectExecuteData[effIndex]->append(victim->GetPackGUID()); + *m_effectExecuteData[effIndex] << victim->GetPackGUID(); *m_effectExecuteData[effIndex] << uint32(attCount); } void Spell::ExecuteLogEffectInterruptCast(uint8 effIndex, Unit* victim, uint32 spellId) { InitEffectExecuteData(effIndex); - m_effectExecuteData[effIndex]->append(victim->GetPackGUID()); + *m_effectExecuteData[effIndex] << victim->GetPackGUID(); *m_effectExecuteData[effIndex] << uint32(spellId); } void Spell::ExecuteLogEffectDurabilityDamage(uint8 effIndex, Unit* victim, int32 itemId, int32 slot) { InitEffectExecuteData(effIndex); - m_effectExecuteData[effIndex]->append(victim->GetPackGUID()); + *m_effectExecuteData[effIndex] << victim->GetPackGUID(); *m_effectExecuteData[effIndex] << int32(itemId); *m_effectExecuteData[effIndex] << int32(slot); } @@ -4630,7 +4632,7 @@ void Spell::ExecuteLogEffectDurabilityDamage(uint8 effIndex, Unit* victim, int32 void Spell::ExecuteLogEffectOpenLock(uint8 effIndex, Object* obj) { InitEffectExecuteData(effIndex); - m_effectExecuteData[effIndex]->append(obj->GetPackGUID()); + *m_effectExecuteData[effIndex] << obj->GetPackGUID(); } void Spell::ExecuteLogEffectCreateItem(uint8 effIndex, uint32 entry) @@ -4648,32 +4650,32 @@ void Spell::ExecuteLogEffectDestroyItem(uint8 effIndex, uint32 entry) void Spell::ExecuteLogEffectSummonObject(uint8 effIndex, WorldObject* obj) { InitEffectExecuteData(effIndex); - m_effectExecuteData[effIndex]->append(obj->GetPackGUID()); + *m_effectExecuteData[effIndex] << obj->GetPackGUID(); } void Spell::ExecuteLogEffectUnsummonObject(uint8 effIndex, WorldObject* obj) { InitEffectExecuteData(effIndex); - m_effectExecuteData[effIndex]->append(obj->GetPackGUID()); + *m_effectExecuteData[effIndex] << obj->GetPackGUID(); } void Spell::ExecuteLogEffectResurrect(uint8 effIndex, Unit* target) { InitEffectExecuteData(effIndex); - m_effectExecuteData[effIndex]->append(target->GetPackGUID()); + *m_effectExecuteData[effIndex] << target->GetPackGUID(); } void Spell::SendInterrupted(uint8 result) { WorldPacket data(SMSG_SPELL_FAILURE, (8 + 1 + 4 + 1)); - data.append(m_caster->GetPackGUID()); + data << m_caster->GetPackGUID(); data << uint8(m_cast_count); data << uint32(m_spellInfo->Id); data << uint8(result); m_caster->SendMessageToSet(&data, true); data.Initialize(SMSG_SPELL_FAILED_OTHER, (8 + 1 + 4 + 1)); - data.append(m_caster->GetPackGUID()); + data << m_caster->GetPackGUID(); data << uint8(m_cast_count); data << uint32(m_spellInfo->Id); data << uint8(result); @@ -4684,12 +4686,12 @@ void Spell::SendChannelUpdate(uint32 time) { if (time == 0) { - m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0); + m_caster->SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, ObjectGuid::Empty); m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0); } WorldPacket data(MSG_CHANNEL_UPDATE, 8 + 4); - data.append(m_caster->GetPackGUID()); + data << m_caster->GetPackGUID(); data << uint32(time); m_caster->SendMessageToSet(&data, true); @@ -4697,13 +4699,13 @@ void Spell::SendChannelUpdate(uint32 time) void Spell::SendChannelStart(uint32 duration) { - uint64 channelTarget = m_targets.GetObjectTargetGUID(); + ObjectGuid channelTarget = m_targets.GetObjectTargetGUID(); if (!channelTarget && !m_spellInfo->NeedsExplicitUnitTarget()) if (m_UniqueTargetInfo.size() + m_UniqueGOTargetInfo.size() == 1) // this is for TARGET_SELECT_CATEGORY_NEARBY channelTarget = !m_UniqueTargetInfo.empty() ? m_UniqueTargetInfo.front().targetGUID : m_UniqueGOTargetInfo.front().targetGUID; WorldPacket data(MSG_CHANNEL_START, (8 + 4 + 4)); - data.append(m_caster->GetPackGUID()); + data << m_caster->GetPackGUID(); data << uint32(m_spellInfo->Id); data << uint32(duration); @@ -4714,7 +4716,7 @@ void Spell::SendChannelStart(uint32 duration) m_timer = duration; if (channelTarget) - m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, channelTarget); + m_caster->SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, channelTarget); m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id); } @@ -4728,7 +4730,7 @@ void Spell::SendResurrectRequest(Player* target) : m_caster->GetNameForLocaleIdx(target->GetSession()->GetSessionDbLocaleIndex())); WorldPacket data(SMSG_RESURRECT_REQUEST, (8 + 4 + sentName.size() + 1 + 1 + 1 + 4)); - data << uint64(m_caster->GetGUID()); + data << m_caster->GetGUID(); data << uint32(sentName.size() + 1); data << sentName; @@ -4756,7 +4758,7 @@ void Spell::TakeCastItem() { // This code is to avoid a crash // I'm not sure, if this is really an error, but I guess every item needs a prototype - LOG_ERROR("server", "Cast item has no item prototype highId=%d, lowId=%d", m_CastItem->GetGUIDHigh(), m_CastItem->GetGUIDLow()); + LOG_ERROR("server", "Cast item has no item prototype %s", m_CastItem->GetGUID().ToString().c_str()); return; } @@ -4800,7 +4802,7 @@ void Spell::TakeCastItem() m_targets.SetItemTarget(nullptr); m_CastItem = nullptr; - m_castItemGUID = 0; + m_castItemGUID.Clear(); } } @@ -4819,7 +4821,7 @@ void Spell::TakePower() if (m_caster->GetTypeId() == TYPEID_PLAYER) { if (PowerType == POWER_RAGE || PowerType == POWER_ENERGY || PowerType == POWER_RUNE || PowerType == POWER_RUNIC_POWER) - if (uint64 targetGUID = m_targets.GetUnitTargetGUID()) + if (ObjectGuid targetGUID = m_targets.GetUnitTargetGUID()) for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) if (ihit->targetGUID == targetGUID) { @@ -5056,7 +5058,7 @@ void Spell::TakeReagents() } m_CastItem = nullptr; - m_castItemGUID = 0; + m_castItemGUID.Clear(); } // if GetItemTarget is also spell reagent @@ -5767,7 +5769,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())); + pTempItem = pTrade->GetTraderData()->GetItem(TradeSlots(m_targets.GetItemTargetGUID().GetRawValue())); } else if (m_targets.GetTargetMask() & TARGET_FLAG_ITEM) pTempItem = m_caster->ToPlayer()->GetItemByGuid(m_targets.GetItemTargetGUID()); @@ -6053,7 +6055,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (target->GetCharmerGUID()) return SPELL_FAILED_CHARMED; - if (target->GetOwnerGUID() && IS_PLAYER_GUID(target->GetOwnerGUID())) + if (target->GetOwnerGUID() && target->GetOwnerGUID().IsPlayer()) return SPELL_FAILED_TARGET_IS_PLAYER_CONTROLLED; if (target->IsPet() && (!target->GetOwner() || target->GetOwner()->ToPlayer())) @@ -6156,7 +6158,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (!my_trade) return SPELL_FAILED_NOT_TRADING; - TradeSlots slot = TradeSlots(m_targets.GetItemTargetGUID()); + TradeSlots slot = TradeSlots(m_targets.GetItemTargetGUID().GetRawValue()); if (slot != TRADE_SLOT_NONTRADED) return SPELL_FAILED_BAD_TARGETS; @@ -6375,7 +6377,7 @@ SpellCastResult Spell::CheckCasterAuras(bool preventionOnly) const bool Spell::CanAutoCast(Unit* target) { - uint64 targetguid = target->GetGUID(); + ObjectGuid targetguid = target->GetGUID(); for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j) { @@ -6436,7 +6438,7 @@ SpellCastResult Spell::CheckRange(bool strict) float min_range = m_caster->GetSpellMinRangeForTarget(target, m_spellInfo); // xinef: hack for npc shooters - if (min_range && GetCaster()->GetTypeId() == TYPEID_UNIT && !IS_PLAYER_GUID(GetCaster()->GetOwnerGUID()) && min_range <= 6.0f) + if (min_range && GetCaster()->GetTypeId() == TYPEID_UNIT && !GetCaster()->GetOwnerGUID().IsPlayer() && min_range <= 6.0f) range_type = SPELL_RANGE_RANGED; if (Player* modOwner = m_caster->GetSpellModOwner()) @@ -7158,7 +7160,7 @@ void Spell::Delayed() // only called in DealDamage() #endif WorldPacket data(SMSG_SPELL_DELAYED, 8 + 4); - data.append(m_caster->GetPackGUID()); + data << m_caster->GetPackGUID(); data << uint32(delaytime); m_caster->SendMessageToSet(&data, true); @@ -7368,7 +7370,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const default: // normal case // Get GO cast coordinates if original caster -> GO WorldObject* caster = nullptr; - if (IS_GAMEOBJECT_GUID(m_originalCasterGUID)) + if (m_originalCasterGUID.IsGameObject()) caster = m_caster->GetMap()->GetGameObject(m_originalCasterGUID); if (!caster) caster = m_caster; @@ -7452,8 +7454,8 @@ SpellEvent::~SpellEvent() } else { - LOG_ERROR("server", "~SpellEvent: %s %u tried to delete non-deletable spell %u. Was not deleted, causes memory leak.", - (m_Spell->GetCaster()->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), m_Spell->GetCaster()->GetGUIDLow(), m_Spell->m_spellInfo->Id); + LOG_ERROR("server", "~SpellEvent: %s %s tried to delete non-deletable spell %u. Was not deleted, causes memory leak.", + (m_Spell->GetCaster()->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), m_Spell->GetCaster()->GetGUID().ToString().c_str(), m_Spell->m_spellInfo->Id); ABORT(); } } @@ -7535,10 +7537,9 @@ bool SpellEvent::IsDeletable() const bool ReflectEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { - Unit* caster = ObjectAccessor::FindUnit(_casterGUID); - Unit* target = ObjectAccessor::FindUnit(_targetGUID); - if (caster && target && caster->IsInMap(target)) - caster->ProcDamageAndSpell(target, PROC_FLAG_NONE, PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG, PROC_EX_REFLECT, 1, BASE_ATTACK, _spellInfo); + Unit* target = ObjectAccessor::GetUnit(*_caster, _targetGUID); + if (target && _caster->IsInMap(target)) + _caster->ProcDamageAndSpell(target, PROC_FLAG_NONE, PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG, PROC_EX_REFLECT, 1, BASE_ATTACK, _spellInfo); return true; } diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index ffe17b604f..d9c007c8c2 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -87,7 +87,7 @@ struct SpellDestination void RelocateOffset(Position const& offset); WorldLocation _position; - uint64 _transportGUID; + ObjectGuid _transportGUID; Position _transportOffset; }; @@ -105,23 +105,23 @@ public: void SetTargetFlag(SpellCastTargetFlags flag) { m_targetMask |= flag; } - uint64 GetUnitTargetGUID() const; + ObjectGuid GetUnitTargetGUID() const; Unit* GetUnitTarget() const; void SetUnitTarget(Unit* target); - uint64 GetGOTargetGUID() const; + ObjectGuid GetGOTargetGUID() const; GameObject* GetGOTarget() const; void SetGOTarget(GameObject* target); - uint64 GetCorpseTargetGUID() const; + ObjectGuid GetCorpseTargetGUID() const; Corpse* GetCorpseTarget() const; void SetCorpseTarget(Corpse* target); WorldObject* GetObjectTarget() const; - uint64 GetObjectTargetGUID() const; + ObjectGuid GetObjectTargetGUID() const; void RemoveObjectTarget(); - uint64 GetItemTargetGUID() const { return m_itemTargetGUID; } + ObjectGuid GetItemTargetGUID() const { return m_itemTargetGUID; } Item* GetItemTarget() const { return m_itemTarget; } uint32 GetItemTargetEntry() const { return m_itemTargetEntry; } void SetItemTarget(Item* item); @@ -164,7 +164,7 @@ public: void OutDebug() const; // Xinef: Channel data - void SetObjectTargetChannel(uint64 targetGUID); + void SetObjectTargetChannel(ObjectGuid targetGUID); void SetDstChannel(SpellDestination const& spellDest); WorldObject* GetObjectTargetChannel(Unit* caster) const; bool HasDstChannel() const; @@ -178,8 +178,8 @@ private: Item* m_itemTarget; // object GUID/etc, can be used always - uint64 m_objectTargetGUID; - uint64 m_itemTargetGUID; + ObjectGuid m_objectTargetGUID; + ObjectGuid m_itemTargetGUID; uint32 m_itemTargetEntry; SpellDestination m_src; @@ -190,7 +190,7 @@ private: // Xinef: Save channel data SpellDestination m_dstChannel; - uint64 m_objectTargetGUIDChannel; + ObjectGuid m_objectTargetGUIDChannel; }; struct SpellValue @@ -224,20 +224,20 @@ enum SpellEffectHandleMode // Xinef: special structure containing data for channel target spells struct ChannelTargetData { - ChannelTargetData(uint64 cguid, const SpellDestination* dst) : channelGUID(cguid) + ChannelTargetData(ObjectGuid cguid, const SpellDestination* dst) : channelGUID(cguid) { if (dst) spellDst = *dst; } - uint64 channelGUID; + ObjectGuid channelGUID; SpellDestination spellDst; }; // Targets store structures and data struct TargetInfo { - uint64 targetGUID; + ObjectGuid targetGUID; uint64 timeDelay; SpellMissInfo missCondition:8; SpellMissInfo reflectResult:8; @@ -256,7 +256,7 @@ class Spell friend void Unit::SetCurrentCastedSpell(Spell* pSpell); friend class SpellScript; public: - Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, uint64 originalCasterGUID = 0, bool skipCheck = false); + Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID = ObjectGuid::Empty, bool skipCheck = false); ~Spell(); void EffectNULL(SpellEffIndex effIndex); @@ -490,7 +490,7 @@ public: SpellInfo const* m_spellInfo; Item* m_CastItem; - uint64 m_castItemGUID; + ObjectGuid m_castItemGUID; uint8 m_cast_count; uint32 m_glyphIndex; uint32 m_preCastSpell; @@ -544,13 +544,13 @@ protected: void TriggerGlobalCooldown(); void CancelGlobalCooldown(); - void SendLoot(uint64 guid, LootType loottype); + void SendLoot(ObjectGuid guid, LootType loottype); Unit* const m_caster; SpellValue* const m_spellValue; - uint64 m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection + ObjectGuid m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection // e.g. damage around area spell trigered by victim aura and damage enemies of aura caster Unit* m_originalCaster; // cached pointer for m_originalCaster, updated at Spell::UpdatePointers() @@ -629,7 +629,7 @@ protected: struct GOTargetInfo { - uint64 targetGUID; + ObjectGuid targetGUID; uint64 timeDelay; uint8 effectMask: 8; bool processed: 1; @@ -801,12 +801,12 @@ protected: class ReflectEvent : public BasicEvent { public: - ReflectEvent(uint64 casterGUID, uint64 targetGUID, const SpellInfo* spellInfo) : _casterGUID(casterGUID), _targetGUID(targetGUID), _spellInfo(spellInfo) { } + ReflectEvent(Unit* caster, ObjectGuid targetGUID, const SpellInfo* spellInfo) : _caster(caster), _targetGUID(targetGUID), _spellInfo(spellInfo) { } bool Execute(uint64 e_time, uint32 p_time) override; protected: - uint64 _casterGUID; - uint64 _targetGUID; + Unit* _caster; + ObjectGuid _targetGUID; const SpellInfo* _spellInfo; }; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 67e8b7f6c7..c9756148f6 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -285,8 +285,8 @@ void Spell::EffectInstaKill(SpellEffIndex /*effIndex*/) finish(); WorldPacket data(SMSG_SPELLINSTAKILLLOG, 8 + 8 + 4); - data << uint64(m_caster->GetGUID()); - data << uint64(unitTarget->GetGUID()); + data << m_caster->GetGUID(); + data << unitTarget->GetGUID(); data << uint32(m_spellInfo->Id); m_caster->SendMessageToSet(&data, true); @@ -1141,7 +1141,7 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex) if (m_spellInfo->Id == 49376) // feral charge { speedXY = pow(speedZ * 10, 8); - m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ, 0, ObjectAccessor::GetUnit(*m_caster, m_caster->GetUInt64Value(UNIT_FIELD_TARGET))); + m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ, 0, ObjectAccessor::GetUnit(*m_caster, m_caster->GetGuidValue(UNIT_FIELD_TARGET))); return; } @@ -1362,7 +1362,8 @@ void Spell::EffectUnlearnSpecialization(SpellEffIndex effIndex) player->removeSpell(spellToUnlearn, SPEC_MASK_ALL, false); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("spells.aura", "Spell: Player %u has unlearned spell %u from NpcGUID: %u", player->GetGUIDLow(), spellToUnlearn, m_caster->GetGUIDLow()); + LOG_DEBUG("spells.aura", "Spell: Player %s has unlearned spell %u from Npc: %s", + player->GetGUID().ToString().c_str(), spellToUnlearn, m_caster->GetGUID().ToString().c_str()); #endif } @@ -1552,7 +1553,7 @@ void Spell::EffectHeal(SpellEffIndex /*effIndex*/) if (!targetAura) { - LOG_ERROR("server", "Target(GUID:" UI64FMTD ") has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget->GetGUID()); + LOG_ERROR("server", "Target(%s) has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget->GetGUID().ToString().c_str()); return; } @@ -1773,7 +1774,7 @@ void Spell::DoCreateItem(uint8 /*effIndex*/, uint32 itemId) // set the "Crafted by ..." property of the item if (pItem->GetTemplate()->HasSignature()) - pItem->SetUInt32Value(ITEM_FIELD_CREATOR, player->GetGUIDLow()); + pItem->SetGuidValue(ITEM_FIELD_CREATOR, player->GetGUID()); // send info to the client player->SendNewItem(pItem, addNumber, true, SelfCast); @@ -1859,7 +1860,7 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex) if (!caster->IsInWorld() || !caster->FindMap() || !ObjectAccessor::GetUnit(*caster, caster->GetGUID())) // pussywizard: temporary crash fix (FindMap and GetUnit are mine) return; DynamicObject* dynObj = new DynamicObject(false); - if (!dynObj->CreateDynamicObject(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, *destTarget, radius, DYNAMIC_OBJECT_AREA_SPELL)) + if (!dynObj->CreateDynamicObject(caster->GetMap()->GenerateLowGuid<HighGuid::DynamicObject>(), caster, m_spellInfo->Id, *destTarget, radius, DYNAMIC_OBJECT_AREA_SPELL)) { delete dynObj; return; @@ -2016,7 +2017,7 @@ void Spell::EffectEnergizePct(SpellEffIndex effIndex) m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, gain, power); } -void Spell::SendLoot(uint64 guid, LootType loottype) +void Spell::SendLoot(ObjectGuid guid, LootType loottype) { Player* player = m_caster->ToPlayer(); if (!player) @@ -2028,7 +2029,8 @@ void Spell::SendLoot(uint64 guid, LootType loottype) if (!gameObjTarget->isSpawned() && !player->IsGameMaster()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_ERROR("server", "Possible hacking attempt: Player %s [guid: %u] tried to loot a gameobject [entry: %u id: %u] which is on respawn time without being in GM mode!", player->GetName().c_str(), player->GetGUIDLow(), gameObjTarget->GetEntry(), gameObjTarget->GetGUIDLow()); + LOG_ERROR("server", "Possible hacking attempt: Player %s [%s] tried to loot a gameobject [%s] which is on respawn time without being in GM mode!", + player->GetName().c_str(), player->GetGUID().ToString().c_str(), gameObjTarget->GetGUID().ToString().c_str()); #endif return; } @@ -2099,7 +2101,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) Player* player = m_caster->ToPlayer(); uint32 lockId = 0; - uint64 guid = 0; + ObjectGuid guid; // Get lockId if (gameObjTarget) @@ -2138,7 +2140,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) // TODO: Add script for spell 41920 - Filling, becouse server it freze when use this spell // handle outdoor pvp object opening, return true if go was registered for handling // these objects must have been spawned by outdoorpvp! - else if (gameObjTarget->GetGOInfo()->type == GAMEOBJECT_TYPE_GOOBER && sOutdoorPvPMgr->HandleOpenGo(player, gameObjTarget->GetGUID())) + else if (gameObjTarget->GetGOInfo()->type == GAMEOBJECT_TYPE_GOOBER && sOutdoorPvPMgr->HandleOpenGo(player, gameObjTarget)) return; lockId = goInfo->GetLockId(); guid = gameObjTarget->GetGUID(); @@ -2185,9 +2187,8 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) if (gameObjTarget) { // Allow one skill-up until respawned - if (!gameObjTarget->IsInSkillupList(player->GetGUIDLow()) && - player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue)) - gameObjTarget->AddToSkillupList(player->GetGUIDLow()); + if (!gameObjTarget->IsInSkillupList(player->GetGUID()) && player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue)) + gameObjTarget->AddToSkillupList(player->GetGUID()); } else if (itemTarget) { @@ -2250,7 +2251,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex) m_targets.SetItemTarget(nullptr); m_CastItem = nullptr; - m_castItemGUID = 0; + m_castItemGUID.Clear(); player->StoreItem(dest, pNewItem, true); player->ItemAddedQuestCheck(pNewItem->GetEntry(), 1); @@ -2270,7 +2271,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex) m_targets.SetItemTarget(nullptr); m_CastItem = nullptr; - m_castItemGUID = 0; + m_castItemGUID.Clear(); player->BankItem(dest, pNewItem, true); return; @@ -2293,7 +2294,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex) m_targets.SetItemTarget(nullptr); m_CastItem = nullptr; - m_castItemGUID = 0; + m_castItemGUID.Clear(); player->EquipItem(dest, pNewItem, true); player->AutoUnequipOffhandIfNeed(); @@ -2555,11 +2556,12 @@ void Spell::EffectLearnSpell(SpellEffIndex effIndex) player->learnSpell(spellToLearn); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("spells.aura", "Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow()); + LOG_DEBUG("spells.aura", "Spell: Player %s has learned spell %u from Npc %s", + player->GetGUID().ToString().c_str(), spellToLearn, m_caster->GetGUID().ToString().c_str()); #endif } -typedef std::list< std::pair<uint32, uint64> > DispelList; +typedef std::list<std::pair<uint32, ObjectGuid>> DispelList; void Spell::EffectDispel(SpellEffIndex effIndex) { if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) @@ -2619,12 +2621,12 @@ void Spell::EffectDispel(SpellEffIndex effIndex) if (!failCount) { // Failed to dispell - dataFail << uint64(m_caster->GetGUID()); // Caster GUID - dataFail << uint64(unitTarget->GetGUID()); // Victim GUID + dataFail << m_caster->GetGUID(); // Caster GUID + dataFail << unitTarget->GetGUID(); // Victim GUID dataFail << uint32(m_spellInfo->Id); // dispel spell id } ++failCount; - dataFail << uint32(itr->first->GetId()); // Spell Id + dataFail << uint32(itr->first->GetId()); // Spell Id } ++count; } @@ -2642,8 +2644,8 @@ void Spell::EffectDispel(SpellEffIndex effIndex) WorldPacket dataSuccess(SMSG_SPELLDISPELLOG, 8 + 8 + 4 + 1 + 4 + success_list.size() * 5); // Send packet header - dataSuccess.append(unitTarget->GetPackGUID()); // Victim GUID - dataSuccess.append(m_caster->GetPackGUID()); // Caster GUID + dataSuccess << unitTarget->GetPackGUID(); // Victim GUID + dataSuccess << m_caster->GetPackGUID(); // Caster GUID dataSuccess << uint32(m_spellInfo->Id); // dispel spell id dataSuccess << uint8(0); // not used dataSuccess << uint32(success_list.size()); // count @@ -2735,7 +2737,7 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex) return; DynamicObject* dynObj = new DynamicObject(true); - if (!dynObj->CreateDynamicObject(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, *destTarget, radius, DYNAMIC_OBJECT_FARSIGHT_FOCUS)) + if (!dynObj->CreateDynamicObject(m_caster->GetMap()->GenerateLowGuid<HighGuid::DynamicObject>(), m_caster, m_spellInfo->Id, *destTarget, radius, DYNAMIC_OBJECT_FARSIGHT_FOCUS)) { delete dynObj; return; @@ -2753,7 +2755,7 @@ void Spell::EffectUntrainTalents(SpellEffIndex /*effIndex*/) if (!unitTarget || m_caster->GetTypeId() == TYPEID_PLAYER) return; - if (uint64 guid = m_caster->GetGUID()) // the trainer is the caster + if (ObjectGuid guid = m_caster->GetGUID()) // the trainer is the caster unitTarget->ToPlayer()->SendTalentWipeConfirm(guid); } @@ -2800,7 +2802,8 @@ void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/) { unitTarget->ToPlayer()->RewardHonor(nullptr, 1, damage / 10, false); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("spells.aura", "SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %u", m_spellInfo->Id, damage / 10, m_CastItem->GetEntry(), unitTarget->ToPlayer()->GetGUIDLow()); + LOG_DEBUG("spells.aura", "SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %s", + m_spellInfo->Id, damage / 10, m_CastItem->GetEntry(), unitTarget->ToPlayer()->GetGUID().ToString().c_str()); #endif return; } @@ -2811,7 +2814,8 @@ void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/) uint32 honor_reward = acore::Honor::hk_honor_at_level(unitTarget->getLevel(), float(damage)); unitTarget->ToPlayer()->RewardHonor(nullptr, 1, honor_reward, false); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("spells.aura", "SpellEffect::AddHonor (spell_id %u) rewards %u honor points (scale) to player: %u", m_spellInfo->Id, honor_reward, unitTarget->ToPlayer()->GetGUIDLow()); + LOG_DEBUG("spells.aura", "SpellEffect::AddHonor (spell_id %u) rewards %u honor points (scale) to player: %s", + m_spellInfo->Id, honor_reward, unitTarget->ToPlayer()->GetGUID().ToString().c_str()); #endif } else @@ -2819,7 +2823,8 @@ void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/) //maybe we have correct honor_gain in damage already unitTarget->ToPlayer()->RewardHonor(nullptr, 1, damage, false); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("spells.aura", "SpellEffect::AddHonor (spell_id %u) rewards %u honor points (non scale) for player: %u", m_spellInfo->Id, damage, unitTarget->ToPlayer()->GetGUIDLow()); + LOG_DEBUG("spells.aura", "SpellEffect::AddHonor (spell_id %u) rewards %u honor points (non scale) for player: %s", + m_spellInfo->Id, damage, unitTarget->ToPlayer()->GetGUID().ToString().c_str()); #endif } } @@ -3739,7 +3744,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) Map* map = target->GetMap(); - if (!pGameObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map, m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) + if (!pGameObj->Create(map->GenerateLowGuid<HighGuid::GameObject>(), gameobject_id, map, m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) { delete pGameObj; return; @@ -3763,7 +3768,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry()) { GameObject* linkedGO = sObjectMgr->IsGameObjectStaticTransport(linkedEntry) ? new StaticTransport() : new GameObject(); - if (linkedGO->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, map, m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) + if (linkedGO->Create(map->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, map, m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) { linkedGO->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); linkedGO->SetSpellId(m_spellInfo->Id); @@ -4348,7 +4353,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex) Player* target = unitTarget->ToPlayer(); // caster or target already have requested duel - if (caster->duel || target->duel || !target->GetSocial() || target->GetSocial()->HasIgnore(caster->GetGUIDLow())) + if (caster->duel || target->duel || !target->GetSocial() || target->GetSocial()->HasIgnore(caster->GetGUID())) return; // Players can only fight a duel in zones with this flag @@ -4371,7 +4376,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex) GameObject* pGameObj = sObjectMgr->IsGameObjectStaticTransport(gameobject_id) ? new StaticTransport() : new GameObject(); Map* map = m_caster->GetMap(); - if (!pGameObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, + if (!pGameObj->Create(map->GenerateLowGuid<HighGuid::GameObject>(), gameobject_id, map, m_caster->GetPhaseMask(), m_caster->GetPositionX() + (unitTarget->GetPositionX() - m_caster->GetPositionX()) / 2, m_caster->GetPositionY() + (unitTarget->GetPositionY() - m_caster->GetPositionY()) / 2, @@ -4396,8 +4401,8 @@ void Spell::EffectDuel(SpellEffIndex effIndex) // Send request WorldPacket data(SMSG_DUEL_REQUESTED, 8 + 8); - data << uint64(pGameObj->GetGUID()); - data << uint64(caster->GetGUID()); + data << pGameObj->GetGUID(); + data << caster->GetGUID(); caster->GetSession()->SendPacket(&data); target->GetSession()->SendPacket(&data); @@ -4418,8 +4423,8 @@ void Spell::EffectDuel(SpellEffIndex effIndex) duel2->isMounted = (GetSpellInfo()->Id == 62875); // Mounted Duel target->duel = duel2; - caster->SetUInt64Value(PLAYER_DUEL_ARBITER, pGameObj->GetGUID()); - target->SetUInt64Value(PLAYER_DUEL_ARBITER, pGameObj->GetGUID()); + caster->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetGUID()); + target->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetGUID()); sScriptMgr->OnPlayerDuelRequest(target, caster); } @@ -4484,9 +4489,9 @@ void Spell::EffectSummonPlayer(SpellEffIndex /*effIndex*/) unitTarget->ToPlayer()->SetSummonPoint(m_caster->GetMapId(), x, y, z); WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); - data << uint64(m_caster->GetGUID()); // summoner guid - data << uint32(m_caster->GetZoneId()); // summoner zone - data << uint32(MAX_PLAYER_SUMMON_DELAY * IN_MILLISECONDS); // auto decline after msecs + data << m_caster->GetGUID(); // summoner guid + data << uint32(m_caster->GetZoneId()); // summoner zone + data << uint32(MAX_PLAYER_SUMMON_DELAY * IN_MILLISECONDS); // auto decline after msecs unitTarget->ToPlayer()->GetSession()->SendPacket(&data); } @@ -4738,8 +4743,8 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex) if (m_caster) { - uint64 guid = m_caster->m_ObjectSlot[slot]; - if (guid != 0) + ObjectGuid guid = m_caster->m_ObjectSlot[slot]; + if (guid) { if (GameObject* gameObject = m_caster->GetMap()->GetGameObject(guid)) { @@ -4748,7 +4753,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex) gameObject->SetSpellId(0); m_caster->RemoveGameObject(gameObject, true); } - m_caster->m_ObjectSlot[slot] = 0; + m_caster->m_ObjectSlot[slot].Clear(); } } @@ -4763,7 +4768,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex) m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); Map* map = m_caster->GetMap(); - if (!pGameObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobjectId, map, m_caster->GetPhaseMask(), x, y, z, m_caster->GetOrientation(), G3D::Quat(), 0, GO_STATE_READY)) + if (!pGameObj->Create(map->GenerateLowGuid<HighGuid::GameObject>(), gameobjectId, map, m_caster->GetPhaseMask(), x, y, z, m_caster->GetOrientation(), G3D::Quat(), 0, GO_STATE_READY)) { delete pGameObj; return; @@ -4913,7 +4918,7 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/) m_caster->SendClearTarget(); WorldPacket data(SMSG_CLEAR_TARGET, 8); - data << uint64(m_caster->GetGUID()); + data << m_caster->GetGUID(); float dist = m_caster->GetVisibilityRange() + VISIBILITY_COMPENSATION; acore::MessageDistDelivererToHostile notifier(m_caster, &data, dist); @@ -5269,7 +5274,7 @@ void Spell::EffectDispelMechanic(SpellEffIndex effIndex) uint32 mechanic = m_spellInfo->Effects[effIndex].MiscValue; - std::queue < std::pair < uint32, uint64 > > dispel_list; + std::queue<std::pair<uint32, ObjectGuid>> dispel_list; Unit::AuraMap const& auras = unitTarget->GetOwnedAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) @@ -5312,7 +5317,7 @@ void Spell::EffectResurrectPet(SpellEffIndex /*effIndex*/) player->GetPosition(x, y, z); if (!pet) { - player->SummonPet(0, x, y, z, player->GetOrientation(), SUMMON_PET, 0, 0, (uint64)damage, PET_LOAD_SUMMON_DEAD_PET); + player->SummonPet(0, x, y, z, player->GetOrientation(), SUMMON_PET, 0, 0, ObjectGuid((uint64)damage), PET_LOAD_SUMMON_DEAD_PET); return; } @@ -5482,7 +5487,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) GameObject* pGameObj = sObjectMgr->IsGameObjectStaticTransport(name_id) ? new StaticTransport() : new GameObject(); - if (!pGameObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), name_id, cMap, m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) + if (!pGameObj->Create(cMap->GenerateLowGuid<HighGuid::GameObject>(), name_id, cMap, m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) { delete pGameObj; return; @@ -5494,7 +5499,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) { case GAMEOBJECT_TYPE_FISHINGNODE: { - m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, pGameObj->GetGUID()); + m_caster->SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, pGameObj->GetGUID()); m_caster->AddGameObject(pGameObj); // will removed at spell cancel // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo)) @@ -5556,7 +5561,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry()) { GameObject* linkedGO = sObjectMgr->IsGameObjectStaticTransport(linkedEntry) ? new StaticTransport() : new GameObject(); - if (linkedGO->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, cMap, m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) + if (linkedGO->Create(cMap->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, cMap, m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) { linkedGO->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); linkedGO->SetSpellId(m_spellInfo->Id); @@ -5748,12 +5753,12 @@ void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex) if (!failCount) { // Failed to dispell - dataFail << uint64(m_caster->GetGUID()); // Caster GUID - dataFail << uint64(unitTarget->GetGUID()); // Victim GUID + dataFail << m_caster->GetGUID(); // Caster GUID + dataFail << unitTarget->GetGUID(); // Victim GUID dataFail << uint32(m_spellInfo->Id); // dispel spell id } ++failCount; - dataFail << uint32(itr->first->GetId()); // Spell Id + dataFail << uint32(itr->first->GetId()); // Spell Id } ++count; } @@ -5766,8 +5771,8 @@ void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex) return; WorldPacket dataSuccess(SMSG_SPELLSTEALLOG, 8 + 8 + 4 + 1 + 4 + damage * 5); - dataSuccess.append(unitTarget->GetPackGUID()); // Victim GUID - dataSuccess.append(m_caster->GetPackGUID()); // Caster GUID + dataSuccess << unitTarget->GetPackGUID(); // Victim GUID + dataSuccess << m_caster->GetPackGUID(); // Caster GUID dataSuccess << uint32(m_spellInfo->Id); // dispel spell id dataSuccess << uint8(0); // not used dataSuccess << uint32(success_list.size()); // count @@ -5788,7 +5793,7 @@ void Spell::EffectKillCreditPersonal(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - unitTarget->ToPlayer()->KilledMonsterCredit(m_spellInfo->Effects[effIndex].MiscValue, 0); + unitTarget->ToPlayer()->KilledMonsterCredit(m_spellInfo->Effects[effIndex].MiscValue); } void Spell::EffectKillCredit(SpellEffIndex effIndex) @@ -6344,7 +6349,7 @@ void Spell::EffectBind(SpellEffIndex effIndex) #endif // zone update data.Initialize(SMSG_PLAYERBOUND, 8 + 4); - data << uint64(m_caster->GetGUID()); + data << m_caster->GetGUID(); data << uint32(areaId); player->SendDirectMessage(&data); } @@ -6361,7 +6366,7 @@ void Spell::EffectSummonRaFFriend(SpellEffIndex /*effIndex*/) m_caster->GetPosition(x, y, z); unitTarget->ToPlayer()->SetSummonPoint(m_caster->GetMapId(), x, y, z); WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); - data << uint64(m_caster->GetGUID()); + data << m_caster->GetGUID(); data << uint32(m_caster->GetZoneId()); data << uint32(MAX_PLAYER_SUMMON_DELAY * IN_MILLISECONDS); // auto decline after msecs unitTarget->ToPlayer()->GetSession()->SendPacket(&data); diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index abd1b3e949..2962028a1b 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -982,7 +982,7 @@ uint32 AuraScript::GetId() const return m_aura->GetId(); } -uint64 AuraScript::GetCasterGUID() const +ObjectGuid AuraScript::GetCasterGUID() const { return m_aura->GetCasterGUID(); } diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index e3a57f445d..1652460f19 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -801,7 +801,7 @@ public: uint32 GetId() const; // returns guid of object which casted the aura (m_originalCaster of the Spell class) - uint64 GetCasterGUID() const; + ObjectGuid GetCasterGUID() const; // returns unit which casted the aura or nullptr if not avalible (caster logged out for example) Unit* GetCaster() const; // returns object on which aura was casted, target for non-area auras, area aura source for area auras diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index a1ff9906df..4c7d877dcf 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -205,7 +205,8 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject CreatureTextHolder::const_iterator itr = textHolder.find(textGroup); if (itr == textHolder.end()) { - LOG_ERROR("sql.sql", "CreatureTextMgr: Could not find TextGroup %u for Creature(%s) GuidLow %u Entry %u. Ignoring.", uint32(textGroup), source->GetName().c_str(), source->GetGUIDLow(), source->GetEntry()); + LOG_ERROR("sql.sql", "CreatureTextMgr: Could not find TextGroup %u for Creature %s (%s). Ignoring.", + uint32(textGroup), source->GetName().c_str(), source->GetGUID().ToString().c_str()); return 0; } @@ -413,7 +414,8 @@ void CreatureTextMgr::SetRepeatId(Creature* source, uint8 textGroup, uint8 id) if (std::find(repeats.begin(), repeats.end(), id) == repeats.end()) repeats.push_back(id); else - LOG_ERROR("sql.sql", "CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), source->GetName().c_str(), source->GetGUIDLow(), source->GetEntry(), uint32(id)); + LOG_ERROR("sql.sql", "CreatureTextMgr: TextGroup %u for Creature %s (%s), id %u already added", + uint32(textGroup), source->GetName().c_str(), source->GetGUID().ToString().c_str(), uint32(id)); } CreatureTextRepeatIds CreatureTextMgr::GetRepeatGroup(Creature* source, uint8 textGroup) diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h index 12bef56258..ec587d0001 100644 --- a/src/server/game/Texts/CreatureTextMgr.h +++ b/src/server/game/Texts/CreatureTextMgr.h @@ -68,7 +68,7 @@ typedef std::map<CreatureTextId, CreatureTextLocale> LocaleCreatureTextMap; //used for handling non-repeatable random texts typedef std::vector<uint8> CreatureTextRepeatIds; typedef std::unordered_map<uint8, CreatureTextRepeatIds> CreatureTextRepeatGroup; -typedef std::unordered_map<uint64, CreatureTextRepeatGroup> CreatureTextRepeatMap;//guid based +typedef std::unordered_map<ObjectGuid, CreatureTextRepeatGroup> CreatureTextRepeatMap;//guid based class CreatureTextMgr { @@ -150,7 +150,7 @@ public: { case CHAT_MSG_MONSTER_WHISPER: case CHAT_MSG_RAID_BOSS_WHISPER: - data.put<uint64>(whisperGUIDpos, player->GetGUID()); + data.put<ObjectGuid>(whisperGUIDpos, player->GetGUID()); break; default: break; diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index d74300cfdd..12513b7a85 100644 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -20,11 +20,11 @@ inline float GetAge(uint64 t) { return float(time(nullptr) - t) / DAY; } /////////////////////////////////////////////////////////////////////////////////////////////////// // GM ticket -GmTicket::GmTicket() : _id(0), _playerGuid(0), _type(TICKET_TYPE_OPEN), _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(0), _lastModifiedTime(0), - _closedBy(0), _resolvedBy(0), _assignedTo(0), _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), - _needResponse(false), _needMoreHelp(false) { } +GmTicket::GmTicket() : _id(0), _type(TICKET_TYPE_OPEN), _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(0), _lastModifiedTime(0), + _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), _needResponse(false), _needMoreHelp(false) { } -GmTicket::GmTicket(Player* player) : _type(TICKET_TYPE_OPEN), _createTime(time(nullptr)), _lastModifiedTime(time(nullptr)), _closedBy(0), _resolvedBy(0), _assignedTo(0), _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), _needMoreHelp(false) +GmTicket::GmTicket(Player* player) : _type(TICKET_TYPE_OPEN), _createTime(time(nullptr)), _lastModifiedTime(time(nullptr)), + _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), _needMoreHelp(false) { _id = sTicketMgr->GenerateTicketId(); _playerName = player->GetName(); @@ -40,7 +40,7 @@ bool GmTicket::LoadFromDB(Field* fields) uint8 index = 0; _id = fields[ index].GetUInt32(); _type = TicketType(fields[++index].GetUInt8()); - _playerGuid = MAKE_NEW_GUID(fields[++index].GetUInt32(), 0, HIGHGUID_PLAYER); + _playerGuid = ObjectGuid::Create<HighGuid::Player>(fields[++index].GetUInt32()); _playerName = fields[++index].GetString(); _message = fields[++index].GetString(); _createTime = fields[++index].GetUInt32(); @@ -49,15 +49,15 @@ bool GmTicket::LoadFromDB(Field* fields) _posY = fields[++index].GetFloat(); _posZ = fields[++index].GetFloat(); _lastModifiedTime = fields[++index].GetUInt32(); - _closedBy = fields[++index].GetInt32(); - _assignedTo = MAKE_NEW_GUID(fields[++index].GetUInt32(), 0, HIGHGUID_PLAYER); + _closedBy = ObjectGuid::Create<HighGuid::Player>(fields[++index].GetInt32()); + _assignedTo = ObjectGuid::Create<HighGuid::Player>(fields[++index].GetUInt32()); _comment = fields[++index].GetString(); _response = fields[++index].GetString(); _completed = fields[++index].GetBool(); _escalatedStatus = GMTicketEscalationStatus(fields[++index].GetUInt8()); _viewed = fields[++index].GetBool(); _needMoreHelp = fields[++index].GetBool(); - _resolvedBy = fields[++index].GetInt32(); + _resolvedBy = ObjectGuid::Create<HighGuid::Player>(fields[++index].GetInt32()); return true; } @@ -70,7 +70,7 @@ void GmTicket::SaveToDB(SQLTransaction& trans) const PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GM_TICKET); stmt->setUInt32( index, _id); stmt->setUInt8 (++index, uint8(_type)); - stmt->setUInt32(++index, GUID_LOPART(_playerGuid)); + stmt->setUInt32(++index, _playerGuid.GetCounter()); stmt->setString(++index, _playerName); stmt->setString(++index, _message); stmt->setUInt32(++index, uint32(_createTime)); @@ -79,15 +79,15 @@ void GmTicket::SaveToDB(SQLTransaction& trans) const stmt->setFloat (++index, _posY); stmt->setFloat (++index, _posZ); stmt->setUInt32(++index, uint32(_lastModifiedTime)); - stmt->setInt32 (++index, GUID_LOPART(_closedBy)); - stmt->setUInt32(++index, GUID_LOPART(_assignedTo)); + stmt->setInt32 (++index, _closedBy.GetCounter()); + stmt->setUInt32(++index, _assignedTo.GetCounter()); stmt->setString(++index, _comment); stmt->setString(++index, _response); stmt->setBool (++index, _completed); stmt->setUInt8 (++index, uint8(_escalatedStatus)); stmt->setBool (++index, _viewed); stmt->setBool (++index, _needMoreHelp); - stmt->setInt32 (++index, GUID_LOPART(_resolvedBy)); + stmt->setInt32 (++index, _resolvedBy.GetCounter()); CharacterDatabase.ExecuteOrAppend(trans, stmt); } @@ -156,7 +156,7 @@ std::string GmTicket::FormatMessageString(ChatHandler& handler, bool detailed) c ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGE, (secsToTimeString(curTime - _lastModifiedTime, true)).c_str()); std::string name; - if (sObjectMgr->GetPlayerNameByGUID(_assignedTo, name)) + if (sObjectMgr->GetPlayerNameByGUID(_assignedTo.GetCounter(), name)) ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTASSIGNEDTO, name.c_str()); if (detailed) @@ -188,7 +188,8 @@ std::string GmTicket::FormatMessageString(ChatHandler& handler, const char* szCl void GmTicket::SetUnassigned() { - _assignedTo = 0; + _assignedTo.Clear(); + switch (_escalatedStatus) { case TICKET_ASSIGNED: @@ -344,7 +345,7 @@ void TicketMgr::AddTicket(GmTicket* ticket) ticket->SaveToDB(trans); } -void TicketMgr::CloseTicket(uint32 ticketId, int64 source) +void TicketMgr::CloseTicket(uint32 ticketId, ObjectGuid source) { if (GmTicket* ticket = GetTicket(ticketId)) { @@ -366,7 +367,7 @@ void TicketMgr::RemoveTicket(uint32 ticketId) } } -void TicketMgr::ResolveAndCloseTicket(uint32 ticketId, int64 source) +void TicketMgr::ResolveAndCloseTicket(uint32 ticketId, ObjectGuid source) { if (GmTicket* ticket = GetTicket(ticketId)) { diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h index 16661cabb6..d12439bb2b 100644 --- a/src/server/game/Tickets/TicketMgr.h +++ b/src/server/game/Tickets/TicketMgr.h @@ -81,23 +81,23 @@ public: bool IsClosed() const { return _type != TICKET_TYPE_OPEN; } bool IsCompleted() const { return _completed; } - bool IsFromPlayer(uint64 guid) const { return guid == _playerGuid; } - bool IsAssigned() const { return _assignedTo != 0; } - bool IsAssignedTo(uint64 guid) const { return guid == _assignedTo; } - bool IsAssignedNotTo(uint64 guid) const { return IsAssigned() && !IsAssignedTo(guid); } + bool IsFromPlayer(ObjectGuid guid) const { return guid == _playerGuid; } + bool IsAssigned() const { return _assignedTo; } + bool IsAssignedTo(ObjectGuid guid) const { return guid == _assignedTo; } + bool IsAssignedNotTo(ObjectGuid guid) const { return IsAssigned() && !IsAssignedTo(guid); } uint32 GetId() const { return _id; } - Player* GetPlayer() const { return ObjectAccessor::FindPlayerInOrOutOfWorld(_playerGuid); } + Player* GetPlayer() const { return ObjectAccessor::FindConnectedPlayer(_playerGuid); } std::string const& GetPlayerName() const { return _playerName; } std::string const& GetMessage() const { return _message; } - Player* GetAssignedPlayer() const { return ObjectAccessor::FindPlayerInOrOutOfWorld(_assignedTo); } - uint64 GetAssignedToGUID() const { return _assignedTo; } + Player* GetAssignedPlayer() const { return ObjectAccessor::FindConnectedPlayer(_assignedTo); } + ObjectGuid GetAssignedToGUID() const { return _assignedTo; } std::string GetAssignedToName() const { std::string name; // save queries if ticket is not assigned if (_assignedTo) - sObjectMgr->GetPlayerNameByGUID(_assignedTo, name); + sObjectMgr->GetPlayerNameByGUID(_assignedTo.GetCounter(), name); return name; } @@ -105,7 +105,7 @@ public: GMTicketEscalationStatus GetEscalatedStatus() const { return _escalatedStatus; } void SetEscalatedStatus(GMTicketEscalationStatus escalatedStatus) { _escalatedStatus = escalatedStatus; } - void SetAssignedTo(uint64 guid, bool isAdmin) + void SetAssignedTo(ObjectGuid guid, bool isAdmin) { _assignedTo = guid; if (isAdmin && _escalatedStatus == TICKET_IN_ESCALATION_QUEUE) @@ -113,8 +113,8 @@ public: else if (_escalatedStatus == TICKET_UNASSIGNED) _escalatedStatus = TICKET_ASSIGNED; } - void SetClosedBy(int64 value) { _closedBy = value; _type = TICKET_TYPE_CLOSED; } - void SetResolvedBy(int64 value) { _resolvedBy = value; } + void SetClosedBy(ObjectGuid value) { _closedBy = value; _type = TICKET_TYPE_CLOSED; } + void SetResolvedBy(ObjectGuid value) { _resolvedBy = value; } void SetCompleted() { _completed = true; } void SetMessage(std::string const& message) { @@ -145,7 +145,7 @@ public: private: uint32 _id; - uint64 _playerGuid; + ObjectGuid _playerGuid; TicketType _type; // 0 = Open, 1 = Closed, 2 = Character deleted std::string _playerName; float _posX; @@ -155,9 +155,9 @@ private: std::string _message; uint64 _createTime; uint64 _lastModifiedTime; - int64 _closedBy; // 0 = Open or Closed by Console (if type = 1), playerGuid = GM who closed it or player abandoned ticket or read the GM response message. - int64 _resolvedBy; // 0 = Open, -1 = Resolved by Console, GM who resolved it by closing or completing the ticket. - uint64 _assignedTo; + ObjectGuid _closedBy; // 0 = Open or Closed by Console (if type = 1), playerGuid = GM who closed it or player abandoned ticket or read the GM response message. + ObjectGuid _resolvedBy; // 0 = Open, -1 = Resolved by Console, GM who resolved it by closing or completing the ticket. + ObjectGuid _assignedTo; std::string _comment; bool _completed; GMTicketEscalationStatus _escalatedStatus; @@ -191,7 +191,7 @@ public: return nullptr; } - GmTicket* GetTicketByPlayer(uint64 playerGuid) + GmTicket* GetTicketByPlayer(ObjectGuid playerGuid) { for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr) if (itr->second && itr->second->IsFromPlayer(playerGuid) && !itr->second->IsClosed()) @@ -210,8 +210,8 @@ public: } void AddTicket(GmTicket* ticket); - void CloseTicket(uint32 ticketId, int64 source = -1); - void ResolveAndCloseTicket(uint32 ticketId, int64 source); // used when GM resolves a ticket by simply closing it + void CloseTicket(uint32 ticketId, ObjectGuid source = ObjectGuid::Empty); + void ResolveAndCloseTicket(uint32 ticketId, ObjectGuid source); // used when GM resolves a ticket by simply closing it void RemoveTicket(uint32 ticketId); bool GetStatus() const { return _status; } diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index af37b6fba5..b41d315987 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -415,18 +415,19 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s // make sure the same guid doesn't already exist and is safe to use bool incHighest = true; - if (guid != 0 && guid < sObjectMgr->_hiCharGuid) + if (guid != 0 && guid < sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed()) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_GUID); stmt->setUInt32(0, guid); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) - guid = sObjectMgr->_hiCharGuid; // use first free if exists - else incHighest = false; + guid = sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed(); // use first free if exists + else + incHighest = false; } else - guid = sObjectMgr->_hiCharGuid; + guid = sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed(); // normalize the name if specified and check if it exists if (!normalizePlayerName(name)) @@ -586,9 +587,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (!changenth(line, 1, newguid)) // character_inventory.guid update ROLLBACK(DUMP_FILE_BROKEN); - if (!changeGuid(line, 2, items, sObjectMgr->_hiItemGuid, true)) + if (!changeGuid(line, 2, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed(), true)) ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.bag update - if (!changeGuid(line, 4, items, sObjectMgr->_hiItemGuid)) + if (!changeGuid(line, 4, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed())) ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.item update break; } @@ -604,7 +605,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s { if (!changeGuid(line, 1, mails, sObjectMgr->_mailId)) ROLLBACK(DUMP_FILE_BROKEN); // mail_items.id - if (!changeGuid(line, 2, items, sObjectMgr->_hiItemGuid)) + if (!changeGuid(line, 2, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed())) ROLLBACK(DUMP_FILE_BROKEN); // mail_items.item_guid if (!changenth(line, 3, newguid)) // mail_items.receiver ROLLBACK(DUMP_FILE_BROKEN); @@ -613,7 +614,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s case DTT_ITEM: { // item, owner, data field:item, owner guid - if (!changeGuid(line, 1, items, sObjectMgr->_hiItemGuid)) + if (!changeGuid(line, 1, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed())) ROLLBACK(DUMP_FILE_BROKEN); // item_instance.guid update if (!changenth(line, 3, newguid)) // item_instance.owner_guid update ROLLBACK(DUMP_FILE_BROKEN); @@ -623,7 +624,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s { if (!changenth(line, 1, newguid)) // character_gifts.guid update ROLLBACK(DUMP_FILE_BROKEN); - if (!changeGuid(line, 2, items, sObjectMgr->_hiItemGuid)) + if (!changeGuid(line, 2, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed())) ROLLBACK(DUMP_FILE_BROKEN); // character_gifts.item_guid update break; } @@ -684,11 +685,11 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s // in case of name conflict player has to rename at login anyway sWorld->AddGlobalPlayerData(guid, account, name, gender, race, playerClass, level, mails.size(), 0); - sObjectMgr->_hiItemGuid += items.size(); + sObjectMgr->GetGenerator<HighGuid::Item>().Set(sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed() + items.size()); sObjectMgr->_mailId += mails.size(); if (incHighest) - ++sObjectMgr->_hiCharGuid; + sObjectMgr->GetGenerator<HighGuid::Player>().Generate(); fclose(fin); diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index 92232fd5c4..d7c1cd1eec 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -249,7 +249,7 @@ void Warden::ApplyPenalty(uint16 checkId, std::string const& reason) if (Player const* plr = _session->GetPlayer()) { std::string const reportFormat = "Player %s (guid %u, account id: %u) failed warden %u check (%s). Action: %s"; - reportMsg = acore::StringFormat(reportFormat, plr->GetName().c_str(), plr->GetGUIDLow(), _session->GetAccountId(), + reportMsg = acore::StringFormat(reportFormat, plr->GetName().c_str(), plr->GetGUID().GetCounter(), _session->GetAccountId(), checkId, ((checkData && !checkData->Comment.empty()) ? checkData->Comment.c_str() : "<warden comment is not set>"), GetWardenActionStr(action).c_str()); } @@ -264,7 +264,7 @@ void Warden::ApplyPenalty(uint16 checkId, std::string const& reason) if (Player const* plr = _session->GetPlayer()) { std::string const reportFormat = "Player %s (guid %u, account id: %u) triggered warden penalty by reason: %s. Action: %s"; - reportMsg = acore::StringFormat(reportFormat, plr->GetName().c_str(), plr->GetGUIDLow(), _session->GetAccountId(), causeMsg.c_str(), GetWardenActionStr(action).c_str()); + reportMsg = acore::StringFormat(reportFormat, plr->GetName().c_str(), plr->GetGUID().GetCounter(), _session->GetAccountId(), causeMsg.c_str(), GetWardenActionStr(action).c_str()); } else { diff --git a/src/server/game/World/IWorld.h b/src/server/game/World/IWorld.h index a578291839..224403bb06 100644 --- a/src/server/game/World/IWorld.h +++ b/src/server/game/World/IWorld.h @@ -7,6 +7,7 @@ #include "Callback.h" #include "Common.h" +#include "ObjectGuid.h" #include "QueryResult.h" #include "SharedDefines.h" #include "Timer.h" @@ -468,7 +469,7 @@ enum Rates // xinef: global storage struct GlobalPlayerData { - uint32 guidLow; + ObjectGuid::LowType guidLow; uint32 accountId; std::string name; uint8 race; @@ -487,7 +488,7 @@ public: virtual ~IWorld() {} virtual WorldSession* FindSession(uint32 id) const = 0; virtual WorldSession* FindOfflineSession(uint32 id) const = 0; - virtual WorldSession* FindOfflineSessionForCharacterGUID(uint32 guidLow) const = 0; + virtual WorldSession* FindOfflineSessionForCharacterGUID(ObjectGuid::LowType guidLow) const = 0; virtual void AddSession(WorldSession* s) = 0; virtual void SendAutoBroadcast() = 0; virtual bool KickSession(uint32 id) = 0; @@ -563,16 +564,16 @@ public: virtual void KickAllLess(AccountTypes sec) = 0; virtual uint32 GetNextWhoListUpdateDelaySecs() = 0; virtual void LoadGlobalPlayerDataStore() = 0; - virtual uint32 GetGlobalPlayerGUID(std::string const& name) const = 0; - virtual GlobalPlayerData const* GetGlobalPlayerData(uint32 guid) const = 0; - virtual void AddGlobalPlayerData(uint32 guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, uint16 mailCount, uint32 guildId) = 0; - virtual void UpdateGlobalPlayerData(uint32 guid, uint8 mask, std::string const& name, uint8 level = 0, uint8 gender = 0, uint8 race = 0, uint8 playerClass = 0) = 0; - virtual void UpdateGlobalPlayerMails(uint32 guid, int16 count, bool add = true) = 0; - virtual void UpdateGlobalPlayerGuild(uint32 guid, uint32 guildId) = 0; - virtual void UpdateGlobalPlayerGroup(uint32 guid, uint32 groupId) = 0; - virtual void UpdateGlobalPlayerArenaTeam(uint32 guid, uint8 slot, uint32 arenaTeamId) = 0; - virtual void UpdateGlobalNameData(uint32 guidLow, std::string const& oldName, std::string const& newName) = 0; - virtual void DeleteGlobalPlayerData(uint32 guid, std::string const& name) = 0; + virtual ObjectGuid GetGlobalPlayerGUID(std::string const& name) const = 0; + virtual GlobalPlayerData const* GetGlobalPlayerData(ObjectGuid::LowType guid) const = 0; + virtual void AddGlobalPlayerData(ObjectGuid::LowType guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, uint16 mailCount, uint32 guildId) = 0; + virtual void UpdateGlobalPlayerData(ObjectGuid::LowType guid, uint8 mask, std::string const& name, uint8 level = 0, uint8 gender = 0, uint8 race = 0, uint8 playerClass = 0) = 0; + virtual void UpdateGlobalPlayerMails(ObjectGuid::LowType guid, int16 count, bool add = true) = 0; + virtual void UpdateGlobalPlayerGuild(ObjectGuid::LowType guid, uint32 guildId) = 0; + virtual void UpdateGlobalPlayerGroup(ObjectGuid::LowType guid, uint32 groupId) = 0; + virtual void UpdateGlobalPlayerArenaTeam(ObjectGuid::LowType guid, uint8 slot, uint32 arenaTeamId) = 0; + virtual void UpdateGlobalNameData(ObjectGuid::LowType guidLow, std::string const& oldName, std::string const& newName) = 0; + virtual void DeleteGlobalPlayerData(ObjectGuid::LowType guid, std::string const& name) = 0; virtual void ProcessCliCommands() = 0; virtual void QueueCliCommand(CliCommandHolder* commandHolder) = 0; virtual void ForceGameEventUpdate() = 0; @@ -589,6 +590,7 @@ public: virtual time_t GetNextTimeWithMonthAndHour(int8 month, int8 hour) = 0; virtual std::string const& GetRealmName() const = 0; virtual void SetRealmName(std::string name) = 0; + virtual void RemoveOldCorpses() = 0; }; #endif //AZEROTHCORE_IWORLD_H diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 05d5d9dbd2..44fb101b3b 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -215,13 +215,15 @@ WorldSession* World::FindOfflineSession(uint32 id) const return nullptr; } -WorldSession* World::FindOfflineSessionForCharacterGUID(uint32 guidLow) const +WorldSession* World::FindOfflineSessionForCharacterGUID(ObjectGuid::LowType guidLow) const { if (m_offlineSessions.empty()) return nullptr; + for (SessionMap::const_iterator itr = m_offlineSessions.begin(); itr != m_offlineSessions.end(); ++itr) if (itr->second->GetGuidLow() == guidLow) return itr->second; + return nullptr; } @@ -1488,11 +1490,6 @@ void World::SetInitialWorldSettings() LoginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'", server_type, realm_zone, realmID); // One-time query - ///- Remove the bones (they should not exist in DB though) and old corpses after a restart - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_CORPSES); - stmt->setUInt32(0, 3 * DAY); - CharacterDatabase.Execute(stmt); - ///- Custom Hook for loading DB items sScriptMgr->OnLoadCustomDatabaseTable(); @@ -1768,9 +1765,6 @@ void World::SetInitialWorldSettings() LOG_INFO("server", "Loading pet level stats..."); sObjectMgr->LoadPetLevelInfo(); - LOG_INFO("server", "Loading Player Corpses..."); - sObjectMgr->LoadCorpses(); - LOG_INFO("server", "Loading Player level dependent mail rewards..."); sObjectMgr->LoadMailLevelRewards(); @@ -2332,7 +2326,10 @@ void World::Update(uint32 diff) if (m_timers[WUPDATE_CORPSES].Passed()) { m_timers[WUPDATE_CORPSES].Reset(); - sObjectAccessor->RemoveOldCorpses(); + sMapMgr->DoForAllMaps([](Map* map) + { + map->RemoveOldCorpses(); + }); } ///- Process Game events when necessary @@ -3225,7 +3222,7 @@ void World::LoadGlobalPlayerDataStore() do { Field* fields = result->Fetch(); - uint32 guidLow = fields[0].GetUInt32(); + ObjectGuid::LowType guidLow = fields[0].GetUInt32(); // count mails uint16 mailCount = 0; @@ -3251,7 +3248,7 @@ void World::LoadGlobalPlayerDataStore() LOG_INFO("server", " "); } -void World::AddGlobalPlayerData(uint32 guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, uint16 mailCount, uint32 guildId) +void World::AddGlobalPlayerData(ObjectGuid::LowType guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, uint16 mailCount, uint32 guildId) { GlobalPlayerData data; @@ -3273,7 +3270,7 @@ void World::AddGlobalPlayerData(uint32 guid, uint32 accountId, std::string const _globalPlayerNameStore[name] = guid; } -void World::UpdateGlobalPlayerData(uint32 guid, uint8 mask, std::string const& name, uint8 level, uint8 gender, uint8 race, uint8 playerClass) +void World::UpdateGlobalPlayerData(ObjectGuid::LowType guid, uint8 mask, std::string const& name, uint8 level, uint8 gender, uint8 race, uint8 playerClass) { GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid); if (itr == _globalPlayerDataStore.end()) @@ -3291,11 +3288,11 @@ void World::UpdateGlobalPlayerData(uint32 guid, uint8 mask, std::string const& n itr->second.name = name; WorldPacket data(SMSG_INVALIDATE_PLAYER, 8); - data << MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER); + data << guid; SendGlobalMessage(&data); } -void World::UpdateGlobalPlayerMails(uint32 guid, int16 count, bool add) +void World::UpdateGlobalPlayerMails(ObjectGuid::LowType guid, int16 count, bool add) { GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid); if (itr == _globalPlayerDataStore.end()) @@ -3313,7 +3310,7 @@ void World::UpdateGlobalPlayerMails(uint32 guid, int16 count, bool add) itr->second.mailCount = uint16(icount + count); // addition or subtraction } -void World::UpdateGlobalPlayerGuild(uint32 guid, uint32 guildId) +void World::UpdateGlobalPlayerGuild(ObjectGuid::LowType guid, uint32 guildId) { GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid); if (itr == _globalPlayerDataStore.end()) @@ -3321,7 +3318,7 @@ void World::UpdateGlobalPlayerGuild(uint32 guid, uint32 guildId) itr->second.guildId = guildId; } -void World::UpdateGlobalPlayerGroup(uint32 guid, uint32 groupId) +void World::UpdateGlobalPlayerGroup(ObjectGuid::LowType guid, uint32 groupId) { GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid); if (itr == _globalPlayerDataStore.end()) @@ -3330,7 +3327,7 @@ void World::UpdateGlobalPlayerGroup(uint32 guid, uint32 groupId) itr->second.groupId = groupId; } -void World::UpdateGlobalPlayerArenaTeam(uint32 guid, uint8 slot, uint32 arenaTeamId) +void World::UpdateGlobalPlayerArenaTeam(ObjectGuid::LowType guid, uint8 slot, uint32 arenaTeamId) { GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid); if (itr == _globalPlayerDataStore.end()) @@ -3339,13 +3336,13 @@ void World::UpdateGlobalPlayerArenaTeam(uint32 guid, uint8 slot, uint32 arenaTea itr->second.arenaTeamId[slot] = arenaTeamId; } -void World::UpdateGlobalNameData(uint32 guidLow, std::string const& oldName, std::string const& newName) +void World::UpdateGlobalNameData(ObjectGuid::LowType guidLow, std::string const& oldName, std::string const& newName) { _globalPlayerNameStore.erase(oldName); _globalPlayerNameStore[newName] = guidLow; } -void World::DeleteGlobalPlayerData(uint32 guid, std::string const& name) +void World::DeleteGlobalPlayerData(ObjectGuid::LowType guid, std::string const& name) { if (guid) _globalPlayerDataStore.erase(guid); @@ -3353,7 +3350,7 @@ void World::DeleteGlobalPlayerData(uint32 guid, std::string const& name) _globalPlayerNameStore.erase(name); } -GlobalPlayerData const* World::GetGlobalPlayerData(uint32 guid) const +GlobalPlayerData const* World::GetGlobalPlayerData(ObjectGuid::LowType guid) const { // Get data from global storage GlobalPlayerDataMap::const_iterator itr = _globalPlayerDataStore.find(guid); @@ -3401,12 +3398,12 @@ GlobalPlayerData const* World::GetGlobalPlayerData(uint32 guid) const return nullptr; } -uint32 World::GetGlobalPlayerGUID(std::string const& name) const +ObjectGuid World::GetGlobalPlayerGUID(std::string const& name) const { // Get data from global storage GlobalPlayerNameMap::const_iterator itr = _globalPlayerNameStore.find(name); if (itr != _globalPlayerNameStore.end()) - return itr->second; + return ObjectGuid::Create<HighGuid::Player>(itr->second); // Player is not in the global storage, try to get it from the Database PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_DATA_BY_NAME); @@ -3421,7 +3418,7 @@ uint32 World::GetGlobalPlayerGUID(std::string const& name) const // Let's add it to the global storage Field* fields = result->Fetch(); - uint32 guidLow = fields[0].GetUInt32(); + ObjectGuid::LowType guidLow = fields[0].GetUInt32(); LOG_INFO("server", "Player %s [GUID: %u] was not found in the global storage, but it was found in the database.", name.c_str(), guidLow); @@ -3442,10 +3439,16 @@ uint32 World::GetGlobalPlayerGUID(std::string const& name) const { LOG_INFO("server", "Player %s [GUID: %u] added to the global storage.", name.c_str(), guidLow); - return guidLow; + return ObjectGuid::Create<HighGuid::Player>(guidLow); } } // Player not found - return 0; + return ObjectGuid::Empty; +} + +void World::RemoveOldCorpses() +{ + m_timers[WUPDATE_CORPSES].SetCurrent(m_timers[WUPDATE_CORPSES].GetInterval()); } + diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 793edaa873..a1bdd67a5c 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -14,6 +14,7 @@ #include "Callback.h" #include "Common.h" #include "IWorld.h" +#include "ObjectGuid.h" #include "QueryResult.h" #include "SharedDefines.h" #include "Timer.h" @@ -149,8 +150,8 @@ enum GlobalPlayerUpdateMask PLAYER_UPDATE_DATA_NAME = 0x10, }; -typedef std::map<uint32, GlobalPlayerData> GlobalPlayerDataMap; -typedef std::map<std::string, uint32> GlobalPlayerNameMap; +typedef std::map<ObjectGuid::LowType, GlobalPlayerData> GlobalPlayerDataMap; +typedef std::map<std::string, ObjectGuid::LowType> GlobalPlayerNameMap; // xinef: petitions storage struct PetitionData @@ -170,7 +171,7 @@ public: WorldSession* FindSession(uint32 id) const; WorldSession* FindOfflineSession(uint32 id) const; - WorldSession* FindOfflineSessionForCharacterGUID(uint32 guidLow) const; + WorldSession* FindOfflineSessionForCharacterGUID(ObjectGuid::LowType guidLow) const; void AddSession(WorldSession* s); void SendAutoBroadcast(); bool KickSession(uint32 id); @@ -356,16 +357,16 @@ public: // xinef: Global Player Data Storage system void LoadGlobalPlayerDataStore(); - uint32 GetGlobalPlayerGUID(std::string const& name) const; - GlobalPlayerData const* GetGlobalPlayerData(uint32 guid) const; - void AddGlobalPlayerData(uint32 guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, uint16 mailCount, uint32 guildId); - void UpdateGlobalPlayerData(uint32 guid, uint8 mask, std::string const& name, uint8 level = 0, uint8 gender = 0, uint8 race = 0, uint8 playerClass = 0); - void UpdateGlobalPlayerMails(uint32 guid, int16 count, bool add = true); - void UpdateGlobalPlayerGuild(uint32 guid, uint32 guildId); - void UpdateGlobalPlayerGroup(uint32 guid, uint32 groupId); - void UpdateGlobalPlayerArenaTeam(uint32 guid, uint8 slot, uint32 arenaTeamId); - void UpdateGlobalNameData(uint32 guidLow, std::string const& oldName, std::string const& newName); - void DeleteGlobalPlayerData(uint32 guid, std::string const& name); + ObjectGuid GetGlobalPlayerGUID(std::string const& name) const; + GlobalPlayerData const* GetGlobalPlayerData(ObjectGuid::LowType guid) const; + void AddGlobalPlayerData(ObjectGuid::LowType guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, uint16 mailCount, uint32 guildId); + void UpdateGlobalPlayerData(ObjectGuid::LowType guid, uint8 mask, std::string const& name, uint8 level = 0, uint8 gender = 0, uint8 race = 0, uint8 playerClass = 0); + void UpdateGlobalPlayerMails(ObjectGuid::LowType guid, int16 count, bool add = true); + void UpdateGlobalPlayerGuild(ObjectGuid::LowType guid, uint32 guildId); + void UpdateGlobalPlayerGroup(ObjectGuid::LowType guid, uint32 groupId); + void UpdateGlobalPlayerArenaTeam(ObjectGuid::LowType guid, uint8 slot, uint32 arenaTeamId); + void UpdateGlobalNameData(ObjectGuid::LowType guidLow, std::string const& oldName, std::string const& newName); + void DeleteGlobalPlayerData(ObjectGuid::LowType guid, std::string const& name); void ProcessCliCommands(); void QueueCliCommand(CliCommandHolder* commandHolder) { cliCmdQueue.add(commandHolder); } @@ -394,6 +395,8 @@ public: std::string const& GetRealmName() const { return _realmName; } // pussywizard void SetRealmName(std::string name) { _realmName = name; } // pussywizard + void RemoveOldCorpses(); + protected: void _UpdateGameTime(); // callback for UpdateRealmCharacters diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 09f12133c4..bb0fc5c4b5 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -104,9 +104,9 @@ public: handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName); if (handler->GetSession()) { - LOG_DEBUG("warden", "Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password.", + LOG_DEBUG("warden", "Account: %d (IP: %s) Character:[%s] (%s) Change Password.", handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), - handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow()); + handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str()); } break; case AOR_NAME_TOO_LONG: diff --git a/src/server/scripts/Commands/cs_arena.cpp b/src/server/scripts/Commands/cs_arena.cpp index 3aa9c5be6c..6e6346e2c6 100644 --- a/src/server/scripts/Commands/cs_arena.cpp +++ b/src/server/scripts/Commands/cs_arena.cpp @@ -209,7 +209,7 @@ public: return false; Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid)) return false; @@ -251,7 +251,7 @@ public: } std::string oldCaptainName; - sObjectMgr->GetPlayerNameByGUID(arena->GetCaptain(), oldCaptainName); + sObjectMgr->GetPlayerNameByGUID(arena->GetCaptain().GetCounter(), oldCaptainName); arena->SetCaptain(targetGuid); handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainName.c_str(), target->GetName().c_str()); @@ -279,7 +279,7 @@ public: handler->PSendSysMessage(LANG_ARENA_INFO_HEADER, arena->GetName().c_str(), arena->GetId(), arena->GetRating(), arena->GetType(), arena->GetType()); for (ArenaTeam::MemberList::iterator itr = arena->m_membersBegin(); itr != arena->m_membersEnd(); ++itr) - handler->PSendSysMessage(LANG_ARENA_INFO_MEMBERS, itr->Name.c_str(), GUID_LOPART(itr->Guid), itr->PersonalRating, (arena->GetCaptain() == itr->Guid ? "- Captain" : "")); + handler->PSendSysMessage(LANG_ARENA_INFO_MEMBERS, itr->Name.c_str(), itr->Guid.GetCounter(), itr->PersonalRating, (arena->GetCaptain() == itr->Guid ? "- Captain" : "")); return true; } diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index da10f66324..20c673a561 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -304,7 +304,7 @@ public: return false; Player* target = ObjectAccessor::FindPlayerByName(args, false); - uint32 targetGuid = 0; + ObjectGuid targetGuid; std::string name(args); if (!target) @@ -317,10 +317,10 @@ public: } } else - targetGuid = target->GetGUIDLow(); + targetGuid = target->GetGUID(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BANINFO); - stmt->setUInt32(0, targetGuid); + stmt->setUInt32(0, targetGuid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) { diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 980ae8dcf2..c2a9667bbb 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -74,7 +74,7 @@ public: // Stores informations about a deleted character struct DeletedInfo { - uint32 lowGuid; ///< the low GUID from the character + ObjectGuid::LowType lowGuid; ///< the low GUID from the character std::string name; ///< the character name uint32 accountId; ///< the account id std::string accountName; ///< the account name @@ -223,7 +223,7 @@ public: sWorld->AddGlobalPlayerData(delInfo.lowGuid, delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8(), 0, 0); } - static void HandleCharacterLevel(Player* player, uint64 playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler) + static void HandleCharacterLevel(Player* player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler) { if (player) { @@ -246,11 +246,11 @@ public: // Update level and reset XP, everything else will be updated at login PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_LEVEL); stmt->setUInt8(0, uint8(newLevel)); - stmt->setUInt32(1, GUID_LOPART(playerGuid)); + stmt->setUInt32(1, playerGuid.GetCounter()); CharacterDatabase.Execute(stmt); // xinef: update global storage - sWorld->UpdateGlobalPlayerData(GUID_LOPART(playerGuid), PLAYER_UPDATE_DATA_LEVEL, "", newLevel); + sWorld->UpdateGlobalPlayerData(playerGuid.GetCounter(), PLAYER_UPDATE_DATA_LEVEL, "", newLevel); } } @@ -303,7 +303,7 @@ public: static bool HandleCharacterRenameCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; @@ -311,7 +311,7 @@ public: if (target) { // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; handler->PSendSysMessage(LANG_RENAME_PLAYER, handler->GetNameLink(target).c_str()); @@ -324,11 +324,11 @@ public: return false; std::string oldNameLink = handler->playerLink(targetName); - handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid)); + handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), targetGuid.GetCounter()); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_RENAME)); - stmt->setUInt32(1, GUID_LOPART(targetGuid)); + stmt->setUInt32(1, targetGuid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -351,12 +351,12 @@ public: } Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName)) return false; - int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromStorage(targetGuid); + int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromStorage(targetGuid.GetCounter()); int32 newlevel = levelStr ? atoi(levelStr) : oldlevel; if (newlevel < 1) @@ -379,7 +379,7 @@ public: static bool HandleCharacterCustomizeCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; @@ -390,13 +390,13 @@ public: { handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str()); target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE); - stmt->setUInt32(1, target->GetGUIDLow()); + stmt->setUInt32(1, target->GetGUID().GetCounter()); } else { std::string oldNameLink = handler->playerLink(targetName); - stmt->setUInt32(1, GUID_LOPART(targetGuid)); - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid)); + stmt->setUInt32(1, targetGuid.GetCounter()); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), targetGuid.GetCounter()); } CharacterDatabase.Execute(stmt); @@ -406,7 +406,7 @@ public: static bool HandleCharacterChangeFactionCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) @@ -418,13 +418,13 @@ public: { handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str()); target->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION); - stmt->setUInt32(1, target->GetGUIDLow()); + stmt->setUInt32(1, target->GetGUID().GetCounter()); } else { std::string oldNameLink = handler->playerLink(targetName); - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid)); - stmt->setUInt32(1, GUID_LOPART(targetGuid)); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), targetGuid.GetCounter()); + stmt->setUInt32(1, targetGuid.GetCounter()); } CharacterDatabase.Execute(stmt); @@ -434,7 +434,7 @@ public: static bool HandleCharacterChangeRaceCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; @@ -446,14 +446,14 @@ public: // TODO : add text into database handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str()); target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE); - stmt->setUInt32(1, target->GetGUIDLow()); + stmt->setUInt32(1, target->GetGUID().GetCounter()); } else { std::string oldNameLink = handler->playerLink(targetName); // TODO : add text into database - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid)); - stmt->setUInt32(1, GUID_LOPART(targetGuid)); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), targetGuid.GetCounter()); + stmt->setUInt32(1, targetGuid.GetCounter()); } CharacterDatabase.Execute(stmt); @@ -688,7 +688,7 @@ public: if (!normalizePlayerName(characterName)) return false; - uint32 characterGuid; + ObjectGuid characterGuid; uint32 accountId; Player* player = ObjectAccessor::FindPlayerByName(characterName); @@ -707,14 +707,14 @@ public: handler->SetSentErrorMessage(true); return false; } - accountId = sObjectMgr->GetPlayerAccountIdByGUID(characterGuid); + accountId = sObjectMgr->GetPlayerAccountIdByGUID(characterGuid.GetCounter()); } std::string accountName; AccountMgr::GetName(accountId, accountName); - Player::DeleteFromDB(characterGuid, accountId, true, true); - handler->PSendSysMessage(LANG_CHARACTER_DELETED, characterName.c_str(), characterGuid, accountName.c_str(), accountId); + Player::DeleteFromDB(characterGuid.GetCounter(), accountId, true, true); + handler->PSendSysMessage(LANG_CHARACTER_DELETED, characterName.c_str(), characterGuid.GetCounter(), accountName.c_str(), accountId); return true; } @@ -733,12 +733,12 @@ public: } Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName)) return false; - int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromStorage(targetGuid); + int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromStorage(targetGuid.GetCounter()); int32 addlevel = levelStr ? atoi(levelStr) : 1; int32 newlevel = oldlevel + addlevel; @@ -824,7 +824,7 @@ public: guidStr = strtok(nullptr, " "); } - uint32 guid = 0; + ObjectGuid::LowType guid = 0; if (guidStr) { @@ -912,10 +912,10 @@ public: if (!fileStr || !playerStr) return false; - uint64 guid; + ObjectGuid guid; // character name can't start from number if (isNumeric(playerStr)) - guid = MAKE_NEW_GUID(atoi(playerStr), 0, HIGHGUID_PLAYER); + guid = ObjectGuid::Create<HighGuid::Player>(atoi(playerStr)); else { std::string name = handler->extractPlayerNameFromLink(playerStr); @@ -929,14 +929,14 @@ public: guid = sObjectMgr->GetPlayerGUIDByName(name); } - if (!sObjectMgr->GetPlayerAccountIdByGUID(guid)) + if (!sObjectMgr->GetPlayerAccountIdByGUID(guid.GetCounter())) { handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND); handler->SetSentErrorMessage(true); return false; } - switch (PlayerDumpWriter().WriteDump(fileStr, uint32(guid))) + switch (PlayerDumpWriter().WriteDump(fileStr, guid.GetCounter())) { case DUMP_SUCCESS: handler->PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS); diff --git a/src/server/scripts/Commands/cs_cheat.cpp b/src/server/scripts/Commands/cs_cheat.cpp index 6590391245..a30fd91f2a 100644 --- a/src/server/scripts/Commands/cs_cheat.cpp +++ b/src/server/scripts/Commands/cs_cheat.cpp @@ -139,7 +139,7 @@ public: } // check online security - if (handler->HasLowerSecurity(player, 0)) + if (handler->HasLowerSecurity(player)) return false; if (strncmp(args, "on", 3) == 0) @@ -190,7 +190,7 @@ public: if (!chr) chr = handler->GetSession()->GetPlayer(); - else if (handler->HasLowerSecurity(chr, 0)) // check online security + else if (handler->HasLowerSecurity(chr)) // check online security return false; if (!*args) diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 28a5bd20c6..78352e1e78 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -239,7 +239,7 @@ public: return false; SellResult msg = SellResult(atoi(args)); - handler->GetSession()->GetPlayer()->SendSellError(msg, 0, 0, 0); + handler->GetSession()->GetPlayer()->SendSellError(msg, 0, ObjectGuid::Empty, 0); return true; } @@ -365,11 +365,11 @@ public: } else if (type == "appitsguid") { - data.append(unit->GetPackGUID()); + data << unit->GetPackGUID(); } else if (type == "appmyguid") { - data.append(player->GetPackGUID()); + data << player->GetPackGUID(); } else if (type == "appgoguid") { @@ -381,7 +381,7 @@ public: ifs.close(); return false; } - data.append(obj->GetPackGUID()); + data << obj->GetPackGUID(); } else if (type == "goguid") { @@ -393,15 +393,15 @@ public: ifs.close(); return false; } - data << uint64(obj->GetGUID()); + data << obj->GetGUID(); } else if (type == "myguid") { - data << uint64(player->GetGUID()); + data << player->GetGUID(); } else if (type == "itsguid") { - data << uint64(unit->GetGUID()); + data << unit->GetGUID(); } else if (type == "itspos") { @@ -503,7 +503,8 @@ public: if (!target) return false; - handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", target->GetName().c_str(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient"); + handler->PSendSysMessage("Loot recipient for creature %s (%s, SpawnId %u) is %s", + target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetSpawnId(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient"); return true; } @@ -560,10 +561,12 @@ public: for (uint8 j = 0; j < bag->GetBagSize(); ++j) if (Item* item2 = bag->GetItemByPos(j)) if (item2->GetState() == state) - handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID())); + handler->PSendSysMessage("bag: 255 slot: %d %s, owner: %s", + item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetOwnerGUID().ToString().c_str()); } else if (item->GetState() == state) - handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID())); + handler->PSendSysMessage("bag: 255 slot: %d %s, owner: %s", + item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str()); } } } @@ -597,7 +600,7 @@ public: break; } - handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bagSlot, item->GetSlot(), item->GetGUIDLow(), st.c_str()); + handler->PSendSysMessage("bag: %d slot: %d %s - state: %s", bagSlot, item->GetSlot(), item->GetGUID().ToString().c_str(), st.c_str()); } if (updateQueue.empty()) handler->PSendSysMessage("The player's updatequeue is empty"); @@ -618,21 +621,23 @@ public: if (item->GetSlot() != i) { - handler->PSendSysMessage("Item with slot %d and guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot()); + handler->PSendSysMessage("Item with slot %d %s has an incorrect slot value: %d", i, item->GetGUID().ToString().c_str(), item->GetSlot()); error = true; continue; } if (item->GetOwnerGUID() != player->GetGUID()) { - handler->PSendSysMessage("The item with slot %d and itemguid %d does have non-matching owner guid (%d) and player guid (%d) !", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); + handler->PSendSysMessage("The item with slot %d (%s) does have non-matching owner (%s) and player (%sd) !", + item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str()); error = true; continue; } if (Bag* container = item->GetContainer()) { - handler->PSendSysMessage("The item with slot %d and guid %d has a container (slot: %d, guid: %d) but shouldn't!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); + handler->PSendSysMessage("The item with slot %d (%s) has a container (slot: %d, %s) but shouldn't!", + item->GetSlot(), item->GetGUID().ToString().c_str(), container->GetSlot(), container->GetGUID().ToString().c_str()); error = true; continue; } @@ -642,28 +647,32 @@ public: uint16 qp = item->GetQueuePos(); if (qp > updateQueue.size()) { - handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp); + handler->PSendSysMessage("The item with slot %d (%s) has its queuepos (%d) larger than the update queue size! ", + item->GetSlot(), item->GetGUID().ToString().c_str(), qp); error = true; continue; } if (updateQueue[qp] == nullptr) { - handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) pointing to nullptr in the queue!", item->GetSlot(), item->GetGUIDLow(), qp); + handler->PSendSysMessage("The item with slot %d (%s) has its queuepos (%d) pointing to nullptr in the queue!", + item->GetSlot(), item->GetGUID().ToString().c_str(), qp); error = true; continue; } if (updateQueue[qp] != item) { - handler->PSendSysMessage("The item with slot %d and guid %d has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); + handler->PSendSysMessage("The item with slot %d (%s) has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, %s)", + item->GetSlot(), item->GetGUID().ToString().c_str(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().ToString().c_str()); error = true; continue; } } else if (item->GetState() != ITEM_UNCHANGED) { - handler->PSendSysMessage("The item with slot %d and guid %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState()); + handler->PSendSysMessage("The item with slot %d (%s) is not in queue but should be (state: %d)!", + item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetState()); error = true; continue; } @@ -678,14 +687,16 @@ public: if (item2->GetSlot() != j) { - handler->PSendSysMessage("The item in bag %d and slot %d (guid: %d) has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot()); + handler->PSendSysMessage("The item in bag %d and slot %d (%s) has an incorrect slot value: %d", + bag->GetSlot(), j, item2->GetGUID().ToString().c_str(), item2->GetSlot()); error = true; continue; } if (item2->GetOwnerGUID() != player->GetGUID()) { - handler->PSendSysMessage("The item in bag %d at slot %d and with itemguid %d, the owner's guid (%d) and the player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow()); + handler->PSendSysMessage("The item in bag %d at slot %d and with item %s, the owner (%s) and the player (%s) don't match!", + bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str()); error = true; continue; } @@ -693,14 +704,16 @@ public: Bag* container = item2->GetContainer(); if (!container) { - handler->PSendSysMessage("The item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow()); + handler->PSendSysMessage("The item in bag %d at slot %d (%s) has no container!", + bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str()); error = true; continue; } if (container != bag) { - handler->PSendSysMessage("The item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); + handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a different container(slot %d %s)!", + bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), container->GetSlot(), container->GetGUID().ToString().c_str()); error = true; continue; } @@ -710,28 +723,32 @@ public: uint16 qp = item2->GetQueuePos(); if (qp > updateQueue.size()) { - handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); + handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a queuepos (%d) larger than the update queue size! ", + bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp); error = true; continue; } if (updateQueue[qp] == nullptr) { - handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to nullptr in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); + handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a queuepos (%d) that points to nullptr in the queue!", + bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp); error = true; continue; } if (updateQueue[qp] != item2) { - handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); + handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, %s)", + bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().ToString().c_str()); error = true; continue; } } else if (item2->GetState() != ITEM_UNCHANGED) { - handler->PSendSysMessage("The item in bag %d at slot %d having guid %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState()); + handler->PSendSysMessage("The item in bag %d at slot %d (%s) is not in queue but should be (state: %d)!", + bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetState()); error = true; continue; } @@ -747,14 +764,15 @@ public: if (item->GetOwnerGUID() != player->GetGUID()) { - handler->PSendSysMessage("queue(" SZFMTD "): For the item with guid %d, the owner's guid (%d) and the player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); + handler->PSendSysMessage("queue(" SZFMTD "): For the item (%s), the owner (%s) and the player (%s) don't match!", + i, item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str()); error = true; continue; } if (item->GetQueuePos() != i) { - handler->PSendSysMessage("queue(" SZFMTD "): For the item with guid %d, the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow()); + handler->PSendSysMessage("queue(" SZFMTD "): For the item (%s), the queuepos doesn't match it's position in the queue!", i, item->GetGUID().ToString().c_str()); error = true; continue; } @@ -766,14 +784,16 @@ public: if (test == nullptr) { - handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have any item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow()); + handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item (%s) are incorrect, the player doesn't have any item at that position!", + i, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str()); error = true; continue; } if (test != item) { - handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, an item which guid is %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); + handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item (%s) are incorrect, an item (%s) is there instead!", + i, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), test->GetGUID().ToString().c_str()); error = true; continue; } @@ -806,7 +826,7 @@ public: ThreatContainer::StorageType const& threatList = target->getThreatManager().getThreatList(); ThreatContainer::StorageType::const_iterator itr; uint32 count = 0; - handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow()); + handler->PSendSysMessage("Threat list of %s (%s)", target->GetName().c_str(), target->GetGUID().ToString().c_str()); for (itr = threatList.begin(); itr != threatList.end(); ++itr) { Unit* unit = (*itr)->getTarget(); @@ -815,7 +835,7 @@ public: handler->PSendSysMessage(" %u. No Unit - threat %f", ++count, (*itr)->getThreat()); continue; } - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUIDLow(), (*itr)->getThreat()); + handler->PSendSysMessage(" %u. %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->getThreat()); } ThreatContainer::StorageType const& threatList2 = target->getThreatManager().getOfflineThreatList(); for (itr = threatList2.begin(); itr != threatList2.end(); ++itr) @@ -826,7 +846,7 @@ public: handler->PSendSysMessage(" %u. [offline] No Unit - threat %f", ++count, (*itr)->getThreat()); continue; } - handler->PSendSysMessage(" %u. [offline] %s (guid %u) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUIDLow(), (*itr)->getThreat()); + handler->PSendSysMessage(" %u. [offline] %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->getThreat()); } handler->SendSysMessage("End of threat list."); @@ -840,11 +860,12 @@ public: target = handler->GetSession()->GetPlayer(); HostileReference* ref = target->getHostileRefManager().getFirst(); uint32 count = 0; - handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow()); + handler->PSendSysMessage("Hostil reference list of %s (%s)", target->GetName().c_str(), target->GetGUID().ToString().c_str()); while (ref) { if (Unit* unit = ref->GetSource()->GetOwner()) - handler->PSendSysMessage(" %u. %s %s (guid %u) - threat %f", ++count, (ref->isOnline() ? "" : "[offline]"), unit->GetName().c_str(), unit->GetGUIDLow(), ref->getThreat()); + handler->PSendSysMessage(" %u. %s %s (%s) - threat %f", ++count, (ref->isOnline() ? "" : "[offline]"), + unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), ref->getThreat()); else handler->PSendSysMessage(" %u. No Owner - threat %f", ++count, ref->getThreat()); ref = ref->next(); @@ -942,7 +963,7 @@ public: Map* map = handler->GetSession()->GetPlayer()->GetMap(); - if (!v->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_VEHICLE), map, handler->GetSession()->GetPlayer()->GetPhaseMask(), entry, id, x, y, z, o)) + if (!v->Create(map->GenerateLowGuid<HighGuid::Vehicle>(), map, handler->GetSession()->GetPlayer()->GetPhaseMask(), entry, id, x, y, z, o)) { delete v; return false; @@ -984,10 +1005,10 @@ public: if (!e || !f) return false; - uint32 guid = (uint32)atoi(e); + ObjectGuid::LowType guid = (uint32)atoi(e); uint32 index = (uint32)atoi(f); - Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); + Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid)); if (!i) return false; @@ -1014,11 +1035,11 @@ public: if (!e || !f || !g) return false; - uint32 guid = (uint32)atoi(e); + ObjectGuid::LowType guid = (uint32)atoi(e); uint32 index = (uint32)atoi(f); uint32 value = (uint32)atoi(g); - Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); + Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid)); if (!i) return false; @@ -1040,9 +1061,9 @@ public: if (!e) return false; - uint32 guid = (uint32)atoi(e); + ObjectGuid::LowType guid = (uint32)atoi(e); - Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); + Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid)); if (!i) return false; @@ -1128,12 +1149,12 @@ public: return false; } - uint64 guid = target->GetGUID(); + ObjectGuid guid = target->GetGUID(); uint32 opcode = (uint32)atoi(x); if (opcode >= target->GetValuesCount()) { - handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount()); + handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, guid.GetCounter(), target->GetValuesCount()); return false; } @@ -1145,13 +1166,13 @@ public: { uint32 value = (uint32)atoi(y); target->SetUInt32Value(opcode, value); - handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), opcode, value); + handler->PSendSysMessage(LANG_SET_UINT_FIELD, guid.GetCounter(), opcode, value); } else { float value = (float)atof(y); target->SetFloatValue(opcode, value); - handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value); + handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, guid.GetCounter(), opcode, value); } return true; @@ -1176,12 +1197,12 @@ public: return false; } - uint64 guid = target->GetGUID(); + ObjectGuid guid = target->GetGUID(); uint32 opcode = (uint32)atoi(x); if (opcode >= target->GetValuesCount()) { - handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount()); + handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, guid.GetCounter(), target->GetValuesCount()); return false; } @@ -1192,12 +1213,12 @@ public: if (isInt32) { uint32 value = target->GetUInt32Value(opcode); - handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), opcode, value); + handler->PSendSysMessage(LANG_GET_UINT_FIELD, guid.GetCounter(), opcode, value); } else { float value = target->GetFloatValue(opcode); - handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value); + handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, guid.GetCounter(), opcode, value); } return true; @@ -1219,7 +1240,7 @@ public: if (opcode >= handler->GetSession()->GetPlayer()->GetValuesCount()) { - handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount()); + handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, handler->GetSession()->GetPlayer()->GetGUID().GetCounter(), handler->GetSession()->GetPlayer()->GetValuesCount()); return false; } @@ -1269,13 +1290,13 @@ public: { value = unit->GetUInt32Value(updateIndex); - handler->PSendSysMessage(LANG_UPDATE, unit->GetGUIDLow(), updateIndex, value); + handler->PSendSysMessage(LANG_UPDATE, unit->GetGUID().GetCounter(), updateIndex, value); return true; } value = atoi(val); - handler->PSendSysMessage(LANG_UPDATE_CHANGE, unit->GetGUIDLow(), updateIndex, value); + handler->PSendSysMessage(LANG_UPDATE_CHANGE, unit->GetGUID().GetCounter(), updateIndex, value); unit->SetUInt32Value(updateIndex, value); diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index a4ab38d7d6..24e8f2d6e4 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -96,7 +96,7 @@ public: handler->SendSysMessage(LANG_USE_BOL); return false; } - data.append(target->GetPackGUID()); + data << target->GetPackGUID(); data << uint32(0); // unknown target->SendMessageToSet(&data, true); handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target).c_str(), args); @@ -110,8 +110,7 @@ public: bool footer = false; std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock()); - - HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers(); + HashMapHolder<Player>::MapType const& m = ObjectAccessor::GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { AccountTypes itrSec = itr->second->GetSession()->GetSecurity(); diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index 44ce153aad..a0c3b7550c 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -123,11 +123,11 @@ public: float z = fields[2].GetFloat(); float ort = fields[3].GetFloat(); int mapId = fields[4].GetUInt16(); - uint32 guid = fields[5].GetUInt32(); + ObjectGuid::LowType guid = fields[5].GetUInt32(); uint32 id = fields[6].GetUInt32(); // if creature is in same map with caster go at its current location - if (Creature* creature = ObjectAccessor::GetCreature(*player, MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT))) + if (Creature* creature = ObjectAccessor::GetCreature(*player, ObjectGuid::Create<HighGuid::Unit>(id, guid))) { x = creature->GetPositionX(); y = creature->GetPositionY(); diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 95408cadba..f04081d5e4 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -68,16 +68,11 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; - GameObject* object = nullptr; - - // by DB guid - if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, goData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); @@ -137,7 +132,7 @@ public: Map* map = player->GetMap(); GameObject* object = sObjectMgr->IsGameObjectStaticTransport(objectInfo->entry) ? new StaticTransport() : new GameObject(); - uint32 guidLow = sObjectMgr->GenerateRecycledLowGuid(HIGHGUID_GAMEOBJECT); + ObjectGuid::LowType guidLow = map->GenerateLowGuid<HighGuid::GameObject>(); if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), x, y, z, o, G3D::Quat(), 0, GO_STATE_READY)) { @@ -270,7 +265,8 @@ public: bool found = false; float x, y, z, o; - uint32 guidLow, id, phase; + ObjectGuid::LowType guidLow; + uint32 id, phase; uint16 mapId; uint32 poolId; @@ -304,7 +300,7 @@ public: return false; } - GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(guidLow, id, HIGHGUID_GAMEOBJECT)); + GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(ObjectGuid::Create<HighGuid::GameObject>(id, guidLow)); handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name.c_str(), guidLow, id, x, y, z, mapId, o, phase); @@ -330,16 +326,11 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; - GameObject* object = nullptr; - - // by DB guid - if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); @@ -347,13 +338,13 @@ public: return false; } - uint64 ownerGuid = object->GetOwnerGUID(); + ObjectGuid ownerGuid = object->GetOwnerGUID(); if (ownerGuid) { Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid); - if (!owner || !IS_PLAYER_GUID(ownerGuid)) + if (!owner || !ownerGuid.IsPlayer()) { - handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(ownerGuid), object->GetGUIDLow()); + handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), object->GetSpawnId()); handler->SetSentErrorMessage(true); return false; } @@ -365,7 +356,7 @@ public: object->Delete(); object->DeleteFromDB(); - handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetGUIDLow()); + handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetSpawnId()); return true; } @@ -378,16 +369,11 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; - GameObject* object = nullptr; - - // by DB guid - if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); @@ -423,7 +409,7 @@ public: object->SaveToDB(); object->Refresh(); - handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow(), oz, oy, ox); + handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId(), oz, oy, ox); return true; } @@ -436,16 +422,11 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; - GameObject* object = nullptr; - - // by DB guid - if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); @@ -488,7 +469,7 @@ public: object->SaveToDB(); object->Refresh(); - handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow()); + handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId()); return true; } @@ -501,16 +482,11 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; - GameObject* object = nullptr; - - // by DB guid - if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); @@ -556,7 +532,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); @@ -647,8 +623,7 @@ public: if (guidLow > 0) { - if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); + object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); } else object = handler->GetSession()->GetPlayer()->FindNearestGameObject(-guidLow, 30.0f); diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp index afb0b31d34..eb4c9a731c 100644 --- a/src/server/scripts/Commands/cs_guild.cpp +++ b/src/server/scripts/Commands/cs_guild.cpp @@ -131,7 +131,7 @@ public: return false; // if not guild name only (in "") then player name - uint64 targetGuid; + ObjectGuid targetGuid; if (!handler->extractPlayerTarget(*args != '"' ? (char*)args : nullptr, nullptr, &targetGuid)) return false; @@ -155,11 +155,11 @@ public: static bool HandleGuildUninviteCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid)) return false; - uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromStorage(GUID_LOPART(targetGuid)); + uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromStorage(targetGuid.GetCounter()); if (!guildId) return false; @@ -180,12 +180,12 @@ public: return false; Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string target_name; if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &target_name)) return false; - uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromStorage(GUID_LOPART(targetGuid)); + uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromStorage(targetGuid.GetCounter()); if (!guildId) return false; @@ -217,8 +217,8 @@ public: // Display Guild Information handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), guild->GetId()); // Guild Id + Name std::string guildMasterName; - if (sObjectMgr->GetPlayerNameByGUID(guild->GetLeaderGUID(), guildMasterName)) - handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), GUID_LOPART(guild->GetLeaderGUID())); // Guild Master + if (sObjectMgr->GetPlayerNameByGUID(guild->GetLeaderGUID().GetCounter(), guildMasterName)) + handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID().GetCounter()); // Guild Master // Format creation date char createdDateStr[20]; diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp index 67a2edc80d..0ab8a68d4b 100644 --- a/src/server/scripts/Commands/cs_honor.cpp +++ b/src/server/scripts/Commands/cs_honor.cpp @@ -57,7 +57,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; uint32 amount = (uint32)atoi(args); @@ -76,7 +76,7 @@ public: } // check online security - if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) + if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer())) return false; handler->GetSession()->GetPlayer()->RewardHonor(target, 1); @@ -94,7 +94,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; target->UpdateHonorFields(); diff --git a/src/server/scripts/Commands/cs_instance.cpp b/src/server/scripts/Commands/cs_instance.cpp index 502918a018..2ab6759f11 100644 --- a/src/server/scripts/Commands/cs_instance.cpp +++ b/src/server/scripts/Commands/cs_instance.cpp @@ -66,7 +66,7 @@ public: uint32 counter = 0; for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUIDLow(), Difficulty(i)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUID(), Difficulty(i)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { InstanceSave* save = itr->second.save; @@ -108,7 +108,7 @@ public: for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { - BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUIDLow(), Difficulty(i)); + BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUID(), Difficulty(i)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end();) { InstanceSave* save = itr->second.save; @@ -118,7 +118,7 @@ public: uint32 ttr = (resetTime >= time(nullptr) ? resetTime - time(nullptr) : 0); std::string timeleft = GetTimeString(ttr); handler->PSendSysMessage("unbinding map: %d, inst: %d, perm: %s, diff: %d, canReset: %s, TTR: %s%s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str(), (itr->second.extended ? " (extended)" : "")); - sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUIDLow(), itr->first, Difficulty(i), true, player); + sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), itr->first, Difficulty(i), true, player); itr = m_boundInstances.begin(); counter++; } diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index 9cc9f5d8d2..084651d73b 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -16,7 +16,7 @@ void GetPlayerInfo(ChatHandler* handler, Player* player) if (!player) return; - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); lfg::LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid); std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid)); @@ -73,7 +73,7 @@ public: return true; } - uint64 guid = grp->GetGUID(); + ObjectGuid guid = grp->GetGUID(); std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid)); handler->PSendSysMessage(LANG_LFG_GROUP_INFO, grp->isLFGGroup(), state.c_str(), sLFGMgr->GetDungeon(guid)); diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index d5ce231de6..437ac5e3a2 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -94,12 +94,12 @@ public: { do { - Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); - uint16 mapId = fields[4].GetUInt16(); + Field* fields = result->Fetch(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); + float x = fields[1].GetFloat(); + float y = fields[2].GetFloat(); + float z = fields[3].GetFloat(); + uint16 mapId = fields[4].GetUInt16(); if (handler->GetSession()) handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name.c_str(), x, y, z, mapId); @@ -378,13 +378,13 @@ public: { do { - Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); - uint16 mapId = fields[4].GetUInt16(); - uint32 entry = fields[5].GetUInt32(); + Field* fields = result->Fetch(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); + float x = fields[1].GetFloat(); + float y = fields[2].GetFloat(); + float z = fields[3].GetFloat(); + uint16 mapId = fields[4].GetUInt16(); + uint32 entry = fields[5].GetUInt32(); if (handler->GetSession()) handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapId); @@ -427,8 +427,8 @@ public: handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str().c_str() : name), aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(), aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""), - (talent ? talentStr : ""), IS_PLAYER_GUID(aura->GetCasterGUID()) ? "player" : "creature", - GUID_LOPART(aura->GetCasterGUID())); + (talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature", + aura->GetCasterGUID().GetCounter()); } if (!args || std::string(args) != "all") diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 9e9b633357..315db5b21e 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -1414,11 +1414,11 @@ public: do { - Field* characterFields = result2->Fetch(); - uint32 guid = characterFields[0].GetUInt32(); - std::string name = characterFields[1].GetString(); + Field* characterFields = result2->Fetch(); + ObjectGuid::LowType guid = characterFields[0].GetUInt32(); + std::string name = characterFields[1].GetString(); uint8 plevel = 0, prace = 0, pclass = 0; - bool online = (ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)) != nullptr); + bool online = ObjectAccessor::FindPlayerByLowGUID(guid) != nullptr; if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(guid)) { diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 0e976cf784..02dbaecafa 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -368,16 +368,48 @@ public: WorldObject* object = nullptr; if (*args) { - uint64 guid = handler->extractGuidFromLink((char*)args); - if (guid) - object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT); + HighGuid guidHigh; + ObjectGuid::LowType guidLow = handler->extractLowGuidFromLink((char*)args, guidHigh); + if (!guidLow) + return false; - if (!object) + switch (guidHigh) { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - return false; + case HighGuid::Player: + { + object = ObjectAccessor::FindPlayerByLowGUID(guidLow); + if (!object) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + } + break; + } + case HighGuid::Unit: + { + object = handler->GetCreatureFromPlayerMapByDbGuid(guidLow); + if (!object) + { + handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); + handler->SetSentErrorMessage(true); + } + break; + } + case HighGuid::GameObject: + { + object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); + if (!object) + { + handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); + handler->SetSentErrorMessage(true); + } + break; + } + default: + return false; } + if (!object) + return false; } else { @@ -514,7 +546,7 @@ public: static bool HandleAppearCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; @@ -530,7 +562,7 @@ public: if (target) { // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; std::string chrNameLink = handler->playerLink(targetName); @@ -578,10 +610,10 @@ public: } // if the GM is bound to another instance, he will not be bound to another one - InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(_player->GetGUIDLow(), target->GetMapId(), target->GetDifficulty(map->IsRaid())); + InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(_player->GetGUID(), target->GetMapId(), target->GetDifficulty(map->IsRaid())); if (!bind) if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetInstanceId())) - sInstanceSaveMgr->PlayerBindToInstance(_player->GetGUIDLow(), save, !save->CanReset(), _player); + sInstanceSaveMgr->PlayerBindToInstance(_player->GetGUID(), save, !save->CanReset(), _player); if (map->IsRaid()) _player->SetRaidDifficulty(target->GetRaidDifficulty()); @@ -618,7 +650,7 @@ public: float x, y, z, o; uint32 map; bool in_flight; - if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, targetGuid)) + if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, targetGuid.GetCounter())) return false; // stop flight if need @@ -640,7 +672,7 @@ public: static bool HandleSummonCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; @@ -657,7 +689,7 @@ public: { std::string nameLink = handler->playerLink(targetName); // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; if (target->IsBeingTeleported()) @@ -692,7 +724,7 @@ public: Map* destMap = target->GetMap(); if (destMap->Instanceable() && destMap->GetInstanceId() != map->GetInstanceId()) - sInstanceSaveMgr->PlayerUnbindInstance(target->GetGUIDLow(), map->GetInstanceId(), target->GetDungeonDifficulty(), true, target); + sInstanceSaveMgr->PlayerUnbindInstance(target->GetGUID(), map->GetInstanceId(), target->GetDungeonDifficulty(), true, target); // we are in an instance, and can only summon players in our group with us as leader if (!handler->GetSession()->GetPlayer()->GetGroup() || !target->GetGroup() || @@ -755,7 +787,7 @@ public: return false; // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; Group* group = target->GetGroup(); @@ -791,7 +823,7 @@ public: continue; // check online security - if (handler->HasLowerSecurity(player, 0)) + if (handler->HasLowerSecurity(player)) return false; std::string plNameLink = handler->GetNameLink(player); @@ -858,7 +890,7 @@ public: if (target->GetTypeId() == TYPEID_PLAYER) { - if (handler->HasLowerSecurity(target->ToPlayer(), 0, false)) + if (handler->HasLowerSecurity(target->ToPlayer())) return false; } @@ -880,7 +912,7 @@ public: static bool HandleReviveCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid)) return false; @@ -891,8 +923,10 @@ public: target->SaveToDB(false, false); } else - // will resurrected at login without corpse - sObjectAccessor->ConvertCorpseForPlayer(targetGuid); + { + SQLTransaction trans(nullptr); + Player::OfflineResurrect(targetGuid, trans); + } return true; } @@ -923,16 +957,16 @@ public: static bool HandleGUIDCommand(ChatHandler* handler, char const* /*args*/) { - uint64 guid = handler->GetSession()->GetPlayer()->GetTarget(); + ObjectGuid guid = handler->GetSession()->GetPlayer()->GetTarget(); - if (guid == 0) + if (!guid) { handler->SendSysMessage(LANG_NO_SELECTION); handler->SetSentErrorMessage(true); return false; } - handler->PSendSysMessage(LANG_OBJECT_GUID, GUID_LOPART(guid), GUID_HIPART(guid)); + handler->PSendSysMessage(LANG_OBJECT_GUID, guid.ToString().c_str()); return true; } @@ -1026,19 +1060,50 @@ public: static bool HandleGetDistanceCommand(ChatHandler* handler, char const* args) { WorldObject* obj = nullptr; - if (*args) { - uint64 guid = handler->extractGuidFromLink((char*)args); - if (guid) - obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT); + HighGuid guidHigh; + ObjectGuid::LowType guidLow = handler->extractLowGuidFromLink((char*)args, guidHigh); + if (!guidLow) + return false; - if (!obj) + switch (guidHigh) { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - return false; + case HighGuid::Player: + { + obj = ObjectAccessor::FindPlayerByLowGUID(guidLow); + if (!obj) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + } + break; + } + case HighGuid::Unit: + { + obj = handler->GetCreatureFromPlayerMapByDbGuid(guidLow); + if (!obj) + { + handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); + handler->SetSentErrorMessage(true); + } + break; + } + case HighGuid::GameObject: + { + obj = handler->GetObjectFromPlayerMapByDbGuid(guidLow); + if (!obj) + { + handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); + handler->SetSentErrorMessage(true); + } + break; + } + default: + return false; } + if (!obj) + return false; } else { @@ -1063,7 +1128,7 @@ public: return false; // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; if (target->IsBeingTeleported()) @@ -1116,7 +1181,7 @@ public: // Save all players in the world static bool HandleSaveAllCommand(ChatHandler* handler, char const* /*args*/) { - sObjectAccessor->SaveAllPlayers(); + ObjectAccessor::SaveAllPlayers(); handler->SendSysMessage(LANG_PLAYERS_SAVED); return true; } @@ -1137,7 +1202,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; std::string kickReasonStr = handler->GetAcoreString(LANG_NO_REASON); @@ -1725,15 +1790,15 @@ public: static bool HandlePInfoCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; PreparedStatement* stmt = nullptr; - uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER); + ObjectGuid parseGUID = ObjectGuid::Create<HighGuid::Player>(atol((char*)args)); - if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName)) + if (sObjectMgr->GetPlayerNameByGUID(parseGUID.GetCounter(), targetName)) { - target = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(parseGUID, 0, HIGHGUID_PLAYER)); + target = ObjectAccessor::FindConnectedPlayer(parseGUID); targetGuid = parseGUID; } else if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) @@ -1741,7 +1806,7 @@ public: // Account data print variables std::string userName = handler->GetAcoreString(LANG_ERROR); - uint32 lowguid = GUID_LOPART(targetGuid); + ObjectGuid::LowType lowguid = targetGuid.GetCounter(); uint32 accId = 0; std::string eMail = handler->GetAcoreString(LANG_ERROR); std::string regMail = handler->GetAcoreString(LANG_ERROR); @@ -1795,7 +1860,7 @@ public: if (target) { // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; accId = target->GetSession()->GetAccountId(); @@ -1821,7 +1886,7 @@ public: // Query informations from the DB stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO); - stmt->setUInt32(0, GUID_LOPART(targetGuid)); + stmt->setUInt32(0, lowguid); PreparedQueryResult charInfoResult = CharacterDatabase.Query(stmt); if (!charInfoResult) @@ -1917,7 +1982,7 @@ public: { banType = handler->GetAcoreString(LANG_CHARACTER); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS); - stmt->setUInt32(0, GUID_LOPART(targetGuid)); + stmt->setUInt32(0, lowguid); accBannedResult = CharacterDatabase.Query(stmt); } @@ -1948,8 +2013,8 @@ public: if (charXpResult) { Field* fields = charXpResult->Fetch(); - xp = fields[0].GetUInt32(); - uint32 gguid = fields[1].GetUInt32(); + xp = fields[0].GetUInt32(); + ObjectGuid::LowType gguid = fields[1].GetUInt32(); if (gguid != 0) { @@ -1970,7 +2035,7 @@ public: // Initiate output // Output I. LANG_PINFO_PLAYER - handler->PSendSysMessage(LANG_PINFO_PLAYER, target ? "" : handler->GetAcoreString(LANG_OFFLINE), nameLink.c_str(), GUID_LOPART(targetGuid)); + handler->PSendSysMessage(LANG_PINFO_PLAYER, target ? "" : handler->GetAcoreString(LANG_OFFLINE), nameLink.c_str(), targetGuid.GetCounter()); // Output II. LANG_PINFO_GM_ACTIVE if character is gamemaster if (target && target->IsGameMaster()) @@ -2129,7 +2194,7 @@ public: // Mail Data - an own query, because it may or may not be useful. // SQL: "SELECT SUM(CASE WHEN (checked & 1) THEN 1 ELSE 0 END) AS 'readmail', COUNT(*) AS 'totalmail' FROM mail WHERE `receiver` = ?" PreparedStatement* mailQuery = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_MAILS); - mailQuery->setUInt32(0, GUID_LOPART(targetGuid)); + mailQuery->setUInt32(0, lowguid); PreparedQueryResult mailInfoResult = CharacterDatabase.Query(mailQuery); if (mailInfoResult) { @@ -2192,12 +2257,12 @@ public: muteReasonStr = muteReason; Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName)) return false; - uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); + uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid.GetCounter()); // find only player from same account if any if (!target) @@ -2255,7 +2320,7 @@ public: { // pussywizard: notify all online GMs std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock()); - HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers(); + HashMapHolder<Player>::MapType const& m = ObjectAccessor::GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) if (itr->second->GetSession()->GetSecurity()) ChatHandler(itr->second->GetSession()).PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : handler->GetAcoreString(LANG_CONSOLE)), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); @@ -2268,12 +2333,12 @@ public: static bool HandleUnmuteCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; - uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); + uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid.GetCounter()); // find only player from same account if any if (!target) @@ -2383,7 +2448,7 @@ public: return false; } - handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUID().GetCounter()); MotionMaster* motionMaster = unit->GetMotionMaster(); float x, y, z; @@ -2426,9 +2491,9 @@ public: if (!target) handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL); else if (target->GetTypeId() == TYPEID_PLAYER) - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter()); else - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter()); break; } case FOLLOW_MOTION_TYPE: @@ -2442,9 +2507,9 @@ public: if (!target) handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); else if (target->GetTypeId() == TYPEID_PLAYER) - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter()); else - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter()); break; } case HOME_MOTION_TYPE: @@ -2520,7 +2585,7 @@ public: if (target->GetTypeId() == TYPEID_PLAYER) { - if (handler->HasLowerSecurity(target->ToPlayer(), 0, false)) + if (handler->HasLowerSecurity(target->ToPlayer())) return false; } @@ -2563,7 +2628,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; target->CombatStop(); @@ -2584,7 +2649,7 @@ public: return false; // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; // Repair items @@ -2602,7 +2667,7 @@ public: { // format: name "subject text" "mail text" Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; @@ -2628,12 +2693,12 @@ public: std::string text = msgText; // from console show not existed sender - MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); + MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUID().GetCounter() : 0, MAIL_STATIONERY_GM); //- TODO: Fix poor design SQLTransaction trans = CharacterDatabase.BeginTransaction(); MailDraft(subject, text) - .SendMailTo(trans, MailReceiver(target, GUID_LOPART(targetGuid)), sender); + .SendMailTo(trans, MailReceiver(target, targetGuid.GetCounter()), sender); CharacterDatabase.CommitTransaction(trans); @@ -2646,7 +2711,7 @@ public: { // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12] Player* receiver; - uint64 receiverGuid; + ObjectGuid receiverGuid; std::string receiverName; if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName)) return false; @@ -2726,7 +2791,7 @@ public: } // from console show not existed sender - MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); + MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUID().GetCounter() : 0, MAIL_STATIONERY_GM); // fill mail MailDraft draft(subject, text); @@ -2742,7 +2807,7 @@ public: } } - draft.SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender); + draft.SendMailTo(trans, MailReceiver(receiver, receiverGuid.GetCounter()), sender); CharacterDatabase.CommitTransaction(trans); std::string nameLink = handler->playerLink(receiverName); @@ -2755,7 +2820,7 @@ public: /// format: name "subject text" "mail text" money Player* receiver; - uint64 receiverGuid; + ObjectGuid receiverGuid; std::string receiverName; if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName)) return false; @@ -2786,13 +2851,13 @@ public: std::string text = msgText; // from console show not existed sender - MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); + MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUID().GetCounter() : 0, MAIL_STATIONERY_GM); SQLTransaction trans = CharacterDatabase.BeginTransaction(); MailDraft(subject, text) .AddMoney(money) - .SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender); + .SendMailTo(trans, MailReceiver(receiver, receiverGuid.GetCounter()), sender); CharacterDatabase.CommitTransaction(trans); @@ -2868,7 +2933,7 @@ public: creatureTarget->RemoveCorpse(); creatureTarget->SetHealth(0); // just for nice GM-mode view - pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID()); + pet->SetGuidValue(UNIT_FIELD_CREATEDBY, player->GetGUID()); pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction()); if (!pet->InitStatsForLevel(creatureTarget->getLevel())) @@ -3050,10 +3115,10 @@ public: } else if (targetName) { - if (uint64 playerGUID = sWorld->GetGlobalPlayerGUID(name)) + if (ObjectGuid playerGUID = sWorld->GetGlobalPlayerGUID(name)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN); - stmt->setUInt32(0, GUID_LOPART(playerGUID)); + stmt->setUInt32(0, playerGUID.GetCounter()); CharacterDatabase.Execute(stmt); handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str()); return true; @@ -3068,7 +3133,7 @@ public: { Player* player = nullptr; Group* group = nullptr; - uint64 guid = 0; + ObjectGuid guid; char* nameStr = strtok((char*)args, " "); if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid)) @@ -3085,7 +3150,7 @@ public: { Player* player = nullptr; Group* group = nullptr; - uint64 guid = 0; + ObjectGuid guid; char* nameStr = strtok((char*)args, " "); if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid)) @@ -3099,7 +3164,7 @@ public: { Player* player = nullptr; Group* group = nullptr; - uint64 guid = 0; + ObjectGuid guid; char* nameStr = strtok((char*)args, " "); if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid, true)) @@ -3116,8 +3181,8 @@ public: Player* playerSource = nullptr; Group* groupSource = nullptr; - uint64 guidSource = 0; - uint64 guidTarget = 0; + ObjectGuid guidSource; + ObjectGuid guidTarget; char* nameplgrStr = strtok((char*)args, " "); char* nameplStr = strtok(nullptr, " "); @@ -3167,14 +3232,14 @@ public: static bool HandleGroupListCommand(ChatHandler* handler, char const* args) { Player* playerTarget; - uint64 guidTarget = 0; + ObjectGuid guidTarget; std::string nameTarget; - uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER); + ObjectGuid parseGUID = ObjectGuid::Create<HighGuid::Player>(atol((char*)args)); - if (sObjectMgr->GetPlayerNameByGUID(parseGUID, nameTarget)) + if (sObjectMgr->GetPlayerNameByGUID(parseGUID.GetCounter(), nameTarget)) { - playerTarget = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(parseGUID, 0, HIGHGUID_PLAYER)); + playerTarget = ObjectAccessor::FindConnectedPlayer(parseGUID); guidTarget = parseGUID; } else if (!handler->extractPlayerTarget((char*)args, &playerTarget, &guidTarget, &nameTarget)) @@ -3185,8 +3250,8 @@ public: groupTarget = playerTarget->GetGroup(); if (!groupTarget && guidTarget) - if (uint32 groupId = Player::GetGroupIdFromStorage(GUID_LOPART(guidTarget))) - groupTarget = sGroupMgr->GetGroupByGUID(groupId); + if (uint32 groupGUID = Player::GetGroupIdFromStorage(guidTarget.GetCounter())) + groupTarget = sGroupMgr->GetGroupByGUID(groupGUID); if (groupTarget) { @@ -3217,11 +3282,11 @@ public: if (flags.empty()) flags = "None"; - /*Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld((*itr).guid); + /*Player* p = ObjectAccessor::FindConnectedPlayer((*itr).guid); const char* onlineState = p ? "online" : "offline"; handler->PSendSysMessage(LANG_GROUP_PLAYER_NAME_GUID, slot.name.c_str(), onlineState, - GUID_LOPART(slot.guid), flags.c_str(), lfg::GetRolesString(slot.roles).c_str());*/ + slot.guid.GetCounter(), flags.c_str(), lfg::GetRolesString(slot.roles).c_str());*/ } } else diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index ac104fc85d..b1e09d2bbf 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -99,7 +99,7 @@ public: return false; } - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; handler->PSendSysMessage(LANG_YOU_CHANGE_HP, handler->GetNameLink(target).c_str(), hp, hpm); @@ -137,7 +137,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; handler->PSendSysMessage(LANG_YOU_CHANGE_MANA, handler->GetNameLink(target).c_str(), mana, manam); @@ -186,7 +186,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; handler->PSendSysMessage(LANG_YOU_CHANGE_ENERGY, handler->GetNameLink(target).c_str(), energy / 10, energym / 10); @@ -239,7 +239,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; handler->PSendSysMessage(LANG_YOU_CHANGE_RAGE, handler->GetNameLink(target).c_str(), rage / 10, ragem / 10); @@ -308,7 +308,7 @@ public: uint32 flag = target->GetUInt32Value(UNIT_FIELD_FLAGS); uint32 npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS); uint32 dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS); - handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUIDLow(), factionid, flag, npcflag, dyflag); + handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUID().GetCounter(), factionid, flag, npcflag, dyflag); return true; } @@ -344,7 +344,7 @@ public: return false; } - handler->PSendSysMessage(LANG_YOU_CHANGE_FACTION, target->GetGUIDLow(), factionid, flag, npcflag, dyflag); + handler->PSendSysMessage(LANG_YOU_CHANGE_FACTION, target->GetGUID().GetCounter(), factionid, flag, npcflag, dyflag); target->setFaction(factionid); target->SetUInt32Value(UNIT_FIELD_FLAGS, flag); @@ -393,7 +393,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; handler->PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, handler->GetNameLink(target).c_str()); @@ -431,7 +431,7 @@ public: if (target->GetTypeId() == TYPEID_PLAYER) { // check online security - if (handler->HasLowerSecurity(target->ToPlayer(), 0)) + if (handler->HasLowerSecurity(target->ToPlayer())) return false; target->ToPlayer()->SetFreeTalentPoints(tp); target->ToPlayer()->SendTalentsInfoData(false); @@ -443,7 +443,7 @@ public: if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet*)target)->IsPermanentPetFor(owner->ToPlayer())) { // check online security - if (handler->HasLowerSecurity(owner->ToPlayer(), 0)) + if (handler->HasLowerSecurity(owner->ToPlayer())) return false; ((Pet*)target)->SetFreeTalentPoints(tp); owner->ToPlayer()->SendTalentsInfoData(true); @@ -482,7 +482,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; std::string targetNameLink = handler->GetNameLink(target); @@ -532,7 +532,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; std::string targetNameLink = handler->GetNameLink(target); @@ -579,7 +579,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; std::string targetNameLink = handler->GetNameLink(target); @@ -626,7 +626,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; std::string targetNameLink = handler->GetNameLink(target); @@ -673,7 +673,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; handler->PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, handler->GetNameLink(target).c_str()); @@ -710,7 +710,7 @@ public: if (Player* player = target->ToPlayer()) { // check online security - if (handler->HasLowerSecurity(player, 0)) + if (handler->HasLowerSecurity(player)) return false; handler->PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, handler->GetNameLink(player).c_str()); @@ -958,7 +958,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; handler->PSendSysMessage(LANG_YOU_GIVE_MOUNT, handler->GetNameLink(target).c_str()); @@ -969,14 +969,14 @@ public: target->Mount(mId); WorldPacket data(SMSG_FORCE_RUN_SPEED_CHANGE, (8 + 4 + 1 + 4)); - data.append(target->GetPackGUID()); + data << target->GetPackGUID(); data << (uint32)0; data << (uint8)0; //new 2.1.0 data << float(speed); target->SendMessageToSet(&data, true); data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, (8 + 4 + 4)); - data.append(target->GetPackGUID()); + data << target->GetPackGUID(); data << (uint32)0; data << float(speed); target->SendMessageToSet(&data, true); @@ -999,7 +999,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; int32 moneyToAdd = 0; @@ -1073,7 +1073,7 @@ public: } // check online security - if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) + if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer())) return false; char* pField = strtok((char*)args, " "); @@ -1127,7 +1127,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; int32 amount = (uint32)atoi(args); @@ -1168,7 +1168,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; char* factionTxt = handler->extractKeyFromLink((char*)args, "Hfaction"); @@ -1264,7 +1264,7 @@ public: target = handler->GetSession()->GetPlayer(); // check online security - else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) + else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer())) return false; target->SetDisplayId(display_id); @@ -1280,7 +1280,7 @@ public: target = handler->GetSession()->GetPlayer(); // check online security - else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) + else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer())) return false; target->DeMorph(); @@ -1300,7 +1300,7 @@ public: target = handler->GetSession()->GetPlayer(); // check online security - else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) + else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer())) return false; target->SetPhaseMask(phasemask, true); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 5c5d17fdf3..1f8feaa95d 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -213,7 +213,7 @@ public: if (Transport* tt = chr->GetTransport()) if (MotionTransport* trans = tt->ToMotionTransport()) { - uint32 guid = sObjectMgr->GenerateRecycledLowGuid(HIGHGUID_UNIT); + ObjectGuid::LowType guid = sObjectMgr->GenerateCreatureSpawnId(); CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid); data.id = id; data.phaseMask = chr->GetPhaseMaskForSpawn(); @@ -231,7 +231,7 @@ public: } Creature* creature = new Creature(); - if (!creature->Create(sObjectMgr->GenerateRecycledLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o)) + if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o)) { delete creature; return false; @@ -239,20 +239,20 @@ public: creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - uint32 db_guid = creature->GetDBTableGUIDLow(); + ObjectGuid::LowType spawnId = creature->GetSpawnId(); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells() // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior creature->CleanupsBeforeDelete(); delete creature; creature = new Creature(); - if (!creature->LoadCreatureFromDB(db_guid, map)) + if (!creature->LoadCreatureFromDB(spawnId, map, true, false, true)) { delete creature; return false; } - sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid)); + sObjectMgr->AddCreatureToGrid(spawnId, sObjectMgr->GetCreatureData(spawnId)); return true; } @@ -322,22 +322,22 @@ public: char* guidStr = strtok((char*)args, " "); char* waitStr = strtok((char*)nullptr, " "); - uint32 lowGuid = atoi((char*)guidStr); + ObjectGuid::LowType spawnId = atoi((char*)guidStr); Creature* creature = nullptr; /* FIXME: impossible without entry if (lowguid) - creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HIGHGUID_UNIT)); + creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HighGuid::Unit)); */ // attempt check creature existence by DB data if (!creature) { - CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid); + CreatureData const* data = sObjectMgr->GetCreatureData(spawnId); if (!data) { - handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowGuid); + handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, spawnId); handler->SetSentErrorMessage(true); return false; } @@ -345,7 +345,7 @@ public: else { // obtain real GUID for DB operations - lowGuid = creature->GetDBTableGUIDLow(); + spawnId = creature->GetSpawnId(); } int wait = waitStr ? atoi(waitStr) : 0; @@ -357,7 +357,7 @@ public: PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE); stmt->setUInt8(0, uint8(WAYPOINT_MOTION_TYPE)); - stmt->setUInt32(1, lowGuid); + stmt->setUInt32(1, spawnId); WorldDatabase.Execute(stmt); @@ -470,12 +470,12 @@ public: if (!cId) return false; - uint32 lowguid = atoi(cId); + ObjectGuid::LowType lowguid = atoi(cId); if (!lowguid) return false; if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid)) - unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT)); + unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(cr_data->id, lowguid)); } else unit = handler->getSelectedCreature(); @@ -729,7 +729,7 @@ public: std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true); std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true); - handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), target->GetGUIDLow(), faction, npcflags, Entry, displayid, nativeid); + handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().GetCounter(), faction, npcflags, Entry, displayid, nativeid); handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, target->GetCurrentEquipmentId(), target->GetOriginalEquipmentId()); handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); @@ -778,7 +778,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); @@ -803,7 +803,7 @@ public: //move selected creature static bool HandleNpcMoveCommand(ChatHandler* handler, const char* args) { - uint32 lowguid = 0; + ObjectGuid::LowType lowguid = 0; Creature* creature = handler->getSelectedCreature(); @@ -818,7 +818,7 @@ public: /* FIXME: impossible without entry if (lowguid) - creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HIGHGUID_UNIT)); + creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HighGuid::Unit)); */ // Attempting creature load from DB data @@ -843,12 +843,12 @@ public: } else { - lowguid = creature->GetDBTableGUIDLow(); + lowguid = creature->GetSpawnId(); } } else { - lowguid = creature->GetDBTableGUIDLow(); + lowguid = creature->GetSpawnId(); } float x = handler->GetSession()->GetPlayer()->GetPositionX(); @@ -858,7 +858,7 @@ public: if (creature) { - if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetDBTableGUIDLow())) + if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetSpawnId())) { const_cast<CreatureData*>(data)->posX = x; const_cast<CreatureData*>(data)->posY = y; @@ -971,7 +971,7 @@ public: if (!guid_str) return false; - uint32 lowguid = 0; + ObjectGuid::LowType lowguid = 0; Creature* creature = nullptr; if (dontdel_str) @@ -1009,16 +1009,15 @@ public: creature = handler->getSelectedCreature(); if (!creature || creature->IsPet()) return false; - lowguid = creature->GetDBTableGUIDLow(); + + lowguid = creature->GetSpawnId(); } else // case .setmovetype #creature_guid $move_type (with selected creature) { lowguid = atoi((char*)guid_str); - /* impossible without entry if (lowguid) - creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HIGHGUID_UNIT)); - */ + creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid); // attempt check creature existence by DB data if (!creature) @@ -1033,7 +1032,7 @@ public: } else { - lowguid = creature->GetDBTableGUIDLow(); + lowguid = creature->GetSpawnId(); } } @@ -1133,10 +1132,10 @@ public: mtype = RANDOM_MOTION_TYPE; Creature* creature = handler->getSelectedCreature(); - uint32 guidLow = 0; + ObjectGuid::LowType guidLow = 0; if (creature) - guidLow = creature->GetDBTableGUIDLow(); + guidLow = creature->GetSpawnId(); else return false; @@ -1182,10 +1181,10 @@ public: } Creature* creature = handler->getSelectedCreature(); - uint32 guidLow = 0; + ObjectGuid::LowType guidLow = 0; if (creature) - guidLow = creature->GetDBTableGUIDLow(); + guidLow = creature->GetSpawnId(); else return false; @@ -1305,11 +1304,11 @@ public: if (!creature || !receiver_str || !text) return false; - uint64 receiver_guid = atol(receiver_str); + ObjectGuid receiver_guid = ObjectGuid::Create<HighGuid::Player>(atol(receiver_str)); // check online security Player* receiver = ObjectAccessor::FindPlayer(receiver_guid); - if (handler->HasLowerSecurity(receiver, 0)) + if (handler->HasLowerSecurity(receiver, ObjectGuid::Empty)) return false; creature->MonsterWhisper(text, receiver); @@ -1430,17 +1429,17 @@ public: if (!*args) return false; - uint32 leaderGUID = (uint32) atoi((char*)args); + ObjectGuid::LowType leaderGUID = (uint32) atoi((char*)args); Creature* creature = handler->getSelectedCreature(); - if (!creature || !creature->GetDBTableGUIDLow()) + if (!creature || !creature->GetSpawnId()) { handler->SendSysMessage(LANG_SELECT_CREATURE); handler->SetSentErrorMessage(true); return false; } - uint32 lowguid = creature->GetDBTableGUIDLow(); + ObjectGuid::LowType lowguid = creature->GetSpawnId(); if (creature->GetFormation()) { handler->PSendSysMessage("Selected creature is already member of group %u", creature->GetFormation()->GetId()); @@ -1482,7 +1481,7 @@ public: if (!*args) return false; - uint32 linkguid = (uint32) atoi((char*)args); + ObjectGuid::LowType linkguid = (uint32) atoi((char*)args); Creature* creature = handler->getSelectedCreature(); @@ -1493,21 +1492,21 @@ public: return false; } - if (!creature->GetDBTableGUIDLow()) + if (!creature->GetSpawnId()) { - handler->PSendSysMessage("Selected creature %u isn't in creature table", creature->GetGUIDLow()); + handler->PSendSysMessage("Selected creature %s isn't in creature table", creature->GetGUID().ToString().c_str()); handler->SetSentErrorMessage(true); return false; } - if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetDBTableGUIDLow(), linkguid)) + if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid)) { handler->PSendSysMessage("Selected creature can't link with guid '%u'", linkguid); handler->SetSentErrorMessage(true); return false; } - handler->PSendSysMessage("LinkGUID '%u' added to creature with DBTableGUID: '%u'", linkguid, creature->GetDBTableGUIDLow()); + handler->PSendSysMessage("LinkGUID '%u' added to creature with SpawnId: '%u'", linkguid, creature->GetSpawnId()); return true; } @@ -1517,7 +1516,7 @@ public: /*if (!*args) return false; - uint64 guid = handler->GetSession()->GetPlayer()->GetSelection(); + ObjectGuid guid = handler->GetSession()->GetPlayer()->GetSelection(); if (guid == 0) { handler->SendSysMessage(LANG_NO_SELECTION); @@ -1601,7 +1600,7 @@ public: } } - uint64 guid; + ObjectGuid guid; guid = handler->GetSession()->GetPlayer()->GetSelection(); if (guid == 0) { @@ -1648,7 +1647,7 @@ public: return false; } } - uint64 guid; + ObjectGuid guid; guid = handler->GetSession()->GetPlayer()->GetSelection(); if (guid == 0) { diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 1287cf5fa7..328c6e2857 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -199,11 +199,11 @@ public: { if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature)) for (uint16 z = 0; z < creatureCount; ++z) - player->KilledMonster(creatureInfo, 0); + player->KilledMonster(creatureInfo, ObjectGuid::Empty); } else if (creature < 0) for (uint16 z = 0; z < creatureCount; ++z) - player->KillCreditGO(creature, 0); + player->KillCreditGO(creature); } // If the quest requires reputation to complete @@ -237,7 +237,7 @@ public: // prepare Quest Tracker datas auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_GM_COMPLETE); stmt->setUInt32(0, quest->GetQuestId()); - stmt->setUInt32(1, player->GetGUIDLow()); + stmt->setUInt32(1, player->GetGUID().GetCounter()); // add to Quest Tracker CharacterDatabase.Execute(stmt); diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp index 3d793b1e18..09309e3c6c 100644 --- a/src/server/scripts/Commands/cs_reset.cpp +++ b/src/server/scripts/Commands/cs_reset.cpp @@ -46,14 +46,14 @@ public: static bool HandleResetAchievementsCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid)) return false; if (target) target->ResetAchievements(); else - AchievementMgr::DeleteFromDB(GUID_LOPART(targetGuid)); + AchievementMgr::DeleteFromDB(targetGuid.GetCounter()); return true; } @@ -145,7 +145,7 @@ public: static bool HandleResetSpellsCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; @@ -162,7 +162,7 @@ public: { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_RESET_SPELLS)); - stmt->setUInt32(1, GUID_LOPART(targetGuid)); + stmt->setUInt32(1, targetGuid.GetCounter()); CharacterDatabase.Execute(stmt); handler->PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, targetName.c_str()); @@ -192,7 +192,7 @@ public: static bool HandleResetTalentsCommand(ChatHandler* handler, char const* args) { Player* target; - uint64 targetGuid; + ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) { @@ -236,7 +236,7 @@ public: { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_NONE | AT_LOGIN_RESET_PET_TALENTS)); - stmt->setUInt32(1, GUID_LOPART(targetGuid)); + stmt->setUInt32(1, targetGuid.GetCounter()); CharacterDatabase.Execute(stmt); std::string nameLink = handler->playerLink(targetName); @@ -285,7 +285,7 @@ public: CharacterDatabase.Execute(stmt); std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock()); - HashMapHolder<Player>::MapType const& plist = sObjectAccessor->GetPlayers(); + HashMapHolder<Player>::MapType const& plist = ObjectAccessor::GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr) itr->second->SetAtLoginFlag(atLogin); diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index d5339421ed..068988f754 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -85,7 +85,7 @@ public: // Triggering corpses expire check in world static bool HandleServerCorpsesCommand(ChatHandler* /*handler*/, char const* /*args*/) { - sObjectAccessor->RemoveOldCorpses(); + sWorld->RemoveOldCorpses(); return true; } diff --git a/src/server/scripts/Commands/cs_spectator.cpp b/src/server/scripts/Commands/cs_spectator.cpp index 8042b6f2e0..8b4dd6795a 100644 --- a/src/server/scripts/Commands/cs_spectator.cpp +++ b/src/server/scripts/Commands/cs_spectator.cpp @@ -239,7 +239,7 @@ bool ArenaSpectator::HandleSpectatorWatchCommand(ChatHandler* handler, char cons return true; } - if (player->GetUInt64Value(PLAYER_FARSIGHT) || player->m_seer != player) // pussywizard: below this point we must not have a viewpoint! + if (player->GetGuidValue(PLAYER_FARSIGHT) || player->m_seer != player) // pussywizard: below this point we must not have a viewpoint! return true; if (player->HaveAtClient(spectate)) diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index 944141a8a0..d47a7cbef6 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -110,7 +110,7 @@ public: return false; Player* target; - uint64 target_guid; + ObjectGuid target_guid; std::string target_name; if (!handler->extractPlayerTarget(nameStr, &target, &target_guid, &target_name)) return false; @@ -122,7 +122,7 @@ public: else { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_HOMEBIND); - stmt->setUInt32(0, target_guid); + stmt->setUInt32(0, target_guid.GetCounter()); PreparedQueryResult resultDB = CharacterDatabase.Query(stmt); if (resultDB) @@ -153,7 +153,7 @@ public: if (target) { // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; std::string chrNameLink = handler->playerLink(target_name); @@ -212,7 +212,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r @@ -250,7 +250,7 @@ public: continue; // check online security - if (handler->HasLowerSecurity(player, 0)) + if (handler->HasLowerSecurity(player)) return false; std::string plNameLink = handler->GetNameLink(player); diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index c808791415..178b8a396a 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -82,8 +82,8 @@ public: } // Get target information - uint64 targetGuid = sObjectMgr->GetPlayerGUIDByName(target.c_str()); - uint64 targetAccountId = sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); + ObjectGuid targetGuid = sObjectMgr->GetPlayerGUIDByName(target.c_str()); + uint32 targetAccountId = sObjectMgr->GetPlayerAccountIdByGUID(targetGuid.GetCounter()); uint32 targetGmLevel = AccountMgr::GetSecurity(targetAccountId, realmID); // Target must exist and have administrative rights @@ -142,7 +142,7 @@ public: return true; } - sTicketMgr->ResolveAndCloseTicket(ticket->GetId(), player ? player->GetGUID() : -1); + sTicketMgr->ResolveAndCloseTicket(ticket->GetId(), player ? player->GetGUID() : ObjectGuid::Empty); sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName().c_str() : "Console", nullptr, nullptr, nullptr); @@ -244,7 +244,7 @@ public: SQLTransaction trans = SQLTransaction(nullptr); ticket->SetCompleted(); - ticket->SetResolvedBy(gm ? gm->GetGUID() : -1); + ticket->SetResolvedBy(gm ? gm->GetGUID() : ObjectGuid::Empty); ticket->SaveToDB(trans); std::string msg = ticket->FormatMessageString(*handler, nullptr, nullptr, nullptr, nullptr); @@ -380,8 +380,8 @@ public: security = assignedPlayer->GetSession()->GetSecurity(); else { - uint64 guid = ticket->GetAssignedToGUID(); - uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid); + ObjectGuid guid = ticket->GetAssignedToGUID(); + uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid.GetCounter()); security = AccountMgr::GetSecurity(accountId, realmID); } @@ -438,7 +438,7 @@ public: return false; // Detect target's GUID - uint64 guid = 0; + ObjectGuid guid; if (Player* player = ObjectAccessor::FindPlayerByName(name, false)) guid = player->GetGUID(); else diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp index 68aa0554b7..7d5b5effcf 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -66,7 +66,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); @@ -111,7 +111,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); @@ -157,7 +157,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); @@ -205,7 +205,7 @@ public: } // check online security - if (handler->HasLowerSecurity(target, 0)) + if (handler->HasLowerSecurity(target)) return false; uint64 titles2 = titles; diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 40450121f1..f641a7a045 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -137,7 +137,7 @@ public: path_number = strtok((char*)args, " "); uint32 pathid = 0; - uint32 guidLow = 0; + ObjectGuid::LowType guidLow = 0; Creature* target = handler->getSelectedCreature(); // Did player provide a path_id? @@ -166,7 +166,7 @@ public: return true; } - guidLow = target->GetDBTableGUIDLow(); + guidLow = target->GetSpawnId(); PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_ADDON_BY_GUID); @@ -231,7 +231,7 @@ public: return true; } - uint32 guildLow = target->GetDBTableGUIDLow(); + uint32 guildLow = target->GetSpawnId(); if (target->GetCreatureAddon()) { @@ -566,7 +566,6 @@ public: // -> variable lowguid is filled with the GUID of the NPC uint32 pathid = 0; uint32 point = 0; - uint32 wpGuid = 0; Creature* target = handler->getSelectedCreature(); if (!target || target->GetEntry() != VISUAL_WAYPOINT) @@ -576,18 +575,18 @@ public: } // The visual waypoint - wpGuid = target->GetGUIDLow(); + ObjectGuid::LowType wpSpawnId = target->GetSpawnId(); // User did select a visual waypoint? // Check the creature PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_WPGUID); - stmt->setUInt32(0, wpGuid); + stmt->setUInt32(0, wpSpawnId); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) { - handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow()); + handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, wpSpawnId); // Select waypoint number from database // Since we compare float values, we have to deal with // some difficulties. @@ -607,7 +606,7 @@ public: if (!result) { - handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid); + handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpSpawnId); return true; } } @@ -634,8 +633,8 @@ public: { handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); - if (wpGuid != 0) - if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT))) + if (wpSpawnId != 0) + if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(target->GetGUID())) { wpCreature->CombatStop(); wpCreature->DeleteFromDB(); @@ -670,9 +669,9 @@ public: // What to do: // Move the visual spawnpoint // Respawn the owner of the waypoints - if (wpGuid != 0) + if (wpSpawnId != 0) { - if (Creature* wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT))) + if (Creature* wpCreature = map->GetCreature(target->GetGUID())) { wpCreature->CombatStop(); wpCreature->DeleteFromDB(); @@ -680,7 +679,7 @@ public: } // re-create Creature* wpCreature2 = new Creature; - if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation())) + if (!wpCreature2->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation())) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); delete wpCreature2; @@ -691,7 +690,7 @@ public: wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); //TODO: Should we first use "Create" then use "LoadFromDB"? - if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetDBTableGUIDLow(), map)) + if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetSpawnId(), map, true, false, true)) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); delete wpCreature2; @@ -795,7 +794,7 @@ public: PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID); - stmt->setUInt32(0, target->GetGUIDLow()); + stmt->setUInt32(0, target->GetSpawnId()); PreparedQueryResult result = WorldDatabase.Query(stmt); @@ -857,7 +856,7 @@ public: { Field* fields = result2->Fetch(); uint32 wpguid = fields[0].GetUInt32(); - Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); + Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, wpguid)); if (!creature) { @@ -901,7 +900,7 @@ public: float o = chr->GetOrientation(); Creature* wpCreature = new Creature; - if (!wpCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o)) + if (!wpCreature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o)) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); delete wpCreature; @@ -911,7 +910,7 @@ public: // Set "wpguid" column to the visual waypoint PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID); - stmt->setInt32(0, int32(wpCreature->GetGUIDLow())); + stmt->setInt32(0, int32(wpCreature->GetSpawnId())); stmt->setUInt32(1, pathid); stmt->setUInt32(2, point); @@ -919,7 +918,7 @@ public: wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - if (!wpCreature->LoadCreatureFromDB(wpCreature->GetDBTableGUIDLow(), map)) + if (!wpCreature->LoadCreatureFromDB(wpCreature->GetSpawnId(), map, true, false, true)) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); delete wpCreature; @@ -964,7 +963,7 @@ public: Map* map = chr->GetMap(); Creature* creature = new Creature; - if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o)) + if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o)) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); delete creature; @@ -972,7 +971,7 @@ public: } creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - if (!creature->LoadCreatureFromDB(creature->GetDBTableGUIDLow(), map)) + if (!creature->LoadCreatureFromDB(creature->GetSpawnId(), map, true, false, true)) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); delete creature; @@ -1013,7 +1012,7 @@ public: Map* map = chr->GetMap(); Creature* creature = new Creature; - if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o)) + if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o)) { handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); delete creature; @@ -1021,7 +1020,7 @@ public: } creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - if (!creature->LoadCreatureFromDB(creature->GetDBTableGUIDLow(), map)) + if (!creature->LoadCreatureFromDB(creature->GetSpawnId(), map, true, false, true)) { handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); delete creature; @@ -1053,8 +1052,8 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); + ObjectGuid::LowType guid = fields[0].GetUInt32(); + Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, guid)); if (!creature) { handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid); diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp index 4182cf1395..ce2a762364 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp @@ -42,14 +42,14 @@ public: npc_water_elementalAI(Creature* creature) : ScriptedAI(creature) { } uint32 waterBoltTimer; - uint64 balindaGUID; + ObjectGuid balindaGUID; uint32 resetTimer; void Reset() override { waterBoltTimer = 3 * IN_MILLISECONDS; resetTimer = 5 * IN_MILLISECONDS; - balindaGUID = 0; + balindaGUID.Clear(); } void UpdateAI(uint32 diff) override diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp index 967ee08de6..8514c733cc 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp @@ -29,7 +29,7 @@ public: else instance->SetData(TYPE_LYCEUM, IN_PROGRESS); // If used brazier open linked doors (North or South) - if (go->GetGUID() == instance->GetData64(DATA_SF_BRAZIER_N)) + if (go->GetGUID() == instance->GetGuidData(DATA_SF_BRAZIER_N)) { if (braziersUsed == 0) { @@ -37,12 +37,12 @@ public: } else if(braziersUsed == 2) { - instance->HandleGameObject(instance->GetData64(DATA_GOLEM_DOOR_N), true); - instance->HandleGameObject(instance->GetData64(DATA_GOLEM_DOOR_S), true); + instance->HandleGameObject(instance->GetGuidData(DATA_GOLEM_DOOR_N), true); + instance->HandleGameObject(instance->GetGuidData(DATA_GOLEM_DOOR_S), true); braziersUsed = 0; } } - else if (go->GetGUID() == instance->GetData64(DATA_SF_BRAZIER_S)) + else if (go->GetGUID() == instance->GetGuidData(DATA_SF_BRAZIER_S)) { if (braziersUsed == 0) { @@ -50,8 +50,8 @@ public: } else if (braziersUsed == 1) { - instance->HandleGameObject(instance->GetData64(DATA_GOLEM_DOOR_N), true); - instance->HandleGameObject(instance->GetData64(DATA_GOLEM_DOOR_S), true); + instance->HandleGameObject(instance->GetGuidData(DATA_GOLEM_DOOR_N), true); + instance->HandleGameObject(instance->GetGuidData(DATA_GOLEM_DOOR_S), true); braziersUsed = 0; } } @@ -214,7 +214,7 @@ public: void HandleGameObject(uint32 id, bool open) { - instance->HandleGameObject(instance->GetData64(id), open); + instance->HandleGameObject(instance->GetGuidData(id), open); } void SummonBoss() @@ -294,11 +294,11 @@ public: if (theldrenEvent) { if (GameObject* go = me->SummonGameObject(GO_ARENA_SPOILS, 596.48f, -187.91f, -54.14f, 4.9f, 0.0f, 0.0f, 0.0f, 0.0f, 300)) - go->SetOwnerGUID(0); + go->SetOwnerGUID(ObjectGuid::Empty); Map::PlayerList const& pl = me->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) - itr->GetSource()->KilledMonsterCredit(16166, 0); + itr->GetSource()->KilledMonsterCredit(16166); } HandleGameObject(DATA_ARENA2, false); @@ -526,7 +526,7 @@ public: void DoGo(uint32 id, uint32 state) { - if (GameObject* go = instance->instance->GetGameObject(instance->GetData64(id))) + if (GameObject* go = instance->instance->GetGameObject(instance->GetGuidData(id))) go->SetGoState((GOState)state); } @@ -574,7 +574,7 @@ public: DoGo(DATA_GO_BAR_KEG_TRAP, 0); //doesn't work very well, leaving code here for future //spell by trap has effect61, this indicate the bar go hostile - if (Unit* tmp = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_PHALANX))) + if (Unit* tmp = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_PHALANX))) tmp->setFaction(14); //for later, this event(s) has alot more to it. diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp index f065648c19..76e5e1549c 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp @@ -62,7 +62,7 @@ public: void JustDied(Unit* /*killer*/) override { - if (Creature* Moira = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_MOIRA))) + if (Creature* Moira = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MOIRA))) { Moira->AI()->EnterEvadeMode(); Moira->setFaction(35); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_magmus.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_magmus.cpp index e800e3190f..e8ec018195 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_magmus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_magmus.cpp @@ -70,7 +70,7 @@ public: void JustDied(Unit* killer) override { if (InstanceScript* instance = killer->GetInstanceScript()) - instance->HandleGameObject(instance->GetData64(DATA_THRONE_DOOR), true); + instance->HandleGameObject(instance->GetGuidData(DATA_THRONE_DOOR), true); } }; }; diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp index 01b386fc09..2d9bd966fa 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp @@ -53,7 +53,7 @@ public: if (InstanceScript* instance = creature->GetInstanceScript()) { //are 5 minutes expected? go template may have data to despawn when used at quest - instance->DoRespawnGameObject(instance->GetData64(DATA_GO_CHALICE), MINUTE * 5); + instance->DoRespawnGameObject(instance->GetGuidData(DATA_GO_CHALICE), MINUTE * 5); } break; } @@ -110,7 +110,7 @@ public: // Start encounter InstanceScript* instance = creature->GetInstanceScript(); if (instance) - instance->SetData64(DATA_EVENSTARTER, player->GetGUID()); + instance->SetGuidData(DATA_EVENSTARTER, player->GetGUID()); break; } return true; @@ -175,7 +175,7 @@ public: if (me->IsAlive()) me->GetMotionMaster()->MoveTargetedHome(); me->SetLootRecipient(nullptr); - instance->SetData64(DATA_EVENSTARTER, 0); + instance->SetGuidData(DATA_EVENSTARTER, ObjectGuid::Empty); } void JustDied(Unit* /*killer*/) override diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp index 4b0d17e7e9..4c8f5e2dbb 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp @@ -71,37 +71,37 @@ public: uint32 encounter[MAX_ENCOUNTER]; std::string str_data; - uint64 EmperorGUID; - uint64 PhalanxGUID; - uint64 MagmusGUID; - uint64 MoiraGUID; - - uint64 GoArena1GUID; - uint64 GoArena2GUID; - uint64 GoArena3GUID; - uint64 GoArena4GUID; - uint64 GoShadowLockGUID; - uint64 GoShadowMechGUID; - uint64 GoShadowGiantGUID; - uint64 GoShadowDummyGUID; - uint64 GoBarKegGUID; - uint64 GoBarKegTrapGUID; - uint64 GoBarDoorGUID; - uint64 GoTombEnterGUID; - uint64 GoTombExitGUID; - uint64 GoLyceumGUID; - uint64 GoSFSGUID; - uint64 GoSFNGUID; - uint64 GoGolemNGUID; - uint64 GoGolemSGUID; - uint64 GoThroneGUID; - uint64 GoChestGUID; - uint64 GoSpectralChaliceGUID; + ObjectGuid EmperorGUID; + ObjectGuid PhalanxGUID; + ObjectGuid MagmusGUID; + ObjectGuid MoiraGUID; + + ObjectGuid GoArena1GUID; + ObjectGuid GoArena2GUID; + ObjectGuid GoArena3GUID; + ObjectGuid GoArena4GUID; + ObjectGuid GoShadowLockGUID; + ObjectGuid GoShadowMechGUID; + ObjectGuid GoShadowGiantGUID; + ObjectGuid GoShadowDummyGUID; + ObjectGuid GoBarKegGUID; + ObjectGuid GoBarKegTrapGUID; + ObjectGuid GoBarDoorGUID; + ObjectGuid GoTombEnterGUID; + ObjectGuid GoTombExitGUID; + ObjectGuid GoLyceumGUID; + ObjectGuid GoSFSGUID; + ObjectGuid GoSFNGUID; + ObjectGuid GoGolemNGUID; + ObjectGuid GoGolemSGUID; + ObjectGuid GoThroneGUID; + ObjectGuid GoChestGUID; + ObjectGuid GoSpectralChaliceGUID; uint32 BarAleCount; uint32 GhostKillCount; - uint64 TombBossGUIDs[7]; - uint64 TombEventStarterGUID; + ObjectGuid TombBossGUIDs[7]; + ObjectGuid TombEventStarterGUID; uint32 TombTimer; uint32 TombEventCounter; uint32 OpenedCoofers; @@ -110,42 +110,11 @@ public: { memset(&encounter, 0, sizeof(encounter)); - EmperorGUID = 0; - PhalanxGUID = 0; - MagmusGUID = 0; - MoiraGUID = 0; - - GoArena1GUID = 0; - GoArena2GUID = 0; - GoArena3GUID = 0; - GoArena4GUID = 0; - GoShadowLockGUID = 0; - GoShadowMechGUID = 0; - GoShadowGiantGUID = 0; - GoShadowDummyGUID = 0; - GoBarKegGUID = 0; - GoBarKegTrapGUID = 0; - GoBarDoorGUID = 0; - GoTombEnterGUID = 0; - GoTombExitGUID = 0; - GoLyceumGUID = 0; - GoSFSGUID = 0; - GoSFNGUID = 0; - GoGolemNGUID = 0; - GoGolemSGUID = 0; - GoThroneGUID = 0; - GoChestGUID = 0; - GoSpectralChaliceGUID = 0; - BarAleCount = 0; GhostKillCount = 0; - TombEventStarterGUID = 0; TombTimer = TIMER_TOMBOFTHESEVEN; TombEventCounter = 0; OpenedCoofers = 0; - - for (uint8 i = 0; i < 7; ++i) - TombBossGUIDs[i] = 0; } void OnCreatureCreate(Creature* creature) override @@ -185,7 +154,7 @@ public: case NPC_MAGMUS: MagmusGUID = creature->GetGUID(); if (!creature->IsAlive()) - HandleGameObject(GetData64(DATA_THRONE_DOOR), true); // if Magmus is dead open door to last boss + HandleGameObject(GetGuidData(DATA_THRONE_DOOR), true); // if Magmus is dead open door to last boss break; } } @@ -233,9 +202,9 @@ public: case GO_TOMB_EXIT: GoTombExitGUID = go->GetGUID(); if (GhostKillCount >= 7) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); else - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_LYCEUM: GoLyceumGUID = go->GetGUID(); @@ -264,12 +233,8 @@ public: } } - void SetData64(uint32 type, uint64 data) override + void SetGuidData(uint32 type, ObjectGuid data) override { -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - LOG_DEBUG("scripts.ai", "TSCR: Instance Blackrock Depths: SetData64 update (Type: %u Data " UI64FMTD ")", type, data); -#endif - switch (type) { case DATA_EVENSTARTER: @@ -365,7 +330,7 @@ public: return 0; } - uint64 GetData64(uint32 data) const override + ObjectGuid GetGuidData(uint32 data) const override { switch (data) { @@ -404,7 +369,8 @@ public: case DATA_GO_CHALICE: return GoSpectralChaliceGUID; } - return 0; + + return ObjectGuid::Empty; } std::string GetSaveData() override @@ -474,7 +440,6 @@ public: } } GhostKillCount = 0; - TombEventStarterGUID = 0; TombEventCounter = 0; TombTimer = TIMER_TOMBOFTHESEVEN; SetData(TYPE_TOMB_OF_SEVEN, NOT_STARTED); @@ -492,7 +457,7 @@ public: DoRespawnGameObject(GoChestGUID, DAY); HandleGameObject(GoTombExitGUID, true);//event done, open exit door HandleGameObject(GoTombEnterGUID, true);//event done, open entrance door - TombEventStarterGUID = 0; + TombEventStarterGUID.Clear(); SetData(TYPE_TOMB_OF_SEVEN, DONE); } void Update(uint32 diff) override diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_drakkisath.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_drakkisath.cpp index e0d6e17230..5ecb961a0d 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_drakkisath.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_drakkisath.cpp @@ -72,8 +72,7 @@ public: me->GetCreaturesWithEntryInRange(ChromaticEliteGuards, 15.0f, ChromaticEliteGuardEntry); for (std::list<Creature*>::const_iterator itr = ChromaticEliteGuards.begin(); itr != ChromaticEliteGuards.end(); ++itr) { - if ((*itr)->GetGUID()) - (*itr)->ToCreature()->AI()->AttackStart(me->GetVictim()); + (*itr)->ToCreature()->AI()->AttackStart(me->GetVictim()); } } @@ -145,16 +144,14 @@ public: me->GetCreaturesWithEntryInRange(GeneralDrakkisath, 15.0f, GeneralDrakkisathEntry); for (std::list<Creature*>::const_iterator itr = GeneralDrakkisath.begin(); itr != GeneralDrakkisath.end(); ++itr) { - if ((*itr)->GetGUID()) - (*itr)->ToCreature()->AI()->AttackStart(who); + (*itr)->ToCreature()->AI()->AttackStart(who); } std::list<Creature*> ChromaticEliteGuards; me->GetCreaturesWithEntryInRange(ChromaticEliteGuards, 15.0f, ChromaticEliteGuardEntry); for (std::list<Creature*>::const_iterator itr = ChromaticEliteGuards.begin(); itr != ChromaticEliteGuards.end(); ++itr) { - if ((*itr)->GetGUID()) - (*itr)->ToCreature()->AI()->AttackStart(who); + (*itr)->ToCreature()->AI()->AttackStart(who); } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp index 97326d49b9..0c3834cb0b 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp @@ -93,10 +93,10 @@ public: break; case 2: // Close these two doors on Blackhand Incarcerators aggro - if (GameObject* door1 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_IN))) + if (GameObject* door1 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_EMBERSEER_IN))) if (door1->GetGoState() == GO_STATE_ACTIVE) door1->SetGoState(GO_STATE_READY); - if (GameObject* door2 = me->GetMap()->GetGameObject(instance->GetData64(GO_DOORS))) + if (GameObject* door2 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_DOORS))) if (door2->GetGoState() == GO_STATE_ACTIVE) door2->SetGoState(GO_STATE_READY); break; @@ -155,33 +155,33 @@ public: void OpenDoors(bool Boss_Killed) { // These two doors reopen on reset or boss kill - if (GameObject* door1 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_IN))) + if (GameObject* door1 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_EMBERSEER_IN))) door1->SetGoState(GO_STATE_ACTIVE); - if (GameObject* door2 = me->GetMap()->GetGameObject(instance->GetData64(GO_DOORS))) + if (GameObject* door2 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_DOORS))) door2->SetGoState(GO_STATE_ACTIVE); // This door opens on boss kill if (Boss_Killed) - if (GameObject* door3 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_OUT))) + if (GameObject* door3 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_EMBERSEER_OUT))) door3->SetGoState(GO_STATE_ACTIVE); } void UpdateRunes(GOState state) { // update all runes - if (GameObject* rune1 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_1))) + if (GameObject* rune1 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_EMBERSEER_RUNE_1))) rune1->SetGoState(state); - if (GameObject* rune2 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_2))) + if (GameObject* rune2 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_EMBERSEER_RUNE_2))) rune2->SetGoState(state); - if (GameObject* rune3 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_3))) + if (GameObject* rune3 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_EMBERSEER_RUNE_3))) rune3->SetGoState(state); - if (GameObject* rune4 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_4))) + if (GameObject* rune4 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_EMBERSEER_RUNE_4))) rune4->SetGoState(state); - if (GameObject* rune5 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_5))) + if (GameObject* rune5 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_EMBERSEER_RUNE_5))) rune5->SetGoState(state); - if (GameObject* rune6 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_6))) + if (GameObject* rune6 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_EMBERSEER_RUNE_6))) rune6->SetGoState(state); - if (GameObject* rune7 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_7))) + if (GameObject* rune7 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_EMBERSEER_RUNE_7))) rune7->SetGoState(state); } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_rend_blackhand.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_rend_blackhand.cpp index a9aa224052..1b2a99712e 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_rend_blackhand.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_rend_blackhand.cpp @@ -171,15 +171,15 @@ public: me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_PREPARATION); gythEvent = false; - victorGUID = 0; - waveDoorGUID = 0; + victorGUID.Clear(); + waveDoorGUID.Clear(); summons.DespawnAll(); if (Creature* victor = me->FindNearestCreature(NPC_LORD_VICTOR_NEFARIUS, 5.0f, true)) victor->Respawn(true); - if (GameObject* exitDoor = me->GetMap()->GetGameObject(instance->GetData64(GO_GYTH_ENTRY_DOOR))) + if (GameObject* exitDoor = me->GetMap()->GetGameObject(instance->GetGuidData(GO_GYTH_ENTRY_DOOR))) exitDoor->SetGoState(GO_STATE_ACTIVE); instance->SetBossState(DATA_WARCHIEF_REND_BLACKHAND, NOT_STARTED); @@ -225,7 +225,7 @@ public: if (Creature* victor = me->FindNearestCreature(NPC_LORD_VICTOR_NEFARIUS, 75.0f, true)) victor->AI()->SetData(1, 2); - if (GameObject* exitDoor = me->GetMap()->GetGameObject(instance->GetData64(GO_GYTH_ENTRY_DOOR))) + if (GameObject* exitDoor = me->GetMap()->GetGameObject(instance->GetGuidData(GO_GYTH_ENTRY_DOOR))) exitDoor->SetGoState(GO_STATE_ACTIVE); instance->SetBossState(DATA_WARCHIEF_REND_BLACKHAND, DONE); @@ -287,7 +287,7 @@ public: if (Creature* victor = ObjectAccessor::GetCreature(*me, victorGUID)) victor->AI()->Talk(SAY_NEFARIUS_0); - if (GameObject* door2 = me->GetMap()->GetGameObject(instance->GetData64(GO_GYTH_ENTRY_DOOR))) + if (GameObject* door2 = me->GetMap()->GetGameObject(instance->GetGuidData(GO_GYTH_ENTRY_DOOR))) door2->SetGoState(GO_STATE_READY); events.ScheduleEvent(EVENT_START_2, 4000); @@ -465,8 +465,8 @@ public: private: bool gythEvent; - uint64 victorGUID; - uint64 waveDoorGUID; + ObjectGuid victorGUID; + ObjectGuid waveDoorGUID; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/instance_blackrock_spire.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/instance_blackrock_spire.cpp index bd674b55af..f264224c62 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/instance_blackrock_spire.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/instance_blackrock_spire.cpp @@ -41,30 +41,6 @@ public: instance_blackrock_spireMapScript(InstanceMap* map) : InstanceScript(map) { SetBossNumber(EncounterCount); - HighlordOmokk = 0; - ShadowHunterVoshgajin = 0; - WarMasterVoone = 0; - MotherSmolderweb = 0; - UrokDoomhowl = 0; - QuartermasterZigris = 0; - GizrultheSlavener = 0; - Halycon = 0; - OverlordWyrmthalak = 0; - PyroguardEmberseer = 0; - WarchiefRendBlackhand = 0; - Gyth = 0; - LordVictorNefarius = 0; - TheBeast = 0; - GeneralDrakkisath = 0; - go_emberseerin = 0; - go_doors = 0; - go_emberseerout = 0; - go_blackrockaltar = 0; - go_portcullis_active = 0; - go_portcullis_tobossrooms = 0; - go_urok_pile = 0; - memset(go_roomrunes, 0, sizeof(go_roomrunes)); - memset(go_emberseerrunes, 0, sizeof(go_emberseerrunes)); } void CreatureLooted(Creature* creature, LootType loot) override @@ -147,97 +123,97 @@ public: break; case GO_EMBERSEER_IN: go_emberseerin = go->GetGUID(); - HandleGameObject(0, GetBossState(DATA_DRAGONSPIRE_ROOM) == DONE, go); + HandleGameObject(ObjectGuid::Empty, GetBossState(DATA_DRAGONSPIRE_ROOM) == DONE, go); break; case GO_DOORS: go_doors = go->GetGUID(); if (GetBossState(DATA_DRAGONSPIRE_ROOM) == DONE) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_EMBERSEER_OUT: go_emberseerout = go->GetGUID(); if (GetBossState(DATA_PYROGAURD_EMBERSEER) == DONE) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_HALL_RUNE_1: go_roomrunes[0] = go->GetGUID(); if (GetBossState(DATA_HALL_RUNE_1) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_HALL_RUNE_2: go_roomrunes[1] = go->GetGUID(); if (GetBossState(DATA_HALL_RUNE_2) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_HALL_RUNE_3: go_roomrunes[2] = go->GetGUID(); if (GetBossState(DATA_HALL_RUNE_3) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_HALL_RUNE_4: go_roomrunes[3] = go->GetGUID(); if (GetBossState(DATA_HALL_RUNE_4) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_HALL_RUNE_5: go_roomrunes[4] = go->GetGUID(); if (GetBossState(DATA_HALL_RUNE_5) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_HALL_RUNE_6: go_roomrunes[5] = go->GetGUID(); if (GetBossState(DATA_HALL_RUNE_6) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_HALL_RUNE_7: go_roomrunes[6] = go->GetGUID(); if (GetBossState(DATA_HALL_RUNE_7) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_EMBERSEER_RUNE_1: go_emberseerrunes[0] = go->GetGUID(); if (GetBossState(DATA_PYROGAURD_EMBERSEER) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_EMBERSEER_RUNE_2: go_emberseerrunes[1] = go->GetGUID(); if (GetBossState(DATA_PYROGAURD_EMBERSEER) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_EMBERSEER_RUNE_3: go_emberseerrunes[2] = go->GetGUID(); if (GetBossState(DATA_PYROGAURD_EMBERSEER) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_EMBERSEER_RUNE_4: go_emberseerrunes[3] = go->GetGUID(); if (GetBossState(DATA_PYROGAURD_EMBERSEER) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_EMBERSEER_RUNE_5: go_emberseerrunes[4] = go->GetGUID(); if (GetBossState(DATA_PYROGAURD_EMBERSEER) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_EMBERSEER_RUNE_6: go_emberseerrunes[5] = go->GetGUID(); if (GetBossState(DATA_PYROGAURD_EMBERSEER) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_EMBERSEER_RUNE_7: go_emberseerrunes[6] = go->GetGUID(); if (GetBossState(DATA_PYROGAURD_EMBERSEER) == DONE) - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_PORTCULLIS_ACTIVE: go_portcullis_active = go->GetGUID(); if (GetBossState(DATA_GYTH) == DONE) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_PORTCULLIS_TOBOSSROOMS: go_portcullis_tobossrooms = go->GetGUID(); if (GetBossState(DATA_GYTH) == DONE) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_UROK_PILE: go_urok_pile = go->GetGUID(); @@ -315,7 +291,7 @@ public: } } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -388,7 +364,8 @@ public: default: break; } - return 0; + + return ObjectGuid::Empty; } void Update(uint32 diff) override @@ -465,7 +442,7 @@ public: if (!_mobAlive && rune->GetGoState() == GO_STATE_ACTIVE) { - HandleGameObject(0, false, rune); + HandleGameObject(ObjectGuid::Empty, false, rune); switch (rune->GetEntry()) { @@ -502,11 +479,11 @@ public: { SetBossState(DATA_DRAGONSPIRE_ROOM, DONE); if (GameObject* door1 = instance->GetGameObject(go_emberseerin)) - HandleGameObject(0, true, door1); + HandleGameObject(ObjectGuid::Empty, true, door1); if (GameObject* door2 = instance->GetGameObject(go_doors)) - HandleGameObject(0, true, door2); + HandleGameObject(ObjectGuid::Empty, true, door2); if (GameObject* door3 = instance->GetGameObject(go_emberseerin)) - HandleGameObject(0, true, door3); + HandleGameObject(ObjectGuid::Empty, true, door3); } } @@ -556,31 +533,31 @@ public: protected: EventMap Events; - uint64 HighlordOmokk; - uint64 ShadowHunterVoshgajin; - uint64 WarMasterVoone; - uint64 MotherSmolderweb; - uint64 UrokDoomhowl; - uint64 QuartermasterZigris; - uint64 GizrultheSlavener; - uint64 Halycon; - uint64 OverlordWyrmthalak; - uint64 PyroguardEmberseer; - uint64 WarchiefRendBlackhand; - uint64 Gyth; - uint64 LordVictorNefarius; - uint64 TheBeast; - uint64 GeneralDrakkisath; - uint64 go_emberseerin; - uint64 go_doors; - uint64 go_emberseerout; - uint64 go_blackrockaltar; - uint64 go_roomrunes[7]; - uint64 go_emberseerrunes[7]; - uint64 runecreaturelist[7][5]; - uint64 go_portcullis_active; - uint64 go_portcullis_tobossrooms; - uint64 go_urok_pile; + ObjectGuid HighlordOmokk; + ObjectGuid ShadowHunterVoshgajin; + ObjectGuid WarMasterVoone; + ObjectGuid MotherSmolderweb; + ObjectGuid UrokDoomhowl; + ObjectGuid QuartermasterZigris; + ObjectGuid GizrultheSlavener; + ObjectGuid Halycon; + ObjectGuid OverlordWyrmthalak; + ObjectGuid PyroguardEmberseer; + ObjectGuid WarchiefRendBlackhand; + ObjectGuid Gyth; + ObjectGuid LordVictorNefarius; + ObjectGuid TheBeast; + ObjectGuid GeneralDrakkisath; + ObjectGuid go_emberseerin; + ObjectGuid go_doors; + ObjectGuid go_emberseerout; + ObjectGuid go_blackrockaltar; + ObjectGuid go_roomrunes[7]; + ObjectGuid go_emberseerrunes[7]; + ObjectGuid runecreaturelist[7][5]; + ObjectGuid go_portcullis_active; + ObjectGuid go_portcullis_tobossrooms; + ObjectGuid go_urok_pile; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_chromaggus.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_chromaggus.cpp index a556794e49..1dbfc73b26 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_chromaggus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_chromaggus.cpp @@ -300,11 +300,11 @@ class go_chromaggus_lever : public GameObjectScript { _instance->SetBossState(DATA_CHROMAGGUS, IN_PROGRESS); - if (Creature* creature = _instance->instance->GetCreature(DATA_CHROMAGGUS)) + if (Creature* creature = _instance->instance->GetCreature(_instance->GetGuidData(DATA_CHROMAGGUS))) creature->AI()->AttackStart(player); - if (GameObject* go = _instance->instance->GetGameObject(DATA_GO_CHROMAGGUS_DOOR)) - _instance->HandleGameObject(0, true, go); + if (GameObject* go = _instance->instance->GetGameObject(_instance->GetGuidData(DATA_GO_CHROMAGGUS_DOOR))) + _instance->HandleGameObject(ObjectGuid::Empty, true, go); } go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE | GO_FLAG_IN_USE); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp index 09b4dff0c3..69e9bae492 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp @@ -158,7 +158,7 @@ public: { if (InstanceScript* instance = go->GetInstanceScript()) if (instance->GetData(DATA_EGG_EVENT) != DONE) - if (Creature* razor = ObjectAccessor::GetCreature(*go, instance->GetData64(DATA_RAZORGORE_THE_UNTAMED))) + if (Creature* razor = ObjectAccessor::GetCreature(*go, instance->GetGuidData(DATA_RAZORGORE_THE_UNTAMED))) { razor->Attack(player, true); player->CastSpell(razor, SPELL_MINDCONTROL); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp index 9d6343c965..6745b6ade6 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp @@ -74,7 +74,7 @@ public: void Initialize() { - PlayerGUID = 0; + PlayerGUID.Clear(); HasYelled = false; me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); @@ -260,8 +260,8 @@ public: } private: - uint64 PlayerGUID; - uint64 m_nefariusGuid; + ObjectGuid PlayerGUID; + ObjectGuid m_nefariusGuid; bool HasYelled; }; diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/instance_blackwing_lair.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/instance_blackwing_lair.cpp index ea6c10e173..07059847bb 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/instance_blackwing_lair.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/instance_blackwing_lair.cpp @@ -75,7 +75,7 @@ public: case NPC_BLACKWING_TASKMASTER: case NPC_BLACKWING_LEGIONAIRE: case NPC_BLACKWING_WARLOCK: - if (Creature* razor = instance->GetCreature(DATA_RAZORGORE_THE_UNTAMED)) + if (Creature* razor = instance->GetCreature(GetGuidData(DATA_RAZORGORE_THE_UNTAMED))) if (CreatureAI* razorAI = razor->AI()) razorAI->JustSummoned(creature); break; @@ -169,8 +169,8 @@ public: case DATA_RAZORGORE_THE_UNTAMED: if (state == DONE) { - for (std::list<uint64>::const_iterator itr = EggList.begin(); itr != EggList.end(); ++itr) - if (GameObject* egg = instance->GetGameObject((*itr))) + for (ObjectGuid const guid : EggList) + if (GameObject* egg = instance->GetGameObject(guid)) egg->SetPhaseMask(2, true); } SetData(DATA_EGG_EVENT, NOT_STARTED); @@ -179,7 +179,7 @@ public: switch (state) { case NOT_STARTED: - if (Creature* nefarian = instance->GetCreature(DATA_NEFARIAN)) + if (Creature* nefarian = instance->GetCreature(GetGuidData(DATA_NEFARIAN))) nefarian->DespawnOrUnsummon(); break; case FAIL: @@ -213,7 +213,7 @@ public: case SPECIAL: if (++EggCount == 15) { - if (Creature* razor = instance->GetCreature(DATA_RAZORGORE_THE_UNTAMED)) + if (Creature* razor = instance->GetCreature(GetGuidData(DATA_RAZORGORE_THE_UNTAMED))) { SetData(DATA_EGG_EVENT, DONE); razor->RemoveAurasDueToSpell(42013); // MindControl @@ -255,11 +255,11 @@ public: break; case EVENT_RAZOR_PHASE_TWO: _events.CancelEvent(EVENT_RAZOR_SPAWN); - if (Creature* razor = instance->GetCreature(DATA_RAZORGORE_THE_UNTAMED)) + if (Creature* razor = instance->GetCreature(GetGuidData(DATA_RAZORGORE_THE_UNTAMED))) razor->AI()->DoAction(ACTION_PHASE_TWO); break; case EVENT_RESPAWN_NEFARIUS: - if (Creature* nefarius = instance->GetCreature(DATA_LORD_VICTOR_NEFARIUS)) + if (Creature* nefarius = instance->GetCreature(GetGuidData(DATA_LORD_VICTOR_NEFARIUS))) { nefarius->SetPhaseMask(1, true); nefarius->setActive(true); @@ -278,7 +278,7 @@ public: // Razorgore uint8 EggCount; uint32 EggEvent; - std::list<uint64> EggList; + GuidList EggList; }; InstanceScript* GetInstanceScript(InstanceMap* map) const diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_golemagg.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_golemagg.cpp index a1e79bbc24..811ac81e1e 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_golemagg.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_golemagg.cpp @@ -143,7 +143,7 @@ public: if (HealthAbovePct(50) || !instance) return; - if (Creature* pGolemagg = instance->instance->GetCreature(instance->GetData64(BOSS_GOLEMAGG_THE_INCINERATOR))) + if (Creature* pGolemagg = instance->instance->GetCreature(instance->GetGuidData(BOSS_GOLEMAGG_THE_INCINERATOR))) { if (pGolemagg->IsAlive()) { diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp index 73e1c25ea2..13f061ff37 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp @@ -147,7 +147,7 @@ public: break; case EVENT_INTRO_4: Talk(SAY_ARRIVAL5_RAG); - if (Creature* executus = ObjectAccessor::GetCreature(*me, instance->GetData64(BOSS_MAJORDOMO_EXECUTUS))) + if (Creature* executus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(BOSS_MAJORDOMO_EXECUTUS))) Unit::Kill(me, executus); break; case EVENT_INTRO_5: diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/instance_molten_core.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/instance_molten_core.cpp index 113edbf317..573af4972a 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/instance_molten_core.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/instance_molten_core.cpp @@ -42,9 +42,6 @@ public: instance_molten_core_InstanceMapScript(Map* map) : InstanceScript(map) { SetBossNumber(MAX_ENCOUNTER); - _golemaggTheIncineratorGUID = 0; - _majordomoExecutusGUID = 0; - _cacheOfTheFirelordGUID = 0; _deadBossCount = 0; _ragnarosAddDeaths = 0; } @@ -125,7 +122,7 @@ public: return 0; } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -135,7 +132,7 @@ public: return _majordomoExecutusGUID; } - return 0; + return ObjectGuid::Empty; } bool SetBossState(uint32 bossId, EncounterState state) override @@ -236,12 +233,12 @@ public: } private: - uint64 _golemaggTheIncineratorGUID; - uint64 _majordomoExecutusGUID; - uint64 _cacheOfTheFirelordGUID; + ObjectGuid _golemaggTheIncineratorGUID; + ObjectGuid _majordomoExecutusGUID; + ObjectGuid _cacheOfTheFirelordGUID; uint8 _deadBossCount; uint8 _ragnarosAddDeaths; - std::unordered_map<uint8, uint64> _circlesGUIDs; + std::unordered_map<uint8, ObjectGuid> _circlesGUIDs; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp index 881d61c6c9..5fb5046ee7 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp @@ -139,7 +139,7 @@ public: if (type != POINT_MOTION_TYPE) return; - me->SetTarget(0); + me->SetTarget(); me->SetFacingTo(5.558f); me->SetStandState(UNIT_STAND_STATE_KNEEL); events.ScheduleEvent(point == EQUIP_TWO_SWORDS ? EVENT_SWAP_WEAPON1 : EVENT_SWAP_WEAPON2, 1500); diff --git a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp index 0a1a46143f..819977a13f 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp @@ -32,7 +32,7 @@ public: break; case GO_IRON_CLAD_DOOR: if (_encounters[TYPE_CANNON] == DONE) - HandleGameObject(0, true, gameobject); + HandleGameObject(ObjectGuid::Empty, true, gameobject); break; } } diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/instance_gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/instance_gnomeregan.cpp index 6fad05fefe..843b4eb475 100644 --- a/src/server/scripts/EasternKingdoms/Gnomeregan/instance_gnomeregan.cpp +++ b/src/server/scripts/EasternKingdoms/Gnomeregan/instance_gnomeregan.cpp @@ -57,14 +57,13 @@ public: { npc_kernobeeAI(Creature* creature) : PassiveAI(creature) { - playerGUID = 0; checkTimer = 0; } uint32 checkTimer; - uint64 playerGUID; + ObjectGuid playerGUID; - void SetGUID(uint64 guid, int32) override + void SetGUID(ObjectGuid guid, int32) override { playerGUID = guid; } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index defb5872d5..f221454595 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -67,13 +67,6 @@ public: boss_netherspiteAI(Creature* creature) : ScriptedAI(creature) { instance = creature->GetInstanceScript(); - - for (int i = 0; i < 3; ++i) - { - PortalGUID[i] = 0; - BeamTarget[i] = 0; - BeamerGUID[i] = 0; - } } InstanceScript* instance; @@ -86,9 +79,9 @@ public: uint32 NetherbreathTimer; uint32 EmpowermentTimer; uint32 PortalTimer; // timer for beam checking - uint64 PortalGUID[3]; // guid's of portals - uint64 BeamerGUID[3]; // guid's of auxiliary beaming portals - uint64 BeamTarget[3]; // guid's of portals' current targets + ObjectGuid PortalGUID[3]; // guid's of portals + ObjectGuid BeamerGUID[3]; // guid's of auxiliary beaming portals + ObjectGuid BeamTarget[3]; // guid's of portals' current targets bool IsBetween(WorldObject* u1, WorldObject* target, WorldObject* u2) // the in-line checker { @@ -150,8 +143,8 @@ public: portal->DisappearAndDie(); if (Creature* portal = ObjectAccessor::GetCreature(*me, BeamerGUID[i])) portal->DisappearAndDie(); - PortalGUID[i] = 0; - BeamTarget[i] = 0; + PortalGUID[i].Clear(); + BeamTarget[i].Clear(); } } @@ -175,9 +168,9 @@ public: Player* p = i->GetSource(); if (p && p->IsAlive() // alive && (!target || target->GetDistance2d(portal) > p->GetDistance2d(portal)) // closer than current best - && !p->HasAura(PlayerDebuff[j], 0) // not exhausted - && !p->HasAura(PlayerBuff[(j + 1) % 3], 0) // not on another beam - && !p->HasAura(PlayerBuff[(j + 2) % 3], 0) + && !p->HasAura(PlayerDebuff[j]) // not exhausted + && !p->HasAura(PlayerBuff[(j + 1) % 3]) // not on another beam + && !p->HasAura(PlayerBuff[(j + 2) % 3]) && IsBetween(me, p, portal)) // on the beam target = p; } @@ -197,7 +190,7 @@ public: { beamer->CastSpell(target, PortalBeam[j], false); beamer->DisappearAndDie(); - BeamerGUID[j] = 0; + BeamerGUID[j].Clear(); } // create new one and start beaming on the target if (Creature* beamer = portal->SummonCreature(PortalID[j], portal->GetPositionX(), portal->GetPositionY(), portal->GetPositionZ(), portal->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 60000)) @@ -241,7 +234,7 @@ public: void HandleDoors(bool open) // Massive Door switcher { - if (GameObject* Door = ObjectAccessor::GetGameObject(*me, instance->GetData64(DATA_GO_MASSIVE_DOOR) )) + if (GameObject* Door = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(DATA_GO_MASSIVE_DOOR) )) Door->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY); } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp index 1297d9491b..983d1869b1 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp @@ -120,10 +120,10 @@ public: if (instance) { - if (instance->GetData64(DATA_NIGHTBANE) == DONE) + if (instance->GetData(DATA_NIGHTBANE) == DONE) me->DisappearAndDie(); else - instance->SetData64(DATA_NIGHTBANE, NOT_STARTED); + instance->SetData(DATA_NIGHTBANE, NOT_STARTED); } HandleTerraceDoors(true); @@ -142,15 +142,15 @@ public: { if (instance) { - instance->HandleGameObject(instance->GetData64(DATA_MASTERS_TERRACE_DOOR_1), open); - instance->HandleGameObject(instance->GetData64(DATA_MASTERS_TERRACE_DOOR_2), open); + instance->HandleGameObject(instance->GetGuidData(DATA_MASTERS_TERRACE_DOOR_1), open); + instance->HandleGameObject(instance->GetGuidData(DATA_MASTERS_TERRACE_DOOR_2), open); } } void EnterCombat(Unit* /*who*/) override { if (instance) - instance->SetData64(DATA_NIGHTBANE, IN_PROGRESS); + instance->SetData(DATA_NIGHTBANE, IN_PROGRESS); HandleTerraceDoors(false); Talk(YELL_AGGRO); @@ -428,7 +428,7 @@ public: if (InstanceScript* pInstance = go->GetInstanceScript()) { if (pInstance->GetData(DATA_NIGHTBANE) != DONE && !go->FindNearestCreature(NPC_NIGHTBANE, 40.0f)) - if (Creature* cr = ObjectAccessor::GetCreature(*player, pInstance->GetData64(DATA_NIGHTBANE))) + if (Creature* cr = ObjectAccessor::GetCreature(*player, pInstance->GetGuidData(DATA_NIGHTBANE))) cr->GetMotionMaster()->MovePoint(0, IntroWay[0][0], IntroWay[0][1], IntroWay[0][2]); } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index b8f44aa562..36fefed084 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -87,11 +87,11 @@ public: struct netherspite_infernalAI : public ScriptedAI { netherspite_infernalAI(Creature* creature) : ScriptedAI(creature), - HellfireTimer(0), CleanupTimer(0), malchezaar(0), point(nullptr) { } + HellfireTimer(0), CleanupTimer(0), point(nullptr) { } uint32 HellfireTimer; uint32 CleanupTimer; - uint64 malchezaar; + ObjectGuid malchezaar; InfernalPoint* point; void Reset() override { } @@ -176,9 +176,9 @@ public: uint32 InfernalCleanupTimer; uint32 phase; uint32 enfeeble_health[5]; - uint64 enfeeble_targets[5]; + ObjectGuid enfeeble_targets[5]; - std::vector<uint64> infernals; + GuidVector infernals; std::vector<InfernalPoint*> positions; void Initialize() @@ -194,7 +194,7 @@ public: phase = 1; clearweapons(); positions.clear(); - instance->HandleGameObject(instance->GetData64(DATA_GO_NETHER_DOOR), true); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_NETHER_DOOR), true); } void clearweapons() @@ -216,7 +216,7 @@ public: void JustDied(Unit* /*killer*/) override { Talk(SAY_DEATH); - instance->HandleGameObject(instance->GetData64(DATA_GO_NETHER_DOOR), true); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_NETHER_DOOR), true); if (Creature* Axe = me->FindNearestCreature(MALCHEZARS_AXE, 100.0f)) { Axe->DespawnOrUnsummon(); @@ -227,7 +227,7 @@ public: { Talk(SAY_AGGRO); DoZoneInCombat(); - instance->HandleGameObject(instance->GetData64(DATA_GO_NETHER_DOOR), false); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_NETHER_DOOR), false); } void SummonAxes() @@ -278,7 +278,7 @@ public: Unit* target = ObjectAccessor::GetUnit(*me, enfeeble_targets[i]); if (target && target->IsAlive()) target->SetHealth(enfeeble_health[i]); - enfeeble_targets[i] = 0; + enfeeble_targets[i].Clear(); enfeeble_health[i] = 0; } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index 9280b0022a..cf070a4482 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -78,7 +78,7 @@ public: uint32 FlameWreathTimer; uint32 FlameWreathCheckTime; - uint64 FlameWreathTarget[3]; + ObjectGuid FlameWreathTarget[3]; float FWTargPosX[3]; float FWTargPosY[3]; @@ -105,6 +105,9 @@ public: FlameWreathTimer = 0; FlameWreathCheckTime = 0; + for (uint8 i = 0; i < 3; ++i) + FlameWreathTarget[i].Clear(); + CurrentNormalSpell = 0; ArcaneCooldown = 0; FireCooldown = 0; @@ -118,7 +121,7 @@ public: // Not in progress instance->SetData(DATA_ARAN, NOT_STARTED); - instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), true); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_LIBRARY_DOOR), true); } void KilledUnit(Unit* /*victim*/) override @@ -131,7 +134,7 @@ public: Talk(SAY_DEATH); instance->SetData(DATA_ARAN, DONE); - instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), true); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_LIBRARY_DOOR), true); } void EnterCombat(Unit* /*who*/) override @@ -139,7 +142,7 @@ public: Talk(SAY_AGGRO); instance->SetData(DATA_ARAN, IN_PROGRESS); - instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), false); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_LIBRARY_DOOR), false); DoZoneInCombat(); } @@ -187,7 +190,7 @@ public: { if (CloseDoorTimer <= diff) { - instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), false); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_LIBRARY_DOOR), false); CloseDoorTimer = 0; } else @@ -362,9 +365,9 @@ public: FlameWreathTimer = 20000; FlameWreathCheckTime = 500; - FlameWreathTarget[0] = 0; - FlameWreathTarget[1] = 0; - FlameWreathTarget[2] = 0; + FlameWreathTarget[0].Clear(); + FlameWreathTarget[1].Clear(); + FlameWreathTarget[2].Clear(); FlameWreathEffect(); break; @@ -496,7 +499,7 @@ public: { unit->CastSpell(unit, 20476, true, 0, 0, me->GetGUID()); unit->CastSpell(unit, 11027, true); - FlameWreathTarget[i] = 0; + FlameWreathTarget[i].Clear(); } } FlameWreathCheckTime = 500; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp index 94728f35b5..d2a4ffcf3a 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp @@ -70,13 +70,13 @@ public: InstanceScript* instance; - uint64 TerestianGUID; + ObjectGuid TerestianGUID; uint32 AmplifyTimer; void Reset() override { - TerestianGUID = 0; + TerestianGUID.Clear(); AmplifyTimer = 2000; } @@ -86,7 +86,7 @@ public: void JustDied(Unit* /*killer*/) override { - uint64 TerestianGUID = instance->GetData64(DATA_TERESTIAN); + ObjectGuid TerestianGUID = instance->GetGuidData(DATA_TERESTIAN); if (TerestianGUID) { Unit* Terestian = ObjectAccessor::GetUnit(*me, TerestianGUID); @@ -130,11 +130,11 @@ public: { npc_demon_chainAI(Creature* creature) : ScriptedAI(creature) { } - uint64 SacrificeGUID; + ObjectGuid SacrificeGUID; void Reset() override { - SacrificeGUID = 0; + SacrificeGUID.Clear(); } void EnterCombat(Unit* /*who*/) override { } @@ -243,14 +243,12 @@ public: { boss_terestianAI(Creature* creature) : ScriptedAI(creature) { - for (uint8 i = 0; i < 2; ++i) - PortalGUID[i] = 0; instance = creature->GetInstanceScript(); } InstanceScript* instance; - uint64 PortalGUID[2]; + ObjectGuid PortalGUID[2]; uint8 PortalsCount; uint32 SacrificeTimer; @@ -274,7 +272,7 @@ public: pPortal->DespawnOrUnsummon(); } - PortalGUID[i] = 0; + PortalGUID[i].Clear(); } } @@ -339,7 +337,7 @@ public: if (Creature* pPortal = ObjectAccessor::GetCreature((*me), PortalGUID[i])) pPortal->DespawnOrUnsummon(); - PortalGUID[i] = 0; + PortalGUID[i].Clear(); } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index c059def149..093c7bab8b 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -242,12 +242,12 @@ public: { npc_titoAI(Creature* creature) : ScriptedAI(creature) { } - uint64 DorotheeGUID; + ObjectGuid DorotheeGUID; uint32 YipTimer; void Reset() override { - DorotheeGUID = 0; + DorotheeGUID.Clear(); YipTimer = 10000; } @@ -260,7 +260,7 @@ public: { if (DorotheeGUID) { - Creature* Dorothee = (ObjectAccessor::GetCreature((*me), DorotheeGUID)); + Creature* Dorothee = ObjectAccessor::GetCreature(*me, DorotheeGUID); if (Dorothee && Dorothee->IsAlive()) { CAST_AI(boss_dorothee::boss_dorotheeAI, Dorothee->AI())->TitoDied = true; @@ -848,7 +848,7 @@ public: uint32 FearTimer; uint32 SwipeTimer; - uint64 HoodGUID; + ObjectGuid HoodGUID; float TempThreat; bool IsChasing; @@ -859,7 +859,7 @@ public: FearTimer = urand(25000, 35000); SwipeTimer = 5000; - HoodGUID = 0; + HoodGUID.Clear(); TempThreat = 0; IsChasing = false; @@ -918,7 +918,7 @@ public: if (Unit* target = ObjectAccessor::GetUnit(*me, HoodGUID)) { - HoodGUID = 0; + HoodGUID.Clear(); if (DoGetThreat(target)) DoModifyThreatPercent(target, -100); me->AddThreat(target, TempThreat); @@ -1050,7 +1050,7 @@ public: uint32 EntryYellTimer; uint32 AggroYellTimer; - uint64 RomuloGUID; + ObjectGuid RomuloGUID; uint32 Phase; @@ -1069,7 +1069,7 @@ public: void Reset() override { - RomuloGUID = 0; + RomuloGUID.Clear(); Phase = PHASE_JULIANNE; BlindingPassionTimer = 30000; @@ -1165,7 +1165,7 @@ public: InstanceScript* instance; - uint64 JulianneGUID; + ObjectGuid JulianneGUID; uint32 Phase; uint32 EntryYellTimer; @@ -1181,7 +1181,7 @@ public: void Reset() override { - JulianneGUID = 0; + JulianneGUID.Clear(); Phase = PHASE_ROMULO; BackwardLungeTimer = 15000; @@ -1259,7 +1259,7 @@ public: Talk(SAY_ROMULO_AGGRO); if (JulianneGUID) { - Creature* Julianne = (ObjectAccessor::GetCreature((*me), JulianneGUID)); + Creature* Julianne = ObjectAccessor::GetCreature(*me, JulianneGUID); if (Julianne && Julianne->GetVictim()) { me->AddThreat(Julianne->GetVictim(), 1.0f); diff --git a/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp index 754f72b911..614e9e74d5 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp @@ -142,7 +142,7 @@ public: return true; } - void SetData64(uint32 type, uint64 data) override + void SetGuidData(uint32 type, ObjectGuid data) override { if (type == DATA_IMAGE_OF_MEDIVH) ImageGUID = data; @@ -228,43 +228,12 @@ public: return OperaEvent; case DATA_OPERA_OZ_DEATHCOUNT: return OzDeathCount; - - case DATA_KILREK: - return m_uiKilrekGUID; - case DATA_TERESTIAN: - return m_uiTerestianGUID; - case DATA_MOROES: - return m_uiMoroesGUID; - case DATA_GO_STAGEDOORLEFT: - return m_uiStageDoorLeftGUID; - case DATA_GO_STAGEDOORRIGHT: - return m_uiStageDoorRightGUID; - case DATA_GO_CURTAINS: - return m_uiCurtainGUID; - case DATA_GO_LIBRARY_DOOR: - return m_uiLibraryDoor; - case DATA_GO_MASSIVE_DOOR: - return m_uiMassiveDoor; - case DATA_GO_SIDE_ENTRANCE_DOOR: - return m_uiSideEntranceDoor; - case DATA_GO_GAME_DOOR: - return m_uiGamesmansDoor; - case DATA_GO_GAME_EXIT_DOOR: - return m_uiGamesmansExitDoor; - case DATA_GO_NETHER_DOOR: - return m_uiNetherspaceDoor; - case DATA_MASTERS_TERRACE_DOOR_1: - return MastersTerraceDoor[0]; - case DATA_MASTERS_TERRACE_DOOR_2: - return MastersTerraceDoor[1]; - case DATA_IMAGE_OF_MEDIVH: - return ImageGUID; } return 0; } - uint64 GetData64(uint32 data) const override + ObjectGuid GetGuidData(uint32 data) const override { switch (data) { @@ -302,7 +271,7 @@ public: return m_uiNightBaneGUID; } - return 0; + return ObjectGuid::Empty; } private: @@ -311,25 +280,25 @@ public: uint32 OptionalBossCount; //uint32 m_auiEncounter[MAX_ENCOUNTERS]; //uint32 m_uiTeam; - uint64 m_uiCurtainGUID; - uint64 m_uiStageDoorLeftGUID; - uint64 m_uiStageDoorRightGUID; - uint64 m_uiKilrekGUID; - uint64 m_uiTerestianGUID; - uint64 m_uiMoroesGUID; - uint64 m_uiNightBaneGUID; - //uint64 EchoOfMedivhGUID; - uint64 m_uiLibraryDoor; // Door at Shade of Aran - uint64 m_uiMassiveDoor; // Door at Netherspite - uint64 m_uiSideEntranceDoor; // Side Entrance - uint64 m_uiGamesmansDoor; // Door before Chess - uint64 m_uiGamesmansExitDoor; // Door after Chess - uint64 m_uiNetherspaceDoor; // Door at Malchezaar - //uint64 m_uiServantsAccessDoor; // Door to Brocken Stair - uint64 MastersTerraceDoor[2]; - uint64 ImageGUID; - uint64 DustCoveredChest; - uint64 m_uiRelayGUID; + ObjectGuid m_uiCurtainGUID; + ObjectGuid m_uiStageDoorLeftGUID; + ObjectGuid m_uiStageDoorRightGUID; + ObjectGuid m_uiKilrekGUID; + ObjectGuid m_uiTerestianGUID; + ObjectGuid m_uiMoroesGUID; + ObjectGuid m_uiNightBaneGUID; + //ObjectGuid EchoOfMedivhGUID; + ObjectGuid m_uiLibraryDoor; // Door at Shade of Aran + ObjectGuid m_uiMassiveDoor; // Door at Netherspite + ObjectGuid m_uiSideEntranceDoor; // Side Entrance + ObjectGuid m_uiGamesmansDoor; // Door before Chess + ObjectGuid m_uiGamesmansExitDoor; // Door after Chess + ObjectGuid m_uiNetherspaceDoor; // Door at Malchezaar + //ObjectGuid m_uiServantsAccessDoor; // Door to Brocken Stair + ObjectGuid MastersTerraceDoor[2]; + ObjectGuid ImageGUID; + ObjectGuid DustCoveredChest; + ObjectGuid m_uiRelayGUID; }; }; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp index 010f5c52e4..31f45662d2 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp @@ -126,7 +126,7 @@ public: InstanceScript* instance; - uint64 m_uiSpotlightGUID; + ObjectGuid m_uiSpotlightGUID; uint32 TalkCount; uint32 TalkTimer; @@ -138,7 +138,7 @@ public: void Reset() override { - m_uiSpotlightGUID = 0; + m_uiSpotlightGUID.Clear(); TalkCount = 0; TalkTimer = 2000; @@ -168,7 +168,7 @@ public: { case 0: DoCast(me, SPELL_TUXEDO, false); - instance->DoUseDoorOrButton(instance->GetData64(DATA_GO_STAGEDOORLEFT)); + instance->DoUseDoorOrButton(instance->GetGuidData(DATA_GO_STAGEDOORLEFT)); break; case 4: TalkCount = 0; @@ -184,12 +184,12 @@ public: } break; case 8: - instance->DoUseDoorOrButton(instance->GetData64(DATA_GO_STAGEDOORLEFT)); + instance->DoUseDoorOrButton(instance->GetGuidData(DATA_GO_STAGEDOORLEFT)); PerformanceReady = true; break; case 9: PrepareEncounter(); - instance->DoUseDoorOrButton(instance->GetData64(DATA_GO_CURTAINS)); + instance->DoUseDoorOrButton(instance->GetGuidData(DATA_GO_CURTAINS)); break; } } @@ -437,7 +437,7 @@ public: InstanceScript* instance; - uint64 ArcanagosGUID; + ObjectGuid ArcanagosGUID; uint32 YellTimer; uint8 Step; @@ -448,11 +448,11 @@ public: void Reset() override { - ArcanagosGUID = 0; + ArcanagosGUID.Clear(); MTimer = 0; ATimer = 0; - if (instance && instance->GetData64(DATA_IMAGE_OF_MEDIVH) == 0) + if (instance && !instance->GetGuidData(DATA_IMAGE_OF_MEDIVH)) { Creature* Arcanagos = me->SummonCreature(NPC_ARCANAGOS, ArcanagosPos[0], ArcanagosPos[1], ArcanagosPos[2], 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000); if (!Arcanagos) @@ -461,7 +461,7 @@ public: return; } - instance->SetData64(DATA_IMAGE_OF_MEDIVH, me->GetGUID()); + instance->SetGuidData(DATA_IMAGE_OF_MEDIVH, me->GetGUID()); EventStarted = true; ArcanagosGUID = Arcanagos->GetGUID(); diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index df3591cde7..fb2084f4db 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -314,7 +314,7 @@ struct boss_priestess_lackey_commonAI : public ScriptedAI void EnterEvadeMode() override { - if (Creature* delrissa = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_DELRISSA))) + if (Creature* delrissa = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_DELRISSA))) if (!delrissa->IsAlive()) { delrissa->Respawn(); @@ -325,7 +325,7 @@ struct boss_priestess_lackey_commonAI : public ScriptedAI void EnterCombat(Unit* who) override { - if (Creature* delrissa = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_DELRISSA))) + if (Creature* delrissa = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_DELRISSA))) if (delrissa->IsAlive() && !delrissa->IsInCombat()) delrissa->AI()->AttackStart(who); @@ -344,7 +344,7 @@ struct boss_priestess_lackey_commonAI : public ScriptedAI void KilledUnit(Unit* victim) override { - if (Creature* delrissa = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_DELRISSA))) + if (Creature* delrissa = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_DELRISSA))) delrissa->AI()->KilledUnit(victim); } diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp index d0f52bd9f1..769b483587 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp @@ -59,7 +59,7 @@ public: InstanceScript* instance; EventMap events; SummonList summons; - uint64 CrystalGUID; + ObjectGuid CrystalGUID; bool CanAIAttack(const Unit* who) const override { @@ -94,7 +94,7 @@ public: summons.DespawnAll(); SpawnCrystals(); instance->SetData(DATA_SELIN_EVENT, NOT_STARTED); - CrystalGUID = 0; + CrystalGUID.Clear(); me->SetPower(POWER_MANA, 0); } @@ -130,7 +130,7 @@ public: if (summons.empty()) return; - CrystalGUID = 0; + CrystalGUID.Clear(); Unit* crystal = nullptr; for (SummonList::const_iterator i = summons.begin(); i != summons.end(); ) if (Creature* summon = ObjectAccessor::GetCreature(*me, *i++)) diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp index 29d968d197..0725a58edb 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp @@ -17,29 +17,19 @@ public: uint32 Encounter[MAX_ENCOUNTER]; - uint64 VexallusDoorGUID; - uint64 SelinDoorGUID; - uint64 SelinEncounterDoorGUID; - uint64 DelrissaDoorGUID; - uint64 KaelDoorGUID; - uint64 EscapeOrbGUID; + ObjectGuid VexallusDoorGUID; + ObjectGuid SelinDoorGUID; + ObjectGuid SelinEncounterDoorGUID; + ObjectGuid DelrissaDoorGUID; + ObjectGuid KaelDoorGUID; + ObjectGuid EscapeOrbGUID; - uint64 DelrissaGUID; - uint64 KaelGUID; + ObjectGuid DelrissaGUID; + ObjectGuid KaelGUID; void Initialize() override { memset(&Encounter, 0, sizeof(Encounter)); - - VexallusDoorGUID = 0; - SelinDoorGUID = 0; - SelinEncounterDoorGUID = 0; - DelrissaDoorGUID = 0; - KaelDoorGUID = 0; - EscapeOrbGUID = 0; - - DelrissaGUID = 0; - KaelGUID = 0; } bool IsEncounterInProgress() const override @@ -118,7 +108,7 @@ public: { case GO_SELIN_DOOR: if (GetData(DATA_SELIN_EVENT) == DONE) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); SelinDoorGUID = go->GetGUID(); break; case GO_SELIN_ENCOUNTER_DOOR: @@ -127,13 +117,13 @@ public: case GO_VEXALLUS_DOOR: if (GetData(DATA_VEXALLUS_EVENT) == DONE) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); VexallusDoorGUID = go->GetGUID(); break; case GO_DELRISSA_DOOR: if (GetData(DATA_DELRISSA_EVENT) == DONE) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); DelrissaDoorGUID = go->GetGUID(); break; case GO_KAEL_DOOR: @@ -182,14 +172,15 @@ public: OUT_LOAD_INST_DATA_COMPLETE; } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { switch (identifier) { case NPC_DELRISSA: return DelrissaGUID; } - return 0; + + return ObjectGuid::Empty; } }; diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index d0275d6918..3f2f8f2af0 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -73,7 +73,7 @@ public: void SetControl(Player* player, bool on) { WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, me->GetPackGUID().size() + 1); - data.append(me->GetPackGUID()); + data << me->GetPackGUID(); data << uint8(on ? 1 : 0); player->GetSession()->SendPacket(&data); } @@ -208,7 +208,7 @@ public: if (player->IsInCombat() || creature->IsInCombat()) return true; - if (!creature->AI()->GetData(player->GetGUIDLow())) + if (!creature->AI()->GetGUID(player->GetGUID().GetCounter())) AddGossipItemFor(player, 9765, 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID()); @@ -226,7 +226,7 @@ public: npc_death_knight_initiateAI(Creature* creature) : CombatAI(creature) { } bool _duelInProgress; - uint64 _duelGUID; + ObjectGuid _duelGUID; EventMap events; std::set<uint32> playerGUIDs; uint32 timer = 0; @@ -242,7 +242,7 @@ public: void Reset() override { _duelInProgress = false; - _duelGUID = 0; + _duelGUID.Clear(); me->RestoreFaction(); CombatAI::Reset(); @@ -253,7 +253,7 @@ public: { if (!_duelInProgress && pSpell->Id == SPELL_DUEL) { - playerGUIDs.insert(caster->GetGUIDLow()); + playerGUIDs.insert(caster->GetGUID().GetCounter()); _duelGUID = caster->GetGUID(); _duelInProgress = true; @@ -280,7 +280,7 @@ public: damage = 0; events.ScheduleEvent(EVENT_DUEL_LOST, 2000); events.ScheduleEvent(EVENT_DUEL_LOST + 1, 6000); - _duelGUID = 0; + _duelGUID.Clear(); _duelInProgress = 0; attacker->RemoveGameObject(SPELL_DUEL_FLAG, true); @@ -453,11 +453,10 @@ public: } EventMap events; - uint64 gothikGUID; + ObjectGuid gothikGUID; void InitializeAI() override { - gothikGUID = 0; me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); ScriptedAI::InitializeAI(); me->SetReactState(REACT_PASSIVE); @@ -472,7 +471,7 @@ public: AttackStart(attacker); } - void SetGUID(uint64 guid, int32) override + void SetGUID(ObjectGuid guid, int32) override { gothikGUID = guid; events.ScheduleEvent(EVENT_GHOUL_MOVE_TO_PIT, 3000); @@ -701,17 +700,17 @@ public: me->SetCurrentEquipmentId(me->GetOriginalEquipmentId()); } - uint64 playerGUID; + ObjectGuid playerGUID; UnworthyInitiatePhase phase; uint32 wait_timer; float anchorX, anchorY; - uint64 anchorGUID; + ObjectGuid anchorGUID; EventMap events; void Reset() override { - anchorGUID = 0; + anchorGUID.Clear(); phase = PHASE_CHAINED; events.Reset(); me->setFaction(7); @@ -880,17 +879,17 @@ public: struct npc_unworthy_initiate_anchorAI : public PassiveAI { - npc_unworthy_initiate_anchorAI(Creature* creature) : PassiveAI(creature), prisonerGUID(0) {} + npc_unworthy_initiate_anchorAI(Creature* creature) : PassiveAI(creature) {} - uint64 prisonerGUID; + ObjectGuid prisonerGUID; - void SetGUID(uint64 guid, int32 /*id*/) override + void SetGUID(ObjectGuid guid, int32 /*id*/) override { if (!prisonerGUID) prisonerGUID = guid; } - uint64 GetGUID(int32 /*id*/) const override + ObjectGuid GetGUID(int32 /*id*/) const override { return prisonerGUID; } @@ -905,7 +904,7 @@ public: bool OnGossipHello(Player* player, GameObject* go) override { if (Creature* anchor = go->FindNearestCreature(29521, 15)) - if (uint64 prisonerGUID = anchor->AI()->GetGUID()) + if (ObjectGuid prisonerGUID = anchor->AI()->GetGUID()) if (Creature* prisoner = ObjectAccessor::GetCreature(*player, prisonerGUID)) CAST_AI(npc_unworthy_initiate::npc_unworthy_initiateAI, prisoner->AI())->EventStart(anchor, player); @@ -935,16 +934,16 @@ public: struct npc_scarlet_miner_cartAI : public PassiveAI { - npc_scarlet_miner_cartAI(Creature* creature) : PassiveAI(creature), minerGUID(0) + npc_scarlet_miner_cartAI(Creature* creature) : PassiveAI(creature) { me->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC); me->setFaction(35); me->SetDisplayId(me->GetCreatureTemplate()->Modelid1); // Modelid2 is a horse. } - uint64 minerGUID; + ObjectGuid minerGUID; - void SetGUID(uint64 guid, int32 /*id*/) override + void SetGUID(ObjectGuid guid, int32 /*id*/) override { minerGUID = guid; } @@ -1004,11 +1003,11 @@ public: uint32 IntroTimer; uint32 IntroPhase; - uint64 carGUID; + ObjectGuid carGUID; void Reset() override { - carGUID = 0; + carGUID.Clear(); IntroTimer = 0; IntroPhase = 0; } diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp index a287a4f4f6..fabd56f088 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp @@ -47,13 +47,13 @@ public: uint32 speechTimer; uint32 speechCounter; - uint64 playerGUID; + ObjectGuid playerGUID; void Reset() override { speechTimer = 0; speechCounter = 0; - playerGUID = 0; + playerGUID.Clear(); me->SetReactState(REACT_AGGRESSIVE); me->RestoreFaction(); } @@ -212,7 +212,7 @@ public: uint32 m_uiWave; uint32 m_uiWave_Timer; - uint64 m_uiValrothGUID; + ObjectGuid m_uiValrothGUID; SummonList summons; void Reset() override @@ -221,7 +221,7 @@ public: { m_uiWave = 0; m_uiWave_Timer = 3000; - m_uiValrothGUID = 0; + m_uiValrothGUID.Clear(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->LoadEquipment(0, true); me->RemoveAllAuras(); @@ -645,13 +645,13 @@ public: uint32 ExecuteSpeech_Timer; uint32 ExecuteSpeech_Counter; - uint64 PlayerGUID; + ObjectGuid PlayerGUID; void Reset() override { ExecuteSpeech_Timer = 0; ExecuteSpeech_Counter = 0; - PlayerGUID = 0; + PlayerGUID.Clear(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); } diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/instance_scarlet_monastery.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/instance_scarlet_monastery.cpp index 8eb2f07bed..248ade3d9a 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/instance_scarlet_monastery.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/instance_scarlet_monastery.cpp @@ -147,7 +147,7 @@ public: } } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -158,7 +158,8 @@ public: case DATA_DOOR_WHITEMANE: return DoorHighInquisitorGUID; } - return 0; + + return ObjectGuid::Empty; } uint32 GetData(uint32 type) const override @@ -168,9 +169,9 @@ public: return 0; } private: - uint64 DoorHighInquisitorGUID; - uint64 MograineGUID; - uint64 WhitemaneGUID; + ObjectGuid DoorHighInquisitorGUID; + ObjectGuid MograineGUID; + ObjectGuid WhitemaneGUID; uint32 encounter; }; }; @@ -395,7 +396,7 @@ public: return; //On first death, fake death and open door, as well as initiate whitemane if exist - if (Unit* Whitemane = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_WHITEMANE))) + if (Unit* Whitemane = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_WHITEMANE))) { instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, IN_PROGRESS); Whitemane->GetMotionMaster()->MovePoint(1, 1163.113370f, 1398.856812f, 32.527786f); @@ -413,7 +414,7 @@ public: hasDied = true; fakeDeath = true; damage = 0; - ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_WHITEMANE))->SetInCombatWithZone(); + ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_WHITEMANE))->SetInCombatWithZone(); } } @@ -451,7 +452,7 @@ public: if (hasDied && !heal && instance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT) == SPECIAL) { //On resurrection, stop fake death and heal whitemane and resume fight - if (Unit* Whitemane = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_WHITEMANE))) + if (Unit* Whitemane = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_WHITEMANE))) { //Incase wipe during phase that mograine fake death me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -563,7 +564,7 @@ public: //When casting resuruction make sure to delay so on rez when reinstate battle deepsleep runs out if (Wait_Timer <= diff) { - if (ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_MOGRAINE))) + if (ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MOGRAINE))) { DoCast(SPELL_SCARLET_RESURRECTION); Talk(SAY_WH_RESURRECT); @@ -597,7 +598,7 @@ public: if (!HealthAbovePct(75)) target = me; - if (Creature* mograine = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_MOGRAINE))) + if (Creature* mograine = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MOGRAINE))) { // checking canResurrectCheck prevents her healing Mograine while he is "faking death" if (canResurrectCheck && mograine->IsAlive() && !mograine->HealthAbovePct(75)) diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_kirtonos_the_herald.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_kirtonos_the_herald.cpp index 2d32677bb7..0737faee57 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_kirtonos_the_herald.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_kirtonos_the_herald.cpp @@ -84,7 +84,7 @@ public: void JustDied(Unit* /*killer*/) override { - if (GameObject* gate = me->GetMap()->GetGameObject(instance->GetData64(GO_GATE_KIRTONOS))) + if (GameObject* gate = me->GetMap()->GetGameObject(instance->GetGuidData(GO_GATE_KIRTONOS))) { gate->SetGoState(GO_STATE_ACTIVE); } @@ -94,7 +94,7 @@ public: void EnterEvadeMode() override { - if (GameObject* gate = me->GetMap()->GetGameObject(instance->GetData64(GO_GATE_KIRTONOS))) + if (GameObject* gate = me->GetMap()->GetGameObject(instance->GetGuidData(GO_GATE_KIRTONOS))) { gate->SetGoState(GO_STATE_ACTIVE); } @@ -137,7 +137,7 @@ public: me->GetMotionMaster()->MovePoint(0, PosMove[0]); break; case INTRO_3: - if (GameObject* gate = me->GetMap()->GetGameObject(instance->GetData64(GO_GATE_KIRTONOS))) + if (GameObject* gate = me->GetMap()->GetGameObject(instance->GetGuidData(GO_GATE_KIRTONOS))) { gate->SetGoState(GO_STATE_READY); } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp b/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp index 45e8f78a30..b03dc057a5 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp @@ -24,13 +24,6 @@ public: struct instance_scholomance_InstanceMapScript : public InstanceScript { instance_scholomance_InstanceMapScript(Map* map) : InstanceScript(map), - GateKirtonosGUID { 0 }, - GateMiliciaGUID { 0 }, - GateTheolenGUID { 0 }, - GatePolkeltGUID { 0 }, - GateRavenianGUID { 0 }, - GateBarovGUID { 0 }, - GateIlluciaGUID { 0 }, _kirtonosState { 0 }, _miniBosses { 0 }, _rasHuman { 0 } @@ -64,7 +57,7 @@ public: } } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -84,7 +77,7 @@ public: return GateIlluciaGUID; } - return 0; + return ObjectGuid::Empty; } void SetData(uint32 type, uint32 data) override @@ -146,13 +139,13 @@ public: } protected: - uint64 GateKirtonosGUID; - uint64 GateMiliciaGUID; - uint64 GateTheolenGUID; - uint64 GatePolkeltGUID; - uint64 GateRavenianGUID; - uint64 GateBarovGUID; - uint64 GateIlluciaGUID; + ObjectGuid GateKirtonosGUID; + ObjectGuid GateMiliciaGUID; + ObjectGuid GateTheolenGUID; + ObjectGuid GatePolkeltGUID; + ObjectGuid GateRavenianGUID; + ObjectGuid GateBarovGUID; + ObjectGuid GateIlluciaGUID; uint32 _kirtonosState; uint32 _miniBosses; @@ -291,37 +284,37 @@ public: { case ROOM_HALL_OF_SECRETS: if (InstanceScript* instance = caster->GetInstanceScript()) - if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetData64(GO_GATE_RAVENIAN))) + if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetGuidData(GO_GATE_RAVENIAN))) if (gate->GetGoState() == GO_STATE_ACTIVE) spellId = SPELL_SHADOW_PORTAL_HALLOFSECRETS; break; case ROOM_HALL_OF_THE_DAMNED: if (InstanceScript* instance = caster->GetInstanceScript()) - if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetData64(GO_GATE_THEOLEN))) + if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetGuidData(GO_GATE_THEOLEN))) if (gate->GetGoState() == GO_STATE_ACTIVE) spellId = SPELL_SHADOW_PORTAL_HALLOFTHEDAMNED; break; case ROOM_THE_COVEN: if (InstanceScript* instance = caster->GetInstanceScript()) - if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetData64(GO_GATE_MALICIA))) + if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetGuidData(GO_GATE_MALICIA))) if (gate->GetGoState() == GO_STATE_ACTIVE) spellId = SPELL_SHADOW_PORTAL_THECOVEN; break; case ROOM_THE_SHADOW_VAULT: if (InstanceScript* instance = caster->GetInstanceScript()) - if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetData64(GO_GATE_ILLUCIA))) + if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetGuidData(GO_GATE_ILLUCIA))) if (gate->GetGoState() == GO_STATE_ACTIVE) spellId = SPELL_SHADOW_PORTAL_THESHADOWVAULT; break; case ROOM_BAROV_FAMILY_VAULT: if (InstanceScript* instance = caster->GetInstanceScript()) - if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetData64(GO_GATE_BAROV))) + if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetGuidData(GO_GATE_BAROV))) if (gate->GetGoState() == GO_STATE_ACTIVE) spellId = SPELL_SHADOW_PORTAL_BAROVFAMILYVAULT; break; case ROOM_VAULT_OF_THE_RAVENIAN: if (InstanceScript* instance = caster->GetInstanceScript()) - if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetData64(GO_GATE_POLKELT))) + if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetGuidData(GO_GATE_POLKELT))) if (gate->GetGoState() == GO_STATE_ACTIVE) spellId = SPELL_SHADOW_PORTAL_VAULTOFTHERAVENIAN; break; @@ -442,7 +435,7 @@ public: } if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetData64(gateId))) + if (GameObject* gate = ObjectAccessor::GetGameObject(*caster, instance->GetGuidData(gateId))) { gate->SetGoState(GO_STATE_READY); gate->AI()->SetData(1, 1); diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp index 955263116b..74ca9e0f41 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp @@ -40,15 +40,15 @@ public: { case GO_COURTYARD_DOOR: if (_encounters[TYPE_COURTYARD] == DONE) - HandleGameObject(0, true, gameobject); + HandleGameObject(ObjectGuid::Empty, true, gameobject); break; case GO_SORCERER_DOOR: if (_encounters[TYPE_FENRUS_THE_DEVOURER] == DONE) - HandleGameObject(0, true, gameobject); + HandleGameObject(ObjectGuid::Empty, true, gameobject); break; case GO_ARUGAL_DOOR: if (_encounters[TYPE_WOLF_MASTER_NANDOS] == DONE) - HandleGameObject(0, true, gameobject); + HandleGameObject(ObjectGuid::Empty, true, gameobject); break; } } diff --git a/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp b/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp index 2abe9db045..449dc40135 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp @@ -60,15 +60,6 @@ public: _slaughterNPCs = 0; _postboxesOpened = 0; - _zigguratDoorsGUID1 = 0; - _zigguratDoorsGUID2 = 0; - _zigguratDoorsGUID3 = 0; - _zigguratDoorsGUID4 = 0; - _zigguratDoorsGUID5 = 0; - _gauntletGateGUID = 0; - _slaughterGateGUID = 0; - _baronRivendareGUID = 0; - _gateTrapsCooldown[0] = false; _gateTrapsCooldown[1] = false; @@ -546,18 +537,18 @@ public: uint32 _postboxesOpened; EventMap events; - uint64 _zigguratDoorsGUID1; - uint64 _zigguratDoorsGUID2; - uint64 _zigguratDoorsGUID3; - uint64 _zigguratDoorsGUID4; - uint64 _zigguratDoorsGUID5; - uint64 _slaughterGateGUID; - uint64 _gauntletGateGUID; - uint64 _baronRivendareGUID; + ObjectGuid _zigguratDoorsGUID1; + ObjectGuid _zigguratDoorsGUID2; + ObjectGuid _zigguratDoorsGUID3; + ObjectGuid _zigguratDoorsGUID4; + ObjectGuid _zigguratDoorsGUID5; + ObjectGuid _slaughterGateGUID; + ObjectGuid _gauntletGateGUID; + ObjectGuid _baronRivendareGUID; bool _gateTrapsCooldown[2]; - uint64 _trappedPlayerGUID; - uint64 _trapGatesGUIDs[4]; + ObjectGuid _trappedPlayerGUID; + ObjectGuid _trapGatesGUIDs[4]; void gate_delay(int gate) { @@ -575,7 +566,7 @@ public: { if (_trappedPlayerGUID) { - if (Player* pPlayer = instance->GetPlayer(_trappedPlayerGUID)) + if (Player* pPlayer = ObjectAccessor::GetPlayer(instance, _trappedPlayerGUID)) { DoSpawnPlaguedCritters(gate, pPlayer); } diff --git a/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp b/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp index 863539e4d5..176b8403f5 100644 --- a/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp +++ b/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp @@ -25,9 +25,6 @@ public: _statuePhase = 0; _defendersKilled = 0; memset(&_encounters, 0, sizeof(_encounters)); - - _forcefieldGUID = 0; - _jammalanGUID = 0; } void OnCreatureCreate(Creature* creature) override @@ -39,7 +36,7 @@ public: break; } - if (creature->IsAlive() && creature->GetDBTableGUIDLow() && creature->GetCreatureType() == CREATURE_TYPE_DRAGONKIN && creature->GetEntry() != NPC_SHADE_OF_ERANIKUS) + if (creature->IsAlive() && creature->GetSpawnId() && creature->GetCreatureType() == CREATURE_TYPE_DRAGONKIN && creature->GetEntry() != NPC_SHADE_OF_ERANIKUS) _dragonkinList.push_back(creature->GetGUID()); } @@ -99,9 +96,9 @@ public: } break; case DATA_ERANIKUS_FIGHT: - for (std::list<uint64>::const_iterator itr = _dragonkinList.begin(); itr != _dragonkinList.end(); ++itr) + for (ObjectGuid const guid : _dragonkinList) { - if (Creature* creature = instance->GetCreature(*itr)) + if (Creature* creature = instance->GetCreature(guid)) if (instance->IsGridLoaded(creature->GetPositionX(), creature->GetPositionY())) creature->SetInCombatWithZone(); } @@ -180,9 +177,9 @@ public: uint32 _defendersKilled; uint32 _encounters[MAX_ENCOUNTERS]; - uint64 _forcefieldGUID; - uint64 _jammalanGUID; - std::list<uint64> _dragonkinList; + ObjectGuid _forcefieldGUID; + ObjectGuid _jammalanGUID; + GuidList _dragonkinList; EventMap _events; }; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index 6b98d41ee0..01ec633967 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -94,7 +94,7 @@ public: Talk(YELL_DEATH); me->CastSpell(me, SPELL_SUMMON_BRUTALLUS_DEATH_CLOUD, true); - if (Creature* madrigosa = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_MADRIGOSA))) + if (Creature* madrigosa = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_MADRIGOSA))) madrigosa->AI()->DoAction(ACTION_SPAWN_FELMYST); } @@ -230,7 +230,7 @@ public: { case EVENT_MAD_1: me->SetVisible(true); - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) { me->SetTarget(brutallus->GetGUID()); brutallus->SetReactState(REACT_PASSIVE); @@ -256,12 +256,12 @@ public: events.ScheduleEvent(EVENT_MAD_4, 7000); break; case EVENT_MAD_4: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) brutallus->AI()->Talk(YELL_INTRO); events.ScheduleEvent(EVENT_MAD_5, 5000); break; case EVENT_MAD_5: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) { brutallus->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_ATTACK1H); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_ATTACK1H); @@ -269,7 +269,7 @@ public: events.ScheduleEvent(EVENT_MAD_6, 10000); break; case EVENT_MAD_6: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) { brutallus->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); @@ -292,11 +292,11 @@ public: events.ScheduleEvent(EVENT_MAD_8, 14000); break; case EVENT_MAD_8: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) me->CastSpell(brutallus, SPELL_MADRIGOSA_FROSTBOLT, false); break; case EVENT_MAD_9: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) { brutallus->CastSpell(brutallus, SPELL_BRUTALLUS_FLAME_RING, true); brutallus->RemoveAllAuras(); @@ -318,7 +318,7 @@ public: events.ScheduleEvent(EVENT_MAD_14, 2000); break; case EVENT_MAD_14: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) { brutallus->SetDisableGravity(true); brutallus->GetMotionMaster()->MovePoint(0, brutallus->GetPositionX(), brutallus->GetPositionY() - 30.0f, brutallus->GetPositionZ() + 15.0f, false, true); @@ -326,7 +326,7 @@ public: events.ScheduleEvent(EVENT_MAD_15, 10000); break; case EVENT_MAD_15: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) { brutallus->RemoveAllAuras(); brutallus->SetDisableGravity(false); @@ -336,12 +336,12 @@ public: events.ScheduleEvent(EVENT_MAD_16, 1400); break; case EVENT_MAD_16: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) brutallus->CastSpell(me, SPELL_BRUTALLUS_CHARGE, true); events.ScheduleEvent(EVENT_MAD_17, 1200); break; case EVENT_MAD_17: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) brutallus->HandleEmoteCommand(EMOTE_ONESHOT_ATTACK1H); events.ScheduleEvent(EVENT_MAD_18, 500); break; @@ -352,14 +352,14 @@ public: events.ScheduleEvent(EVENT_MAD_19, 6000); break; case EVENT_MAD_19: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) brutallus->AI()->Talk(YELL_INTRO_KILL_MADRIGOSA); events.ScheduleEvent(EVENT_MAD_20, 7000); break; case EVENT_MAD_20: me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->setFaction(35); - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) { brutallus->AI()->Talk(YELL_INTRO_TAUNT); brutallus->CastSpell(brutallus, SPELL_BRUTALLUS_BREAK_ICE, false); @@ -367,7 +367,7 @@ public: events.ScheduleEvent(EVENT_MAD_21, 4000); break; case EVENT_MAD_21: - if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_BRUTALLUS))) + if (Creature* brutallus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_BRUTALLUS))) { brutallus->SetReactState(REACT_AGGRESSIVE); brutallus->SetHealth(brutallus->GetMaxHealth()); @@ -377,7 +377,7 @@ public: break; case EVENT_SPAWN_FELMYST: me->DespawnOrUnsummon(1); - if (Creature* felmyst = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_FELMYST))) + if (Creature* felmyst = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_FELMYST))) felmyst->AI()->DoAction(ACTION_START_EVENT); break; } @@ -517,7 +517,7 @@ public: { instance->SetBossState(DATA_MADRIGOSA, NOT_STARTED); instance->SetBossState(DATA_MADRIGOSA, DONE); - if (Creature* creature = ObjectAccessor::GetCreature(*player, instance->GetData64(NPC_MADRIGOSA))) + if (Creature* creature = ObjectAccessor::GetCreature(*player, instance->GetGuidData(NPC_MADRIGOSA))) creature->AI()->DoAction(ACTION_START_EVENT); } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp index 473fb25ee2..9f732530ec 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp @@ -101,7 +101,7 @@ public: void EnterEvadeMode() override { BossAI::EnterEvadeMode(); - if (Creature* alythess = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_GRAND_WARLOCK_ALYTHESS))) + if (Creature* alythess = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_GRAND_WARLOCK_ALYTHESS))) { if (!alythess->IsAlive()) alythess->Respawn(true); @@ -113,7 +113,7 @@ public: void EnterCombat(Unit* who) override { BossAI::EnterCombat(who); - if (Creature* alythess = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_GRAND_WARLOCK_ALYTHESS))) + if (Creature* alythess = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_GRAND_WARLOCK_ALYTHESS))) if (alythess->IsAlive() && !alythess->IsInCombat()) alythess->AI()->AttackStart(who); @@ -140,7 +140,7 @@ public: Talk(YELL_SAC_DEAD); instance->SetBossState(DATA_EREDAR_TWINS, DONE); } - else if (Creature* alythess = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_GRAND_WARLOCK_ALYTHESS))) + else if (Creature* alythess = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_GRAND_WARLOCK_ALYTHESS))) alythess->AI()->DoAction(ACTION_SISTER_DIED); } @@ -249,7 +249,7 @@ public: void EnterEvadeMode() override { BossAI::EnterEvadeMode(); - if (Creature* scorlash = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_LADY_SACROLASH))) + if (Creature* scorlash = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_LADY_SACROLASH))) { if (!scorlash->IsAlive()) scorlash->Respawn(true); @@ -261,7 +261,7 @@ public: void EnterCombat(Unit* who) override { BossAI::EnterCombat(who); - if (Creature* scorlash = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_LADY_SACROLASH))) + if (Creature* scorlash = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_LADY_SACROLASH))) if (scorlash->IsAlive() && !scorlash->IsInCombat()) scorlash->AI()->AttackStart(who); @@ -288,7 +288,7 @@ public: Talk(YELL_SAC_DEAD); instance->SetBossState(DATA_EREDAR_TWINS, DONE); } - else if (Creature* scorlash = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_LADY_SACROLASH))) + else if (Creature* scorlash = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_LADY_SACROLASH))) scorlash->AI()->DoAction(ACTION_SISTER_DIED); } @@ -491,9 +491,9 @@ public: if (instance->GetBossState(DATA_EREDAR_TWINS_INTRO) != DONE) { instance->SetBossState(DATA_EREDAR_TWINS_INTRO, DONE); - if (Creature* creature = ObjectAccessor::GetCreature(*player, instance->GetData64(NPC_LADY_SACROLASH))) + if (Creature* creature = ObjectAccessor::GetCreature(*player, instance->GetGuidData(NPC_LADY_SACROLASH))) creature->AI()->Talk(YELL_INTRO_SAC); - if (Creature* creature = ObjectAccessor::GetCreature(*player, instance->GetData64(NPC_GRAND_WARLOCK_ALYTHESS))) + if (Creature* creature = ObjectAccessor::GetCreature(*player, instance->GetGuidData(NPC_GRAND_WARLOCK_ALYTHESS))) creature->AI()->Talk(YELL_INTRO_ALY); } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index 51cc80d9f1..a79ab5cfc9 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -193,7 +193,7 @@ public: } else if (point == POINT_AIR_BREATH_START1) { - me->SetTarget(0); + me->SetTarget(); me->SetFacingTo(4.71f); events.ScheduleEvent(EVENT_FLIGHT_EMOTE, 2000); events.ScheduleEvent(EVENT_CORRUPT_TRIGGERS, 5000); @@ -208,7 +208,7 @@ public: } else if (point == POINT_AIR_BREATH_START2) { - me->SetTarget(0); + me->SetTarget(); me->SetFacingTo(1.57f); events.ScheduleEvent(EVENT_FLIGHT_EMOTE, 2000); events.ScheduleEvent(EVENT_CORRUPT_TRIGGERS, 5000); @@ -308,7 +308,7 @@ public: break; case EVENT_FLIGHT_SEQ: Talk(YELL_TAKEOFF); - me->SetTarget(0); + me->SetTarget(); me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); me->SetDisableGravity(true); me->SendMovementFlagUpdate(); @@ -534,7 +534,7 @@ public: return true; Creature* cr = object->ToCreature(); - return cr->GetDBTableGUIDLow() != 54780 && cr->GetDBTableGUIDLow() != 54787 && cr->GetDBTableGUIDLow() != 54801; + return cr->GetSpawnId() != 54780 && cr->GetSpawnId() != 54787 && cr->GetSpawnId() != 54801; } }; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 07a4291305..85c0675bc9 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -173,7 +173,7 @@ public: events.Reset(); events2.ScheduleEvent(EVENT_TALK_GOOD_1, 1000); ClearPlayerAuras(); - if (Creature* Sath = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_SATHROVARR))) + if (Creature* Sath = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_SATHROVARR))) { Sath->RemoveAllAuras(); Sath->GetMotionMaster()->MovementExpired(); @@ -232,7 +232,7 @@ public: events2.ScheduleEvent(EVENT_TALK_GOOD_2, 1000); break; case EVENT_TALK_GOOD_2: - if (Creature* Sath = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_SATHROVARR))) + if (Creature* Sath = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_SATHROVARR))) { summons.Despawn(Sath); Unit::Kill(me, Sath); @@ -318,7 +318,7 @@ public: case EVENT_CHECK_HEALTH: if (me->HealthBelowPct(10)) { - if (Creature* Sath = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_SATHROVARR))) + if (Creature* Sath = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_SATHROVARR))) Sath->AI()->DoAction(ACTION_ENRAGE_OTHER); DoAction(ACTION_ENRAGE); break; @@ -408,7 +408,7 @@ public: void JustDied(Unit*) override { if (InstanceScript* instance = me->GetInstanceScript()) - if (Creature* kalecgos = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS))) + if (Creature* kalecgos = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS))) kalecgos->AI()->DoAction(ACTION_KALEC_DIED); } @@ -577,7 +577,7 @@ public: if (me->HealthBelowPct(10)) { if (InstanceScript* instance = me->GetInstanceScript()) - if (Creature* kalecgos = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS))) + if (Creature* kalecgos = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS))) kalecgos->AI()->DoAction(ACTION_ENRAGE_OTHER); DoAction(ACTION_ENRAGE); break; @@ -587,7 +587,7 @@ public: case EVENT_CHECK_HEALTH2: if (me->HealthBelowPct(1)) { - if (Creature* kalecgos = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS))) + if (Creature* kalecgos = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS))) kalecgos->AI()->DoAction(ACTION_SATH_BANISH); DoAction(ACTION_BANISH); break; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index 0cddeaf749..ee2fe12746 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -170,7 +170,7 @@ public: void ResetOrbs() { for (uint8 i = 0; i < 4; ++i) - if (GameObject* orb = ObjectAccessor::GetGameObject(*me, instance->GetData64(DATA_ORB_OF_THE_BLUE_DRAGONFLIGHT_1 + i))) + if (GameObject* orb = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(DATA_ORB_OF_THE_BLUE_DRAGONFLIGHT_1 + i))) orb->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } @@ -313,7 +313,7 @@ public: { if (damage >= me->GetHealth()) { - me->SetTarget(0); + me->SetTarget(); me->SetReactState(REACT_PASSIVE); me->RemoveAllAuras(); me->DeleteThreatList(); @@ -332,7 +332,7 @@ public: { Talk(SAY_KJ_DEATH); instance->SetBossState(DATA_KILJAEDEN, DONE); - if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KILJAEDEN_CONTROLLER))) + if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KILJAEDEN_CONTROLLER))) Unit::Kill(controller, controller); } @@ -392,17 +392,17 @@ public: me->CastSpell(me, SPELL_REBIRTH, false); break; case EVENT_EMPOWER_ORBS1: - if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS_KJ))) + if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS_KJ))) kalec->AI()->Talk(SAY_KALECGOS_READY1); EmpowerOrb(false); break; case EVENT_EMPOWER_ORBS2: - if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS_KJ))) + if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS_KJ))) kalec->AI()->Talk(SAY_KALECGOS_READY2); EmpowerOrb(false); break; case EVENT_EMPOWER_ORBS3: - if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS_KJ))) + if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS_KJ))) kalec->AI()->Talk(SAY_KALECGOS_READY_ALL); EmpowerOrb(true); break; @@ -412,56 +412,56 @@ public: me->SetInCombatWithZone(); return; case EVENT_TEXT_SPEACH11: - if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS_KJ))) + if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS_KJ))) kalec->AI()->Talk(SAY_KALECGOS_JOIN); break; case EVENT_TEXT_SPEACH21: - if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS_KJ))) + if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS_KJ))) kalec->AI()->Talk(SAY_KALECGOS_AWAKEN); break; case EVENT_TEXT_SPEACH22: - if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ANVEENA))) + if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ANVEENA))) sCreatureTextMgr->SendChat(anveena, SAY_ANVEENA_IMPRISONED, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); break; case EVENT_TEXT_SPEACH23: Talk(SAY_KJ_PHASE3); break; case EVENT_TEXT_SPEACH31: - if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS_KJ))) + if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS_KJ))) kalec->AI()->Talk(SAY_KALECGOS_LETGO); break; case EVENT_TEXT_SPEACH32: - if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ANVEENA))) + if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ANVEENA))) sCreatureTextMgr->SendChat(anveena, SAY_ANVEENA_LOST, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); break; case EVENT_TEXT_SPEACH33: Talk(SAY_KJ_PHASE4); break; case EVENT_TEXT_SPEACH41: - if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS_KJ))) + if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS_KJ))) kalec->AI()->Talk(SAY_KALECGOS_FOCUS); break; case EVENT_TEXT_SPEACH42: - if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ANVEENA))) + if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ANVEENA))) sCreatureTextMgr->SendChat(anveena, SAY_ANVEENA_KALEC, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); break; case EVENT_TEXT_SPEACH43: - if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KALECGOS_KJ))) + if (Creature* kalec = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KALECGOS_KJ))) kalec->AI()->Talk(SAY_KALECGOS_FATE); break; case EVENT_TEXT_SPEACH44: - if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ANVEENA))) + if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ANVEENA))) sCreatureTextMgr->SendChat(anveena, SAY_ANVEENA_GOODBYE, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); break; case EVENT_TEXT_SPEACH45: - if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ANVEENA))) + if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ANVEENA))) { anveena->RemoveAllAuras(); anveena->DespawnOrUnsummon(3500); } break; case EVENT_TEXT_SPEACH46: - if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ANVEENA))) + if (Creature* anveena = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ANVEENA))) { anveena->CastSpell(anveena, SPELL_SACRIFICE_OF_ANVEENA, true); me->CastSpell(me, SPELL_CUSTOM_08_STATE, true); @@ -628,7 +628,7 @@ public: { for (uint8 i = 0; i < 4; ++i) { - if (GameObject* orb = ObjectAccessor::GetGameObject(*me, instance->GetData64(DATA_ORB_OF_THE_BLUE_DRAGONFLIGHT_1 + i))) + if (GameObject* orb = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(DATA_ORB_OF_THE_BLUE_DRAGONFLIGHT_1 + i))) { if (orb->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE)) { @@ -636,7 +636,7 @@ public: if (Creature* trigger = me->SummonTrigger(orb->GetPositionX(), orb->GetPositionY(), orb->GetPositionZ(), 0, 10 * MINUTE * IN_MILLISECONDS)) { trigger->CastSpell(trigger, SPELL_RING_OF_BLUE_FLAMES, true, nullptr, nullptr, trigger->GetGUID()); - if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_KILJAEDEN_CONTROLLER))) + if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_KILJAEDEN_CONTROLLER))) controller->AI()->JustSummoned(trigger); } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index 3e46bf85c7..43d9271a57 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -166,7 +166,7 @@ public: void EnterEvadeMode() override { if (InstanceScript* instance = me->GetInstanceScript()) - if (Creature* muru = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_MURU))) + if (Creature* muru = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_MURU))) if (!muru->IsInEvadeMode()) muru->AI()->EnterEvadeMode(); @@ -195,7 +195,7 @@ public: void JustDied(Unit* /*killer*/) override { if (InstanceScript* instance = me->GetInstanceScript()) - if (Creature* muru = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_MURU))) + if (Creature* muru = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_MURU))) Unit::Kill(muru, muru); } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp index f4435f22dd..49a9924040 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp @@ -29,22 +29,6 @@ public: { SetBossNumber(MAX_ENCOUNTERS); LoadDoorData(doorData); - - KalecgosDragonGUID = 0; - SathrovarrGUID = 0; - BrutallusGUID = 0; - MadrigosaGUID = 0; - FelmystGUID = 0; - AlythessGUID = 0; - SacrolashGUID = 0; - MuruGUID = 0; - KilJaedenGUID = 0; - KilJaedenControllerGUID = 0; - AnveenaGUID = 0; - KalecgosKjGUID = 0; - - IceBarrierGUID = 0; - memset(&blueFlightOrbGUID, 0, sizeof(blueFlightOrbGUID)); } void OnPlayerEnter(Player* player) override @@ -64,7 +48,7 @@ public: for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { Player* player = itr->GetSource(); - if (player && !player->HasAura(45839, 0)) + if (player && !player->HasAura(45839)) return player; } } @@ -76,7 +60,7 @@ public: void OnCreatureCreate(Creature* creature) override { - if (creature->GetDBTableGUIDLow() > 0 || !IS_PLAYER_GUID(creature->GetOwnerGUID())) + if (creature->GetSpawnId() > 0 || !creature->GetOwnerGUID().IsPlayer()) creature->CastSpell(creature, SPELL_SUNWELL_RADIANCE, true); switch (creature->GetEntry()) @@ -196,7 +180,7 @@ public: } } - uint64 GetData64(uint32 id) const override + ObjectGuid GetGuidData(uint32 id) const override { switch (id) { @@ -232,7 +216,8 @@ public: case DATA_ORB_OF_THE_BLUE_DRAGONFLIGHT_4: return blueFlightOrbGUID[id - DATA_ORB_OF_THE_BLUE_DRAGONFLIGHT_1]; } - return 0; + + return ObjectGuid::Empty; } std::string GetSaveData() override @@ -279,21 +264,21 @@ public: } protected: - uint64 KalecgosDragonGUID; - uint64 SathrovarrGUID; - uint64 BrutallusGUID; - uint64 MadrigosaGUID; - uint64 FelmystGUID; - uint64 AlythessGUID; - uint64 SacrolashGUID; - uint64 MuruGUID; - uint64 KilJaedenGUID; - uint64 KilJaedenControllerGUID; - uint64 AnveenaGUID; - uint64 KalecgosKjGUID; - - uint64 IceBarrierGUID; - uint64 blueFlightOrbGUID[4]; + ObjectGuid KalecgosDragonGUID; + ObjectGuid SathrovarrGUID; + ObjectGuid BrutallusGUID; + ObjectGuid MadrigosaGUID; + ObjectGuid FelmystGUID; + ObjectGuid AlythessGUID; + ObjectGuid SacrolashGUID; + ObjectGuid MuruGUID; + ObjectGuid KilJaedenGUID; + ObjectGuid KilJaedenControllerGUID; + ObjectGuid AnveenaGUID; + ObjectGuid KalecgosKjGUID; + + ObjectGuid IceBarrierGUID; + ObjectGuid blueFlightOrbGUID[4]; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp b/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp index 7e04354d75..523e82e22a 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp @@ -31,8 +31,6 @@ public: void Initialize() override { memset(&_encounters, 0, sizeof(_encounters)); - archaedasTempleDoorGUID = 0; - ancientVaultDoorGUID = 0; } void OnGameObjectCreate(GameObject* gameobject) override @@ -43,18 +41,18 @@ public: case GO_KEYSTONE: if (_encounters[DATA_IRONAYA_DOORS] == DONE) { - HandleGameObject(0, true, gameobject); + HandleGameObject(ObjectGuid::Empty, true, gameobject); gameobject->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } break; case GO_TEMPLE_DOOR: if (_encounters[DATA_STONE_KEEPERS] == DONE) - HandleGameObject(0, true, gameobject); + HandleGameObject(ObjectGuid::Empty, true, gameobject); break; case GO_ANCIENT_VAULT_DOOR: ancientVaultDoorGUID = gameobject->GetGUID(); if (_encounters[DATA_ARCHAEDAS] == DONE) - HandleGameObject(0, true, gameobject); + HandleGameObject(ObjectGuid::Empty, true, gameobject); break; case GO_ARCHAEDAS_TEMPLE_DOOR: archaedasTempleDoorGUID = gameobject->GetGUID(); @@ -121,8 +119,8 @@ public: private: uint32 _encounters[MAX_ENCOUNTERS]; - uint64 archaedasTempleDoorGUID; - uint64 ancientVaultDoorGUID; + ObjectGuid archaedasTempleDoorGUID; + ObjectGuid ancientVaultDoorGUID; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp index ddb73b22c6..5ad0263b5a 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp @@ -76,17 +76,19 @@ public: { boss_akilzonAI(Creature* creature) : BossAI(creature, DATA_AKILZONEVENT) { - memset(BirdGUIDs, 0, sizeof(BirdGUIDs)); } void Reset() override { _Reset(); - TargetGUID = 0; - CloudGUID = 0; - CycloneGUID = 0; - memset(BirdGUIDs, 0, sizeof(BirdGUIDs)); + TargetGUID.Clear(); + CloudGUID.Clear(); + CycloneGUID.Clear(); + + for (uint8 i = 0; i < 8; ++i) + BirdGUIDs[i].Clear(); + StormCount = 0; isRaining = false; @@ -200,7 +202,7 @@ public: StormCount = 0; // finish events.ScheduleEvent(EVENT_SUMMON_EAGLES, 5000); me->InterruptNonMeleeSpells(false); - CloudGUID = 0; + CloudGUID.Clear(); if (Cloud) Unit::DealDamage(Cloud, Cloud, Cloud->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); SetWeather(WEATHER_STATE_FINE, 0.0f); @@ -353,10 +355,10 @@ public: } private: - uint64 BirdGUIDs[8]; - uint64 TargetGUID; - uint64 CycloneGUID; - uint64 CloudGUID; + ObjectGuid BirdGUIDs[8]; + ObjectGuid TargetGUID; + ObjectGuid CycloneGUID; + ObjectGuid CloudGUID; uint8 StormCount; bool isRaining; }; @@ -378,13 +380,13 @@ public: uint32 EagleSwoop_Timer; bool arrived; - uint64 TargetGUID; + ObjectGuid TargetGUID; void Reset() override { EagleSwoop_Timer = urand(5000, 10000); arrived = true; - TargetGUID = 0; + TargetGUID.Clear(); me->SetDisableGravity(true); } @@ -402,7 +404,7 @@ public: { if (Unit* target = ObjectAccessor::GetUnit(*me, TargetGUID)) DoCast(target, SPELL_EAGLE_SWOOP, true); - TargetGUID = 0; + TargetGUID.Clear(); me->SetSpeed(MOVE_RUN, 1.2f); EagleSwoop_Timer = urand(5000, 10000); } diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp index 40281b1a33..fd01cc8cd3 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp @@ -77,14 +77,14 @@ public: uint32 BerserkTimer; uint32 TransformCount; - uint64 LynxGUID; + ObjectGuid LynxGUID; void Reset() override { instance->SetData(DATA_HALAZZIEVENT, NOT_STARTED); summons.DespawnAll(); - LynxGUID = 0; + LynxGUID.Clear(); TransformCount = 0; BerserkTimer = 600000; CheckTimer = 1000; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp index 28ac0db08a..ff806ec9b8 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp @@ -247,16 +247,14 @@ public: { instance = creature->GetInstanceScript(); SelectAddEntry(); - for (uint8 i = 0; i < 4; ++i) - AddGUID[i] = 0; } InstanceScript* instance; - uint64 AddGUID[4]; + ObjectGuid AddGUID[4]; uint32 AddEntry[4]; - uint64 PlayerGUID; + ObjectGuid PlayerGUID; uint32 SpiritBolts_Timer; uint32 DrainPower_Timer; @@ -433,7 +431,7 @@ public: trigger->GetMotionMaster()->MoveChase(me); //DoCast(target, SPELL_SIPHON_SOUL, true); - //me->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, target->GetGUID()); + //me->SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, target->GetGUID()); //me->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_SIPHON_SOUL); PlayerGUID = target->GetGUID(); diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp index 71de8c8f55..86747102ee 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp @@ -126,7 +126,7 @@ public: bool isFlameBreathing; - uint64 FireBombGUIDs[40]; + ObjectGuid FireBombGUIDs[40]; void Reset() override { @@ -146,7 +146,7 @@ public: isFlameBreathing = false; for (uint8 i = 0; i < 40; ++i) - FireBombGUIDs[i] = 0; + FireBombGUIDs[i].Clear(); HatchAllEggs(1); } diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp index d6423b3ab4..e1da0046e2 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp @@ -127,9 +127,9 @@ public: } InstanceScript* instance; - uint64 SpiritGUID[4]; - uint64 ClawTargetGUID; - uint64 TankGUID; + ObjectGuid SpiritGUID[4]; + ObjectGuid ClawTargetGUID; + ObjectGuid TankGUID; uint32 Phase; uint32 health_20; @@ -180,8 +180,8 @@ public: Flame_Breath_Timer = 6000; Pillar_Of_Fire_Timer = 7000; - ClawTargetGUID = 0; - TankGUID = 0; + ClawTargetGUID.Clear(); + TankGUID.Clear(); Summons.DespawnAll(); @@ -278,7 +278,7 @@ public: temp->setDeathState(DEAD); } } - SpiritGUID[i] = 0; + SpiritGUID[i].Clear(); } } @@ -449,7 +449,7 @@ public: Claw_Rage_Timer = urand(15000, 20000); me->SetSpeed(MOVE_RUN, 1.2f); AttackStart(ObjectAccessor::GetUnit(*me, TankGUID)); - TankGUID = 0; + TankGUID.Clear(); return; } else @@ -499,7 +499,7 @@ public: Lynx_Rush_Timer = urand(15000, 20000); me->SetSpeed(MOVE_RUN, 1.2f); AttackStart(ObjectAccessor::GetUnit(*me, TankGUID)); - TankGUID = 0; + TankGUID.Clear(); } else AttackStart(SelectTarget(SELECT_TARGET_RANDOM, 0)); diff --git a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp index bf919ad93a..23ac2bbdc2 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp @@ -56,19 +56,19 @@ public: { instance_zulaman_InstanceMapScript(Map* map) : InstanceScript(map) {} - uint64 HarkorsSatchelGUID; - uint64 TanzarsTrunkGUID; - uint64 AshlisBagGUID; - uint64 KrazsPackageGUID; - uint64 StrangeGongGUID; - uint64 HarrisonJonesGUID; - - uint64 HexLordGateGUID; - uint64 ZulJinGateGUID; - uint64 MassiveGateGUID; - uint64 AkilzonDoorGUID; - uint64 ZulJinDoorGUID; - uint64 HalazziDoorGUID; + ObjectGuid HarkorsSatchelGUID; + ObjectGuid TanzarsTrunkGUID; + ObjectGuid AshlisBagGUID; + ObjectGuid KrazsPackageGUID; + ObjectGuid StrangeGongGUID; + ObjectGuid HarrisonJonesGUID; + + ObjectGuid HexLordGateGUID; + ObjectGuid ZulJinGateGUID; + ObjectGuid MassiveGateGUID; + ObjectGuid AkilzonDoorGUID; + ObjectGuid ZulJinDoorGUID; + ObjectGuid HalazziDoorGUID; uint32 QuestTimer; uint16 BossKilled; @@ -82,20 +82,6 @@ public: { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - HarkorsSatchelGUID = 0; - TanzarsTrunkGUID = 0; - AshlisBagGUID = 0; - KrazsPackageGUID = 0; - StrangeGongGUID = 0; - HexLordGateGUID = 0; - ZulJinGateGUID = 0; - MassiveGateGUID = 0; - AkilzonDoorGUID = 0; - HalazziDoorGUID = 0; - ZulJinDoorGUID = 0; - - HarrisonJonesGUID = 0; - QuestTimer = 0; QuestMinute = 0; BossKilled = 0; @@ -380,7 +366,7 @@ public: } } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -390,7 +376,7 @@ public: return MassiveGateGUID; } - return 0; + return ObjectGuid::Empty; } }; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp b/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp index 5ddc822d62..e916726e03 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp @@ -129,7 +129,7 @@ public: InstanceScript* instance; EventMap events; uint8 eventTimer; - uint64 PlayerGUID; + ObjectGuid PlayerGUID; void Reset() override { } @@ -146,7 +146,7 @@ public: events.Update(diff); if (eventTimer) { - Player* player = me->GetMap()->GetPlayer(PlayerGUID); + Player* player = ObjectAccessor::GetPlayer(me->GetMap(), PlayerGUID); switch (events.ExecuteEvent()) { case 1: @@ -454,7 +454,7 @@ public: } bool IsLoot; - uint64 PlayerGUID; + ObjectGuid PlayerGUID; void Reset() override { } @@ -598,13 +598,13 @@ public: uint8 _gongEvent; uint32 _gongTimer; - uint64 uiTargetGUID; + ObjectGuid uiTargetGUID; void Reset() override { _gongEvent = 0; _gongTimer = 0; - uiTargetGUID = 0; + uiTargetGUID.Clear(); } void EnterCombat(Unit* /*who*/) override { } @@ -629,7 +629,7 @@ public: me->RemoveAllAuras(); me->SetEntry(NPC_HARRISON_JONES_2); me->SetDisplayId(MODEL_HARRISON_JONES_2); - me->SetTarget(0); + me->SetTarget(); me->SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE, UNIT_STAND_STATE_DEAD); me->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); instance->SetData(DATA_GONGEVENT, DONE); @@ -659,14 +659,14 @@ public: _gongTimer = 4000; break; case GONG_EVENT_3: - if (GameObject* gong = me->GetMap()->GetGameObject(instance->GetData64(GO_STRANGE_GONG))) + if (GameObject* gong = me->GetMap()->GetGameObject(instance->GetGuidData(GO_STRANGE_GONG))) gong->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); _gongEvent = GONG_EVENT_4; _gongTimer = 105000; break; case GONG_EVENT_4: me->RemoveAura(SPELL_BANGING_THE_GONG); - if (GameObject* gong = me->GetMap()->GetGameObject(instance->GetData64(GO_STRANGE_GONG))) + if (GameObject* gong = me->GetMap()->GetGameObject(instance->GetGuidData(GO_STRANGE_GONG))) gong->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); // trigger or gong will need to be scripted to set IN_PROGRESS after enough hits. @@ -728,7 +728,7 @@ public: } } - if (GameObject* gate = me->GetMap()->GetGameObject(instance->GetData64(GO_MASSIVE_GATE))) + if (GameObject* gate = me->GetMap()->GetGameObject(instance->GetGuidData(GO_MASSIVE_GATE))) gate->SetGoState(GO_STATE_ACTIVE); _gongTimer = 2000; _gongEvent = GONG_EVENT_8; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp index 10cfead498..52c3f37297 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp @@ -142,7 +142,7 @@ public: void EnterEvadeMode() override { BossAI::EnterEvadeMode(); - if (GameObject* object = ObjectAccessor::GetGameObject(*me, instance->GetData64(GO_GONG_OF_BETHEKK))) + if (GameObject* object = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_GONG_OF_BETHEKK))) object->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); me->DespawnOrUnsummon(4000); } @@ -285,8 +285,8 @@ public: private: uint8 _summonCountA; uint8 _summonCountB; - uint64 _triggersSideAGUID[5]; - uint64 _triggersSideBGUID[5]; + ObjectGuid _triggersSideAGUID[5]; + ObjectGuid _triggersSideBGUID[5]; }; CreatureAI* GetAI(Creature* creature) const override @@ -335,7 +335,7 @@ public: DoCast(me, SPELL_SNEAK_RANK_1_1); DoCast(me, SPELL_SNEAK_RANK_1_2); - if (Unit* arlokk = ObjectAccessor::GetUnit(*me, _instance->GetData64(NPC_ARLOKK))) + if (Unit* arlokk = ObjectAccessor::GetUnit(*me, _instance->GetGuidData(NPC_ARLOKK))) me->GetMotionMaster()->MovePoint(0, arlokk->GetPositionX(), arlokk->GetPositionY(), arlokk->GetPositionZ()); _events.ScheduleEvent(EVENT_ATTACK, 6000); } @@ -355,7 +355,7 @@ public: void JustDied(Unit* /*killer*/) override { - if (Unit* arlokk = ObjectAccessor::GetUnit(*me, _instance->GetData64(NPC_ARLOKK))) + if (Unit* arlokk = ObjectAccessor::GetUnit(*me, _instance->GetGuidData(NPC_ARLOKK))) { if (arlokk->IsAlive()) arlokk->GetAI()->SetData(_sideData, 0); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp index 154691f309..a6f81d2d00 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp @@ -205,7 +205,7 @@ public: //Heal_Timer if (Heal_Timer <= diff) { - Unit* pJindo = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_JINDO)); + Unit* pJindo = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_JINDO)); if (pJindo) DoCast(pJindo, SPELL_HEAL); Heal_Timer = 3000; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp index a0c15a2087..aea2a14893 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp @@ -107,7 +107,7 @@ public: { killCount = 0; events.ScheduleEvent(EVENT_CHECK_START, 1000); - if (Creature* speaker = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_VILEBRANCH_SPEAKER))) + if (Creature* speaker = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_VILEBRANCH_SPEAKER))) if (!speaker->IsAlive()) speaker->Respawn(true); } @@ -157,7 +157,7 @@ public: if (++killCount == 3) { Talk(SAY_DING_KILL); - if (Creature* jindo = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_JINDO))) + if (Creature* jindo = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_JINDO))) if (jindo->IsAlive()) jindo->AI()->Talk(SAY_GRATS_JINDO); DoCast(me, SPELL_LEVEL_UP, true); @@ -261,7 +261,7 @@ public: private: uint8 killCount; - uint64 chainedSpirtGUIDs[CHAINED_SPIRT_COUNT]; + ObjectGuid chainedSpirtGUIDs[CHAINED_SPIRT_COUNT]; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp index 0eff6221dd..41818f32cc 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp @@ -160,7 +160,7 @@ public: if (instance->GetBossState(DATA_LORKHAN) == SPECIAL) { //Resurrect LorKhan - if (Unit* pLorKhan = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_LORKHAN))) + if (Unit* pLorKhan = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_LORKHAN))) { pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pLorKhan->setFaction(14); @@ -173,7 +173,7 @@ public: if (instance->GetBossState(DATA_ZATH) == SPECIAL) { //Resurrect Zath - if (Unit* pZath = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_ZATH))) + if (Unit* pZath = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_ZATH))) { pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pZath->setFaction(14); @@ -310,8 +310,8 @@ public: //Casting Greaterheal to Thekal or Zath if they are in meele range. if (GreaterHeal_Timer <= diff) { - Unit* pThekal = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THEKAL)); - Unit* pZath = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_ZATH)); + Unit* pThekal = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THEKAL)); + Unit* pZath = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_ZATH)); if (!pThekal || !pZath) return; @@ -346,7 +346,7 @@ public: if (instance->GetBossState(DATA_THEKAL) == SPECIAL) { //Resurrect Thekal - if (Unit* pThekal = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THEKAL))) + if (Unit* pThekal = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THEKAL))) { pThekal->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pThekal->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -358,7 +358,7 @@ public: if (instance->GetBossState(DATA_ZATH) == SPECIAL) { //Resurrect Zath - if (Unit* pZath = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_ZATH))) + if (Unit* pZath = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_ZATH))) { pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -499,7 +499,7 @@ public: if (instance->GetBossState(DATA_LORKHAN) == SPECIAL) { //Resurrect LorKhan - if (Unit* pLorKhan = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_LORKHAN))) + if (Unit* pLorKhan = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_LORKHAN))) { pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -511,7 +511,7 @@ public: if (instance->GetBossState(DATA_THEKAL) == SPECIAL) { //Resurrect Thekal - if (Unit* pThekal = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THEKAL))) + if (Unit* pThekal = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THEKAL))) { pThekal->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pThekal->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp index 3b48e4b1d3..0fc45403c4 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp @@ -34,17 +34,6 @@ public: LoadDoorData(doorData); } - void Initialize() override - { - _zealotLorkhanGUID = 0; - _zealotZathGUID = 0; - _highPriestTekalGUID = 0; - _jindoTheHexxerGUID = 0; - _vilebranchSpeakerGUID = 0; - _arlokkGUID = 0; - _goGongOfBethekkGUID = 0; - } - bool IsEncounterInProgress() const override { // not active in Zul'Gurub @@ -107,7 +96,7 @@ public: } } - uint64 GetData64(uint32 uiData) const override + ObjectGuid GetGuidData(uint32 uiData) const override { switch (uiData) { @@ -130,7 +119,8 @@ public: return _goGongOfBethekkGUID; break; } - return 0; + + return ObjectGuid::Empty; } std::string GetSaveData() override @@ -179,13 +169,13 @@ public: //If all High Priest bosses were killed. Lorkhan, Zath and Ohgan are added too. //Storing Lorkhan, Zath and Thekal because we need to cast on them later. Jindo is needed for healfunction too. - uint64 _zealotLorkhanGUID; - uint64 _zealotZathGUID; - uint64 _highPriestTekalGUID; - uint64 _jindoTheHexxerGUID; - uint64 _vilebranchSpeakerGUID; - uint64 _arlokkGUID; - uint64 _goGongOfBethekkGUID; + ObjectGuid _zealotLorkhanGUID; + ObjectGuid _zealotZathGUID; + ObjectGuid _highPriestTekalGUID; + ObjectGuid _jindoTheHexxerGUID; + ObjectGuid _vilebranchSpeakerGUID; + ObjectGuid _arlokkGUID; + ObjectGuid _goGongOfBethekkGUID; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp b/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp index 379a85426a..34979a0a1f 100644 --- a/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp @@ -74,7 +74,7 @@ public: SummonList summons; EventMap events; - uint64 _playerGUID; + ObjectGuid _playerGUID; uint8 _counter; uint8 _savedCount; uint8 _deathCount; @@ -88,7 +88,7 @@ public: _savedCount = 0; _deathCount = 0; _counter = 0; - _playerGUID = 0; + _playerGUID.Clear(); events.Reset(); summons.DespawnAll(); me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER); @@ -99,7 +99,7 @@ public: _faction = faction; } - void SetGUID(uint64 guid, int32) override + void SetGUID(ObjectGuid guid, int32) override { _playerGUID = guid; me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); @@ -242,7 +242,7 @@ public: struct npc_balance_of_light_and_shadowAI : public NullCreatureAI { - npc_balance_of_light_and_shadowAI(Creature* creature) : NullCreatureAI(creature) { timer = 0; _targetGUID = 0; } + npc_balance_of_light_and_shadowAI(Creature* creature) : NullCreatureAI(creature) { timer = 0; _targetGUID.Clear(); } bool CanBeSeen(Player const* player) override { @@ -251,7 +251,7 @@ public: } uint32 timer; - uint64 _targetGUID; + ObjectGuid _targetGUID; void SpellHit(Unit*, const SpellInfo* spellInfo) override { diff --git a/src/server/scripts/EasternKingdoms/zone_isle_of_queldanas.cpp b/src/server/scripts/EasternKingdoms/zone_isle_of_queldanas.cpp index aef7740235..8adb22ebad 100644 --- a/src/server/scripts/EasternKingdoms/zone_isle_of_queldanas.cpp +++ b/src/server/scripts/EasternKingdoms/zone_isle_of_queldanas.cpp @@ -122,8 +122,8 @@ public: EventMap events; SummonList summons; - uint64 playerGUID; - uint64 morlenGUID; + ObjectGuid playerGUID; + ObjectGuid morlenGUID; void Reset() override { @@ -131,8 +131,8 @@ public: me->SetRegeneratingHealth(true); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); me->SetStandState(UNIT_STAND_STATE_STAND); - playerGUID = 0; - morlenGUID = 0; + playerGUID.Clear(); + morlenGUID.Clear(); summons.DespawnAll(); if (Creature* c = me->FindNearestCreature(NPC_THALORIEN_REMAINS, 100.0f, true)) c->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); @@ -378,7 +378,7 @@ public: break; case EVENT_OUTRO_KNEEL: if (Player* p = ObjectAccessor::GetPlayer(*me, playerGUID)) - p->KilledMonsterCredit(NPC_THALORIEN_KILL_CREDIT, 0); + p->KilledMonsterCredit(NPC_THALORIEN_KILL_CREDIT); me->SetStandState(UNIT_STAND_STATE_KNEEL); events.ScheduleEvent(EVENT_DISAPPEAR, 6000); break; @@ -492,13 +492,13 @@ public: npc_grand_magister_rommathAI(Creature* c) : NullCreatureAI(c) { announced = false; - playerGUID = 0; + playerGUID.Clear(); me->SetReactState(REACT_AGGRESSIVE); } EventMap events; bool announced; - uint64 playerGUID; + ObjectGuid playerGUID; void MoveInLineOfSight(Unit* who) override { diff --git a/src/server/scripts/EasternKingdoms/zone_silverpine_forest.cpp b/src/server/scripts/EasternKingdoms/zone_silverpine_forest.cpp index 08622c54b2..2f306afca9 100644 --- a/src/server/scripts/EasternKingdoms/zone_silverpine_forest.cpp +++ b/src/server/scripts/EasternKingdoms/zone_silverpine_forest.cpp @@ -184,7 +184,7 @@ public: uint32 Phase; int8 KillCount; uint32 WaitTimer; - uint64 PlayerGUID; + ObjectGuid PlayerGUID; SummonList Summons; bool QuestInProgress; @@ -197,7 +197,7 @@ public: { Phase = 0; KillCount = 0; - PlayerGUID = 0; + PlayerGUID.Clear(); Summons.DespawnAll(); } } diff --git a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp index 811db7f352..a1a04a1d68 100644 --- a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp +++ b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp @@ -135,14 +135,14 @@ public: uint32 uiTimer; uint32 uiPhase; - uint64 MarzonGUID; + ObjectGuid MarzonGUID; void Reset() override { uiTimer = 0; uiPhase = 0; - MarzonGUID = 0; + MarzonGUID.Clear(); } void EnterEvadeMode() override diff --git a/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp b/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp index 5823e0f1a4..410885da30 100644 --- a/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp +++ b/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp @@ -34,7 +34,7 @@ public: { npc_galen_goodwardAI(Creature* creature) : npc_escortAI(creature) { - galensCageGUID = 0; + galensCageGUID.Clear(); Reset(); } @@ -123,7 +123,7 @@ public: } private: - uint64 galensCageGUID; + ObjectGuid galensCageGUID; uint32 periodicSay; }; diff --git a/src/server/scripts/EasternKingdoms/zone_tirisfal_glades.cpp b/src/server/scripts/EasternKingdoms/zone_tirisfal_glades.cpp index ac98c6fe90..2f405760dc 100644 --- a/src/server/scripts/EasternKingdoms/zone_tirisfal_glades.cpp +++ b/src/server/scripts/EasternKingdoms/zone_tirisfal_glades.cpp @@ -60,13 +60,13 @@ public: uint32 m_uiPhase; uint32 m_uiPhaseTimer; - uint64 m_uiPlayerGUID; + ObjectGuid m_uiPlayerGUID; void Reset() override { m_uiPhase = 0; m_uiPhaseTimer = 5000; - m_uiPlayerGUID = 0; + m_uiPlayerGUID.Clear(); me->RestoreFaction(); diff --git a/src/server/scripts/EasternKingdoms/zone_undercity.cpp b/src/server/scripts/EasternKingdoms/zone_undercity.cpp index 9b0cb57f63..260529afb3 100644 --- a/src/server/scripts/EasternKingdoms/zone_undercity.cpp +++ b/src/server/scripts/EasternKingdoms/zone_undercity.cpp @@ -106,8 +106,7 @@ public: void Reset() override { LamentEvent = false; - targetGUID = 0; - playerGUID = 0; + playerGUID.Clear(); _events.Reset(); } @@ -120,7 +119,7 @@ public: _events.ScheduleEvent(EVENT_MULTI_SHOT, 10000); } - void SetGUID(uint64 guid, int32 type) override + void SetGUID(ObjectGuid guid, int32 type) override { if (type == GUID_EVENT_INVOKER) { @@ -223,8 +222,7 @@ public: private: EventMap _events; bool LamentEvent; - uint64 targetGUID; - uint64 playerGUID; + ObjectGuid playerGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -951,7 +949,7 @@ public: if (Creature* jaina = GetClosestCreatureWithEntry(creature, NPC_JAINA, 50.0f)) ai->jainaGUID = jaina->GetGUID(); else - ai->jainaGUID = 0; + ai->jainaGUID.Clear(); ai->SetDespawnAtEnd(false); ai->SetDespawnAtFar(false); } @@ -979,9 +977,6 @@ public: { npc_varian_wrynnAI(Creature* creature) : npc_escortAI(creature) { - memset(generatorGUID, 0, sizeof(generatorGUID)); - memset(allianceForcesGUID, 0, sizeof(allianceForcesGUID)); - memset(hordeForcesGUID, 0, sizeof(hordeForcesGUID)); allianceGuardsGUID.clear(); } @@ -993,17 +988,17 @@ public: uint32 whirlwindTimer; - uint64 jainaGUID; - uint64 putressGUID; - uint64 blightWormGUID; - uint64 khanokGUID; - uint64 thrallGUID; - uint64 sylvanasGUID; + ObjectGuid jainaGUID; + ObjectGuid putressGUID; + ObjectGuid blightWormGUID; + ObjectGuid khanokGUID; + ObjectGuid thrallGUID; + ObjectGuid sylvanasGUID; - uint64 generatorGUID[GENERATOR_MAXCOUNT]; - uint64 allianceForcesGUID[ALLIANCE_FORCE_MAXCOUNT]; - uint64 hordeForcesGUID[HORDE_FORCE_MAXCOUNT]; - std::vector<uint64> allianceGuardsGUID; + ObjectGuid generatorGUID[GENERATOR_MAXCOUNT]; + ObjectGuid allianceForcesGUID[ALLIANCE_FORCE_MAXCOUNT]; + ObjectGuid hordeForcesGUID[HORDE_FORCE_MAXCOUNT]; + GuidVector allianceGuardsGUID; EventMap _events; @@ -1036,7 +1031,7 @@ public: bStepping = false; step = 0; phaseTimer = 0; - jainaGUID = 0; + jainaGUID.Clear(); _events.ScheduleEvent(EVENT_WHIRLWIND, 5 * IN_MILLISECONDS); _events.ScheduleEvent(EVENT_HEROIC_LEAP, 10 * IN_MILLISECONDS); _events.ScheduleEvent(EVENT_AGGRO_JAINA, 2 * IN_MILLISECONDS); @@ -1046,38 +1041,38 @@ public: if (Creature* putress = ObjectAccessor::GetCreature(*me, putressGUID)) { putress->DespawnOrUnsummon(); - putressGUID = 0; + putressGUID.Clear(); } if (Creature* blightWorm = ObjectAccessor::GetCreature(*me, blightWormGUID)) { blightWorm->DespawnOrUnsummon(); - blightWormGUID = 0; + blightWormGUID.Clear(); } if (Creature* khanok = ObjectAccessor::GetCreature(*me, khanokGUID)) { khanok->DespawnOrUnsummon(); - khanokGUID = 0; + khanokGUID.Clear(); } if (Creature* thrall = ObjectAccessor::GetCreature(*me, thrallGUID)) { thrall->DespawnOrUnsummon(); - thrallGUID = 0; + thrallGUID.Clear(); } if (Creature* sylvanas = ObjectAccessor::GetCreature(*me, sylvanasGUID)) { sylvanas->DespawnOrUnsummon(); - sylvanasGUID = 0; + sylvanasGUID.Clear(); } for (uint8 i = 0; i < GENERATOR_MAXCOUNT; ++i) { if (Creature* temp = ObjectAccessor::GetCreature(*me, generatorGUID[i])) { - generatorGUID[i] = 0; + generatorGUID[i].Clear(); temp->DespawnOrUnsummon(); } } @@ -1086,13 +1081,13 @@ public: { if (Creature* temp = ObjectAccessor::GetCreature(*me, allianceForcesGUID[i])) { - allianceForcesGUID[i] = 0; + allianceForcesGUID[i].Clear(); temp->DespawnOrUnsummon(); } } - for (std::vector<uint64>::const_iterator i = allianceGuardsGUID.begin(); i != allianceGuardsGUID.end(); ++i) - if (Creature* temp = ObjectAccessor::GetCreature(*me, *i)) + for (ObjectGuid const guid : allianceGuardsGUID) + if (Creature* temp = ObjectAccessor::GetCreature(*me, guid)) temp->DespawnOrUnsummon(); allianceGuardsGUID.clear(); @@ -1101,7 +1096,7 @@ public: { if (Creature* temp = ObjectAccessor::GetCreature(*me, hordeForcesGUID[i])) { - hordeForcesGUID[i] = 0; + hordeForcesGUID[i].Clear(); temp->DespawnOrUnsummon(); } } @@ -2291,7 +2286,7 @@ public: thrall_ai->SetDespawnAtFar(false); } else - thrall_ai->sylvanasfollowGUID = 0; + thrall_ai->sylvanasfollowGUID.Clear(); } break; } @@ -2329,7 +2324,6 @@ public: { npc_thrall_bfuAI(Creature* creature) : npc_escortAI(creature) { - memset(allianceForcesGUID, 0, sizeof(allianceForcesGUID)); hordeGuardsGUID.clear(); } @@ -2339,14 +2333,14 @@ public: uint32 step; uint32 phaseTimer; - uint64 sylvanasfollowGUID; - uint64 allianceForcesGUID[ALLIANCE_FORCE_MAXCOUNT]; - uint64 ValimathrasGUID; - uint64 ValimathrasPortalGUID; - uint64 WrynnGUID; - uint64 JainaGUID; - uint64 SaurfangGUID; - std::vector<uint64> hordeGuardsGUID; + ObjectGuid sylvanasfollowGUID; + ObjectGuid allianceForcesGUID[ALLIANCE_FORCE_MAXCOUNT]; + ObjectGuid ValimathrasGUID; + ObjectGuid ValimathrasPortalGUID; + ObjectGuid WrynnGUID; + ObjectGuid JainaGUID; + ObjectGuid SaurfangGUID; + GuidVector hordeGuardsGUID; EventMap _events; @@ -2384,7 +2378,7 @@ public: EnableAttack = false; step = 0; phaseTimer = 0; - sylvanasfollowGUID = 0; + sylvanasfollowGUID.Clear(); _events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, 3 * IN_MILLISECONDS); _events.ScheduleEvent(EVENT_LAVA_BURST, 5 * IN_MILLISECONDS); _events.ScheduleEvent(EVENT_THUNDER, 8 * IN_MILLISECONDS); @@ -2394,35 +2388,35 @@ public: if (Creature* valimathras = ObjectAccessor::GetCreature(*me, ValimathrasGUID)) { valimathras->DespawnOrUnsummon(); - ValimathrasGUID = 0; + ValimathrasGUID.Clear(); } if (Creature* valimathrasportal = ObjectAccessor::GetCreature(*me, ValimathrasPortalGUID)) { valimathrasportal->DespawnOrUnsummon(); - ValimathrasPortalGUID = 0; + ValimathrasPortalGUID.Clear(); } if (Creature* wrynn = ObjectAccessor::GetCreature(*me, WrynnGUID)) { wrynn->DespawnOrUnsummon(); - WrynnGUID = 0; + WrynnGUID.Clear(); } if (Creature* jaina = ObjectAccessor::GetCreature(*me, JainaGUID)) { jaina->DespawnOrUnsummon(); - JainaGUID = 0; + JainaGUID.Clear(); } if (Creature* saurfang = ObjectAccessor::GetCreature(*me, SaurfangGUID)) { saurfang->DespawnOrUnsummon(); - SaurfangGUID = 0; + SaurfangGUID.Clear(); } - for (std::vector<uint64>::const_iterator i = hordeGuardsGUID.begin(); i != hordeGuardsGUID.end(); ++i) - if (Creature* temp = ObjectAccessor::GetCreature(*me, *i)) + for (ObjectGuid const guid : hordeGuardsGUID) + if (Creature* temp = ObjectAccessor::GetCreature(*me, guid)) temp->DespawnOrUnsummon(); hordeGuardsGUID.clear(); diff --git a/src/server/scripts/Events/brewfest.cpp b/src/server/scripts/Events/brewfest.cpp index f98b1fc544..2f4a092c96 100644 --- a/src/server/scripts/Events/brewfest.cpp +++ b/src/server/scripts/Events/brewfest.cpp @@ -421,7 +421,7 @@ public: Player* player = who->ToPlayer(); if (player->HasItemCount(ITEM_PORTABLE_BREWFEST_KEG)) // portable brewfest keg { - player->KilledMonsterCredit(KEG_KILL_CREDIT, 0); + player->KilledMonsterCredit(KEG_KILL_CREDIT); player->CastSpell(me, SPELL_THROW_KEG, true); // throw keg player->DestroyItemCount(ITEM_PORTABLE_BREWFEST_KEG, 1, true); @@ -539,7 +539,7 @@ public: QuestStatusData& q_status = itr->second; if (q_status.CreatureOrGOCount[me->GetEntry() - 24202] == 0) { - player->KilledMonsterCredit(me->GetEntry(), 0); + player->KilledMonsterCredit(me->GetEntry()); player->MonsterSay(GetTextFor(me->GetEntry(), quest).c_str(), LANG_UNIVERSAL, player); } } @@ -949,7 +949,7 @@ public: } uint32 timer; - uint64 targetGUID; + ObjectGuid targetGUID; void EnterCombat(Unit*) override {} void MoveInLineOfSight(Unit*) override {} void AttackStart(Unit*) override {} @@ -1004,7 +1004,7 @@ public: void Reset() override { timer = 0; - targetGUID = 0; + targetGUID.Clear(); me->SetWalk(true); FindNextKeg(); me->ApplySpellImmune(SPELL_ATTACK_KEG, IMMUNITY_ID, SPELL_ATTACK_KEG, true); @@ -1225,7 +1225,7 @@ public: privateLevel++; } else if (questTick++ > 3) - caster->ToPlayer()->KilledMonsterCredit(CREDIT_TROT, 0); + caster->ToPlayer()->KilledMonsterCredit(CREDIT_TROT); break; case 2: // Two - three clicks to maintains speed, less to decrease, more to increase @@ -1242,7 +1242,7 @@ public: questTick = 0; } else if (questTick++ > 3) - caster->ToPlayer()->KilledMonsterCredit(CREDIT_CANTER, 0); + caster->ToPlayer()->KilledMonsterCredit(CREDIT_CANTER); break; case 3: // Four or more clicks to maintains speed, less to decrease @@ -1253,7 +1253,7 @@ public: questTick = 0; } else if (questTick++ > 3) - caster->ToPlayer()->KilledMonsterCredit(CREDIT_GALLOP, 0); + caster->ToPlayer()->KilledMonsterCredit(CREDIT_GALLOP); break; } @@ -1463,7 +1463,7 @@ public: { player->DestroyItemCount(itemCaster->GetEntry(), 1, true); GetSpell()->m_CastItem = nullptr; - GetSpell()->m_castItemGUID = 0; + GetSpell()->m_castItemGUID.Clear(); } } } @@ -1530,7 +1530,7 @@ public: { player->DestroyItemCount(itemCaster->GetEntry(), 1, true); GetSpell()->m_CastItem = nullptr; - GetSpell()->m_castItemGUID = 0; + GetSpell()->m_castItemGUID.Clear(); } } } diff --git a/src/server/scripts/Events/childrens_week.cpp b/src/server/scripts/Events/childrens_week.cpp index 765079bf8a..37da2aa272 100644 --- a/src/server/scripts/Events/childrens_week.cpp +++ b/src/server/scripts/Events/childrens_week.cpp @@ -120,13 +120,13 @@ enum Misc DISPLAY_INVISIBLE = 11686, }; -uint64 getOrphanGUID(Player* player, uint32 orphan) +ObjectGuid getOrphanGUID(Player* player, uint32 orphan) { if (Aura* orphanOut = player->GetAura(SPELL_ORPHAN_OUT)) if (orphanOut->GetCaster() && orphanOut->GetCaster()->GetEntry() == orphan) return orphanOut->GetCaster()->GetGUID(); - return 0; + return ObjectGuid::Empty; } /*###### @@ -145,8 +145,8 @@ public: { timer = 0; phase = 0; - playerGUID = 0; - orphanGUID = 0; + playerGUID.Clear(); + orphanGUID.Clear(); } void MoveInLineOfSight(Unit* who) override @@ -216,8 +216,8 @@ public: private: uint32 timer; int8 phase; - uint64 playerGUID; - uint64 orphanGUID; + ObjectGuid playerGUID; + ObjectGuid orphanGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -242,8 +242,8 @@ public: { timer = 0; phase = 0; - playerGUID = 0; - orphanGUID = 0; + playerGUID.Clear(); + orphanGUID.Clear(); } void MoveInLineOfSight(Unit* who) override @@ -313,8 +313,8 @@ public: private: uint32 timer; int8 phase; - uint64 playerGUID; - uint64 orphanGUID; + ObjectGuid playerGUID; + ObjectGuid orphanGUID; }; CreatureAI* GetAI(Creature* pCreature) const override @@ -342,8 +342,8 @@ public: { timer = 1000; phase = 0; - playerGUID = 0; - orphanGUID = 0; + playerGUID.Clear(); + orphanGUID.Clear(); } void MoveInLineOfSight(Unit* who) override @@ -401,8 +401,8 @@ public: private: uint32 timer; uint8 phase; - uint64 playerGUID; - uint64 orphanGUID; + ObjectGuid playerGUID; + ObjectGuid orphanGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -427,8 +427,8 @@ public: { timer = 0; phase = 0; - playerGUID = 0; - orphanGUID = 0; + playerGUID.Clear(); + orphanGUID.Clear(); } void MoveInLineOfSight(Unit* who) override @@ -488,8 +488,8 @@ public: private: uint32 timer; int8 phase; - uint64 playerGUID; - uint64 orphanGUID; + ObjectGuid playerGUID; + ObjectGuid orphanGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -514,8 +514,8 @@ public: { timer = 0; phase = 0; - playerGUID = 0; - orphanGUID = 0; + playerGUID.Clear(); + orphanGUID.Clear(); } void MoveInLineOfSight(Unit* who) override @@ -574,8 +574,8 @@ public: private: uint32 timer; int8 phase; - uint64 playerGUID; - uint64 orphanGUID; + ObjectGuid playerGUID; + ObjectGuid orphanGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -601,8 +601,8 @@ public: { timer = 0; phase = 0; - playerGUID = 0; - orphanGUID = 0; + playerGUID.Clear(); + orphanGUID.Clear(); } void MoveInLineOfSight(Unit* who) override @@ -669,8 +669,8 @@ public: private: uint32 timer; int8 phase; - uint64 playerGUID; - uint64 orphanGUID; + ObjectGuid playerGUID; + ObjectGuid orphanGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -695,8 +695,8 @@ public: { timer = 0; phase = 0; - playerGUID = 0; - orphanGUID = 0; + playerGUID.Clear(); + orphanGUID.Clear(); } void SetData(uint32 type, uint32 data) override @@ -828,8 +828,8 @@ public: private: int8 phase; uint32 timer; - uint64 playerGUID; - uint64 orphanGUID; + ObjectGuid playerGUID; + ObjectGuid orphanGUID; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Events/hallows_end.cpp b/src/server/scripts/Events/hallows_end.cpp index 822f20092a..ffe2f1b03a 100644 --- a/src/server/scripts/Events/hallows_end.cpp +++ b/src/server/scripts/Events/hallows_end.cpp @@ -368,13 +368,13 @@ public: uint32 eventStarted; bool allowQuest; - uint64 horseGUID; + ObjectGuid horseGUID; void Reset() override { eventStarted = 0; allowQuest = false; - horseGUID = 0; + horseGUID.Clear(); } void GetInitXYZ(float& x, float& y, float& z, float& o, uint32& path) @@ -606,7 +606,7 @@ public: bool Unmount; EventMap events; uint32 counter; - std::list<uint64> unitList; + GuidList unitList; int32 pos; void EnterCombat(Unit*) override {} void MoveInLineOfSight(Unit* /*who*/) override {} @@ -699,8 +699,8 @@ public: if (counter > 12) { bool failed = false; - for (std::list<uint64>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr) - if (Unit* c = ObjectAccessor::GetUnit(*me, *itr)) + for (ObjectGuid const guid : unitList) + if (Unit* c = ObjectAccessor::GetUnit(*me, guid)) if (c->HasAuraType(SPELL_AURA_PERIODIC_DUMMY)) { failed = true; @@ -753,8 +753,8 @@ public: Unit* getTrigger() { std::list<Unit*> tmpList; - for (std::list<uint64>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr) - if (Unit* c = ObjectAccessor::GetUnit(*me, *itr)) + for (ObjectGuid const guid : unitList) + if (Unit* c = ObjectAccessor::GetUnit(*me, guid)) if (!c->HasAuraType(SPELL_AURA_PERIODIC_DUMMY)) tmpList.push_back(c); @@ -772,8 +772,8 @@ public: { me->MonsterYell("Fire consumes! You've tried and failed. Let there be no doubt, justice prevailed!", LANG_UNIVERSAL, 0); me->PlayDirectSound(11967); - for (std::list<uint64>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr) - if (Unit* c = ObjectAccessor::GetUnit(*me, *itr)) + for (ObjectGuid const guid : unitList) + if (Unit* c = ObjectAccessor::GetUnit(*me, guid)) c->RemoveAllAuras(); me->DespawnOrUnsummon(1); @@ -867,7 +867,7 @@ public: else me->RemoveAllAuras(); - caster->ToPlayer()->KilledMonsterCredit(me->GetEntry(), 0); + caster->ToPlayer()->KilledMonsterCredit(me->GetEntry()); } } } @@ -954,7 +954,7 @@ public: EventMap events; SummonList summons; - uint64 playerGUID; + ObjectGuid playerGUID; uint8 talkCount; bool inFight; uint8 phase; @@ -1079,7 +1079,7 @@ public: { events.Reset(); summons.DespawnAll(); - playerGUID = 0; + playerGUID.Clear(); talkCount = 0; phase = 0; inFight = false; diff --git a/src/server/scripts/Events/love_in_air.cpp b/src/server/scripts/Events/love_in_air.cpp index 5643c00651..2f9aa83bb9 100644 --- a/src/server/scripts/Events/love_in_air.cpp +++ b/src/server/scripts/Events/love_in_air.cpp @@ -571,7 +571,7 @@ public: void PeriodicTick(AuraEffect const* /*aurEff*/) { - uint64 guid = (GetCaster() ? GetCaster()->GetGUID() : 0); + ObjectGuid guid = GetCaster() ? GetCaster()->GetGUID() : ObjectGuid::Empty; if (Unit* target = GetTarget()) { uint32 spellId = (GetId() == SPELL_THROW_COLOGNE ? 68934 : 68927); diff --git a/src/server/scripts/Events/midsummer.cpp b/src/server/scripts/Events/midsummer.cpp index c7c6197de3..53c0f2b362 100644 --- a/src/server/scripts/Events/midsummer.cpp +++ b/src/server/scripts/Events/midsummer.cpp @@ -40,7 +40,7 @@ public: npc_midsummer_bonfireAI(Creature* c) : ScriptedAI(c) { me->IsAIEnabled = true; - goGUID = 0; + goGUID.Clear(); if (GameObject* go = me->SummonGameObject(GO_MIDSUMMER_BONFIRE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0)) { goGUID = go->GetGUID(); @@ -48,7 +48,7 @@ public: } } - uint64 goGUID; + ObjectGuid goGUID; void SpellHit(Unit*, SpellInfo const* spellInfo) override { @@ -90,20 +90,20 @@ public: teleTimer = 0; startTimer = 1; posVec.clear(); - playerGUID = 0; + playerGUID.Clear(); me->CastSpell(me, 43313, true); counter = 0; maxCount = 0; } - uint64 playerGUID; + ObjectGuid playerGUID; uint32 startTimer; uint32 teleTimer; std::vector<Position> posVec; uint8 counter; uint8 maxCount; - void SetPlayerGUID(uint64 guid, uint8 cnt) + void SetPlayerGUID(ObjectGuid guid, uint8 cnt) { playerGUID = guid; maxCount = cnt; @@ -330,11 +330,11 @@ public: bool Load() override { - torchGUID = 0; + torchGUID.Clear(); return true; } - uint64 torchGUID; + ObjectGuid torchGUID; void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { diff --git a/src/server/scripts/Events/pilgrims_bounty.cpp b/src/server/scripts/Events/pilgrims_bounty.cpp index 0d39807fcd..11a1eeeee4 100644 --- a/src/server/scripts/Events/pilgrims_bounty.cpp +++ b/src/server/scripts/Events/pilgrims_bounty.cpp @@ -96,7 +96,7 @@ public: { npc_pilgrims_bounty_chairAI(Creature* creature) : VehicleAI(creature) { - plateGUID = 0; + plateGUID.Clear(); timerSpawnPlate = 1; timerRotateChair = 0; me->SetReactState(REACT_PASSIVE); @@ -111,7 +111,7 @@ public: who->ToPlayer()->SetClientControl(me, 0, true); } - uint64 plateGUID; + ObjectGuid plateGUID; uint32 timerSpawnPlate; uint32 timerRotateChair; diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp index e99cd664e7..a7da8c952a 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp @@ -23,7 +23,6 @@ public: void Initialize() override { memset(&_encounters, 0, sizeof(_encounters)); - _akumaiPortalGUID = 0; _requiredDeaths = 0; } @@ -69,7 +68,7 @@ public: break; case GO_AKU_MAI_DOOR: if (_encounters[TYPE_FIRE1] == DONE && _encounters[TYPE_FIRE2] == DONE && _encounters[TYPE_FIRE3] == DONE && _encounters[TYPE_FIRE4] == DONE) - HandleGameObject(0, true, gameobject); + HandleGameObject(ObjectGuid::Empty, true, gameobject); _akumaiPortalGUID = gameobject->GetGUID(); break; } @@ -121,7 +120,7 @@ public: private: uint32 _encounters[MAX_ENCOUNTERS]; - uint64 _akumaiPortalGUID; + ObjectGuid _akumaiPortalGUID; uint8 _requiredDeaths; }; }; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp index ff75f1d1d1..d6ac85d8de 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp @@ -83,7 +83,7 @@ public: { if (waypointId == 7) { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_JAINAPROUDMOORE)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_JAINAPROUDMOORE)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } @@ -178,12 +178,12 @@ public: npc_towering_infernalAI(Creature* creature) : ScriptedAI(creature) { instance = creature->GetInstanceScript(); - AnetheronGUID = instance->GetData64(DATA_ANETHERON); + AnetheronGUID = instance->GetGuidData(DATA_ANETHERON); } uint32 ImmolationTimer; uint32 CheckTimer; - uint64 AnetheronGUID; + ObjectGuid AnetheronGUID; InstanceScript* instance; void Reset() override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp index 68cb15280b..6ad76ed0d9 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp @@ -101,18 +101,18 @@ public: npc_ancient_wispAI(Creature* creature) : ScriptedAI(creature) { instance = creature->GetInstanceScript(); - ArchimondeGUID = 0; + ArchimondeGUID.Clear(); } InstanceScript* instance; - uint64 ArchimondeGUID; + ObjectGuid ArchimondeGUID; uint32 CheckTimer; void Reset() override { CheckTimer = 1000; - ArchimondeGUID = instance->GetData64(DATA_ARCHIMONDE); + ArchimondeGUID = instance->GetGuidData(DATA_ARCHIMONDE); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } @@ -187,12 +187,12 @@ public: { npc_doomfire_targettingAI(Creature* creature) : ScriptedAI(creature) { } - uint64 TargetGUID; + ObjectGuid TargetGUID; uint32 ChangeTargetTimer; void Reset() override { - TargetGUID = 0; + TargetGUID.Clear(); ChangeTargetTimer = 5000; } @@ -219,7 +219,7 @@ public: if (Unit* temp = ObjectAccessor::GetUnit(*me, TargetGUID)) { me->GetMotionMaster()->MoveFollow(temp, 0.0f, 0.0f); - TargetGUID = 0; + TargetGUID.Clear(); } else { @@ -264,8 +264,8 @@ public: InstanceScript* instance; EventMap events; - uint64 DoomfireSpiritGUID; - uint64 WorldTreeGUID; + ObjectGuid DoomfireSpiritGUID; + ObjectGuid WorldTreeGUID; uint8 SoulChargeCount; uint8 WispCount; @@ -283,8 +283,8 @@ public: { instance->SetData(DATA_ARCHIMONDEEVENT, NOT_STARTED); - DoomfireSpiritGUID = 0; - WorldTreeGUID = 0; + DoomfireSpiritGUID.Clear(); + WorldTreeGUID.Clear(); WispCount = 0; Enraged = false; BelowTenPercent = false; @@ -472,7 +472,7 @@ public: if (Unit* DoomfireSpirit = ObjectAccessor::GetUnit(*me, DoomfireSpiritGUID)) { summoned->GetMotionMaster()->MoveFollow(DoomfireSpirit, 0.0f, 0.0f); - DoomfireSpiritGUID = 0; + DoomfireSpiritGUID.Clear(); } } } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp index d44ad587a6..c9a67b423f 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp @@ -88,7 +88,7 @@ public: { if (waypointId == 7 && instance) { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } @@ -185,13 +185,13 @@ public: npc_lesser_doomguardAI(Creature* creature) : hyjal_trashAI(creature) { instance = creature->GetInstanceScript(); - AzgalorGUID = instance->GetData64(DATA_AZGALOR); + AzgalorGUID = instance->GetGuidData(DATA_AZGALOR); } uint32 CrippleTimer; uint32 WarstompTimer; uint32 CheckTimer; - uint64 AzgalorGUID; + ObjectGuid AzgalorGUID; InstanceScript* instance; void Reset() override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp index 5df7a0a468..1dbecc951d 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp @@ -83,7 +83,7 @@ public: { if (waypointId == 7 && instance) { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp index bc6be3e030..2e5f9e09bb 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp @@ -78,7 +78,7 @@ public: { if (waypointId == 7 && instance) { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_JAINAPROUDMOORE)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_JAINAPROUDMOORE)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp index 7b2ea96d51..d9affeb28a 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp @@ -308,8 +308,6 @@ hyjalAI::hyjalAI(Creature* creature) : npc_escortAI(creature), Summons(me) instance = creature->GetInstanceScript(); VeinsSpawned[0] = false; VeinsSpawned[1] = false; - for (uint8 i = 0; i < 14; ++i) - VeinGUID[i] = 0; InfernalCount = 0; TeleportTimer = 1000; Overrun = false; @@ -340,9 +338,9 @@ void hyjalAI::Reset() IsDummy = false; me->setActive(true); // GUIDs - PlayerGUID = 0; - BossGUID[0] = 0; - BossGUID[1] = 0; + PlayerGUID.Clear(); + BossGUID[0].Clear(); + BossGUID[1].Clear(); // Timers NextWaveTimer = 10000; @@ -656,7 +654,7 @@ void hyjalAI::DeSpawnVeins() { if (Faction == 1) { - Creature* unit = ObjectAccessor::GetCreature((*me), instance->GetData64(DATA_JAINAPROUDMOORE)); + Creature* unit = ObjectAccessor::GetCreature((*me), instance->GetGuidData(DATA_JAINAPROUDMOORE)); if (!unit)return; hyjalAI* ai = CAST_AI(hyjalAI, unit->AI()); if (!ai)return; @@ -668,7 +666,7 @@ void hyjalAI::DeSpawnVeins() } else if (Faction) { - Creature* unit = ObjectAccessor::GetCreature((*me), instance->GetData64(DATA_THRALL)); + Creature* unit = ObjectAccessor::GetCreature((*me), instance->GetGuidData(DATA_THRALL)); if (!unit)return; hyjalAI* ai = CAST_AI(hyjalAI, unit->AI()); if (!ai)return; @@ -816,7 +814,7 @@ void hyjalAI::UpdateAI(uint32 diff) EventBegun = false; CheckTimer = 0; me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - BossGUID[i] = 0; + BossGUID[i].Clear(); instance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0); // Reset world state for enemies to disable it } } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.h b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.h index 57366f9c74..ffbf19d745 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.h +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.h @@ -148,9 +148,9 @@ struct hyjalAI : public npc_escortAI public: InstanceScript* instance; - uint64 PlayerGUID; - uint64 BossGUID[2]; - uint64 VeinGUID[14]; + ObjectGuid PlayerGUID; + ObjectGuid BossGUID[2]; + ObjectGuid VeinGUID[14]; uint32 NextWaveTimer; uint32 WaveCount; @@ -181,7 +181,7 @@ public: bool IsDummy; uint32 MassTeleportTimer; bool DoMassTeleport; - uint64 DummyGuid; + ObjectGuid DummyGuid; struct Spell { @@ -192,6 +192,6 @@ public: private: uint32 SpellTimer[3]; - //std::list<uint64> CreatureList; + //GuidList CreatureList; }; #endif diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp index 25b8f025dd..d5ccdbddcf 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp @@ -435,7 +435,7 @@ public: { if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } @@ -478,7 +478,7 @@ public: CanMove = true; if (instance->GetData(DATA_ALLIANCE_RETREAT) && !instance->GetData(DATA_HORDE_RETREAT)) { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } @@ -559,13 +559,13 @@ public: { if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } else { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_JAINAPROUDMOORE)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_JAINAPROUDMOORE)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } @@ -659,13 +659,13 @@ public: { if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } else { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_JAINAPROUDMOORE)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_JAINAPROUDMOORE)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } @@ -771,13 +771,13 @@ public: { if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } else { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_JAINAPROUDMOORE)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_JAINAPROUDMOORE)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } @@ -885,13 +885,13 @@ public: { if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } else { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_JAINAPROUDMOORE)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_JAINAPROUDMOORE)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } @@ -984,13 +984,13 @@ public: { if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } else { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_JAINAPROUDMOORE)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_JAINAPROUDMOORE)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } @@ -1071,13 +1071,13 @@ public: { if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } else { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_JAINAPROUDMOORE)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_JAINAPROUDMOORE)); if (target && target->IsAlive()) me->AddThreat(target, 0.0f); } @@ -1159,7 +1159,7 @@ public: { if (waypointId == 2 && !IsOverrun) { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) { me->AddThreat(target, 0.0f); @@ -1283,7 +1283,7 @@ public: { if (waypointId == 2 && !IsOverrun) { - Unit* target = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_THRALL)); + Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_THRALL)); if (target && target->IsAlive()) { me->AddThreat(target, 0.0f); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp index db7fd702b7..a3f9998eae 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp @@ -51,16 +51,6 @@ public: m_uiAncientGemGUID.clear(); - RageWinterchill = 0; - Anetheron = 0; - Kazrogal = 0; - Azgalor = 0; - Archimonde = 0; - JainaProudmoore = 0; - Thrall = 0; - TyrandeWhisperwind = 0; - HordeGate = 0; - ElfGate = 0; RaidDamage = 0; Trash = 0; hordeRetreat = 0; @@ -85,16 +75,16 @@ public: case GO_HORDE_ENCAMPMENT_PORTAL: HordeGate = go->GetGUID(); if (allianceRetreat) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); else - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_NIGHT_ELF_VILLAGE_PORTAL: ElfGate = go->GetGUID(); if (hordeRetreat) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); else - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); break; case GO_ANCIENT_GEM: m_uiAncientGemGUID.push_back(go->GetGUID()); @@ -133,7 +123,7 @@ public: } } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { switch (identifier) { @@ -155,7 +145,7 @@ public: return TyrandeWhisperwind; } - return 0; + return ObjectGuid::Empty; } void SetData(uint32 type, uint32 data) override @@ -230,10 +220,10 @@ public: { if (!m_uiAncientGemGUID.empty()) { - for (std::list<uint64>::const_iterator itr = m_uiAncientGemGUID.begin(); itr != m_uiAncientGemGUID.end(); ++itr) + for (ObjectGuid const guid : m_uiAncientGemGUID) { //don't know how long it expected - DoRespawnGameObject(*itr, DAY); + DoRespawnGameObject(guid, DAY); } } } @@ -328,17 +318,17 @@ public: protected: uint32 m_auiEncounter[EncounterCount]; std::string str_data; - std::list<uint64> m_uiAncientGemGUID; - uint64 RageWinterchill; - uint64 Anetheron; - uint64 Kazrogal; - uint64 Azgalor; - uint64 Archimonde; - uint64 JainaProudmoore; - uint64 Thrall; - uint64 TyrandeWhisperwind; - uint64 HordeGate; - uint64 ElfGate; + GuidList m_uiAncientGemGUID; + ObjectGuid RageWinterchill; + ObjectGuid Anetheron; + ObjectGuid Kazrogal; + ObjectGuid Azgalor; + ObjectGuid Archimonde; + ObjectGuid JainaProudmoore; + ObjectGuid Thrall; + ObjectGuid TyrandeWhisperwind; + ObjectGuid HordeGate; + ObjectGuid ElfGate; uint32 Trash; uint32 hordeRetreat; uint32 allianceRetreat; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp index 375298abc3..a0a68ba50a 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp @@ -104,7 +104,7 @@ public: me->SetReactState(REACT_PASSIVE); if (InstanceScript* pInstance = me->GetInstanceScript()) { - if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_ARTHAS))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_ARTHAS))) cr->AI()->DoAction(ACTION_KILLED_MALGANIS); // give credit to players diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp index 44e47a5a10..9064e038bc 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp @@ -303,7 +303,7 @@ public: // After killing epoch creature->AI()->DoAction(ACTION_START_SECRET_PASSAGE); creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - creature->SetTarget(0); + creature->SetTarget(); CloseGossipMenuFor(player); break; case GOSSIP_ACTION_INFO_DEF+5: @@ -604,7 +604,7 @@ public: case 36: SetRun(true); if (pInstance) - if (GameObject* pGate = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_SHKAF_GATE))) + if (GameObject* pGate = pInstance->instance->GetGameObject(pInstance->GetGuidData(DATA_SHKAF_GATE))) pGate->SetGoState(GO_STATE_ACTIVE); break; // Behind secred passage @@ -775,7 +775,7 @@ public: case EVENT_ACTION_PHASE1+18: if (Creature* uther = GetEventNpc(NPC_UTHER)) { - uther->SetTarget(0); + uther->SetTarget(); uther->AddUnitMovementFlag(MOVEMENTFLAG_WALKING); uther->GetMotionMaster()->MovePoint(0, EventPos[EVENT_POS_RETREAT], false); } @@ -784,7 +784,7 @@ public: case EVENT_ACTION_PHASE1+19: if (Creature* jaina = GetEventNpc(NPC_JAINA)) { - jaina->SetTarget(0); + jaina->SetTarget(); jaina->AddUnitMovementFlag(MOVEMENTFLAG_WALKING); jaina->GetMotionMaster()->MovePoint(0, EventPos[EVENT_POS_RETREAT], false); } @@ -812,13 +812,13 @@ public: case EVENT_ACTION_PHASE1+22: SetEscortPaused(false); eventInRun = false; - me->SetTarget(0); + me->SetTarget(); // dont schedule next, do it in gossip select! break; //After Gossip 1 (waypoint 8) case EVENT_ACTION_PHASE2: summons.DespawnEntry(NPC_INVIS_TARGET); // remove trigger - me->SetTarget(0); + me->SetTarget(); SetEscortPaused(false); eventInRun = false; ScheduleNextEvent(currentEvent, 1000); @@ -885,7 +885,7 @@ public: case EVENT_ACTION_PHASE2+6: if (Creature* malganis = GetEventNpc(NPC_MAL_GANIS)) { - me->SetTarget(0); + me->SetTarget(); me->SetFacingToObject(malganis); malganis->SetVisible(false); } @@ -1132,7 +1132,7 @@ public: if (pInstance) { pInstance->SetData(DATA_ARTHAS_EVENT, COS_PROGRESS_FINISHED); - if (GameObject* go = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_EXIT_GATE))) + if (GameObject* go = pInstance->instance->GetGameObject(pInstance->GetGuidData(DATA_EXIT_GATE))) go->SetGoState(GO_STATE_ACTIVE); if (!me->GetMap()->GetPlayers().isEmpty()) @@ -1278,7 +1278,7 @@ void npc_arthas::npc_arthasAI::ReorderInstance(uint32 data) if (data >= COS_PROGRESS_KILLED_EPOCH) if (pInstance) - if (GameObject* pGate = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_SHKAF_GATE))) + if (GameObject* pGate = pInstance->instance->GetGameObject(pInstance->GetGuidData(DATA_SHKAF_GATE))) pGate->SetGoState(GO_STATE_READY); pInstance->SetData(DATA_SHOW_INFINITE_TIMER, 1); @@ -1422,7 +1422,7 @@ public: if (pInstance->GetData(DATA_ARTHAS_EVENT) == COS_PROGRESS_NOT_STARTED) { pInstance->SetData(DATA_ARTHAS_EVENT, COS_PROGRESS_FINISHED_INTRO); - if (Creature* arthas = ObjectAccessor::GetCreature(*creature, pInstance->GetData64(DATA_ARTHAS))) + if (Creature* arthas = ObjectAccessor::GetCreature(*creature, pInstance->GetGuidData(DATA_ARTHAS))) arthas->AI()->Reset(); } player->NearTeleportTo(LeaderIntroPos2.GetPositionX(), LeaderIntroPos2.GetPositionY(), LeaderIntroPos2.GetPositionZ(), LeaderIntroPos2.GetOrientation()); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp index d9766774ae..43657f48b9 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp @@ -24,14 +24,6 @@ public: { instance_culling_of_stratholme_InstanceMapScript(Map* pMap) : InstanceScript(pMap) { - // NPCs - _arthasGUID = 0; - _infiniteGUID = 0; - - // GOs - _shkafGateGUID = 0; - _exitGateGUID = 0; - // Instance _crateCount = 0; _showCrateTimer = 0; @@ -137,7 +129,7 @@ public: Map::PlayerList const& PlayerList = instance->GetPlayers(); if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - i->GetSource()->KilledMonsterCredit(NPC_GRAIN_CREATE_TRIGGER, 0); + i->GetSource()->KilledMonsterCredit(NPC_GRAIN_CREATE_TRIGGER); _showCrateTimer++; if (GetData(DATA_ARTHAS_EVENT) < COS_PROGRESS_CRATES_FOUND) @@ -184,7 +176,7 @@ public: return 0; } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { switch (identifier) { @@ -195,7 +187,8 @@ public: case DATA_EXIT_GATE: return _exitGateGUID; } - return 0; + + return ObjectGuid::Empty; } void Update(uint32 diff) override @@ -398,12 +391,12 @@ public: private: // NPCs - uint64 _arthasGUID; - uint64 _infiniteGUID; + ObjectGuid _arthasGUID; + ObjectGuid _infiniteGUID; // GOs - uint64 _shkafGateGUID; - uint64 _exitGateGUID; + ObjectGuid _shkafGateGUID; + ObjectGuid _exitGateGUID; uint32 _encounterState; uint32 _crateCount; uint32 _showCrateTimer; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp index dd68b6c91d..4af6a6f380 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp @@ -67,7 +67,7 @@ public: void JustSummoned(Creature* summon) override { summons.Summon(summon); - if (Creature* thrall = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(DATA_THRALL_GUID))) + if (Creature* thrall = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(DATA_THRALL_GUID))) thrall->AI()->JustSummoned(summon); summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp index 8eb44e7a12..46249c6abb 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp @@ -66,7 +66,7 @@ public: return; Talk(SAY_DEATH); me->GetInstanceScript()->SetData(DATA_ESCORT_PROGRESS, ENCOUNTER_PROGRESS_EPOCH_KILLED); - if (Creature* taretha = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(DATA_TARETHA_GUID))) + if (Creature* taretha = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(DATA_TARETHA_GUID))) taretha->AI()->DoAction(me->GetEntry()); } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp index 1f30e53b6b..634b386327 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp @@ -44,9 +44,6 @@ public: _barrelCount = 0; _attemptsCount = 0; - _thrallGUID = 0; - _tarethaGUID = 0; - _initalFlamesSet.clear(); _finalFlamesSet.clear(); _prisonersSet.clear(); @@ -166,13 +163,14 @@ public: return 0; } - uint64 GetData64(uint32 data) const override + ObjectGuid GetGuidData(uint32 data) const override { if (data == DATA_THRALL_GUID) return _thrallGUID; else if (data == DATA_TARETHA_GUID) return _tarethaGUID; - return 0; + + return ObjectGuid::Empty; } void Update(uint32 diff) override @@ -185,8 +183,8 @@ public: instance->LoadGrid(instancePositions[0].GetPositionX(), instancePositions[0].GetPositionY()); instance->LoadGrid(instancePositions[1].GetPositionX(), instancePositions[1].GetPositionY()); - for (std::set<uint64>::const_iterator itr = _prisonersSet.begin(); itr != _prisonersSet.end(); ++itr) - if (Creature* orc = instance->GetCreature(*itr)) + for (ObjectGuid const guid : _prisonersSet) + if (Creature* orc = instance->GetCreature(guid)) { uint8 index = orc->GetDistance(instancePositions[0]) < 80.0f ? 0 : 1; Position pos(instancePositions[index]); @@ -195,8 +193,8 @@ public: orc->SetStandState(UNIT_STAND_STATE_STAND); } - for (std::set<uint64>::const_iterator itr = _initalFlamesSet.begin(); itr != _initalFlamesSet.end(); ++itr) - if (GameObject* gobject = instance->GetGameObject(*itr)) + for (ObjectGuid const guid : _initalFlamesSet) + if (GameObject* gobject = instance->GetGameObject(guid)) { gobject->SetRespawnTime(0); gobject->UpdateObjectVisibility(true); @@ -214,18 +212,18 @@ public: if (!players.isEmpty()) for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) if (Player* player = itr->GetSource()) - player->KilledMonsterCredit(NPC_LODGE_QUEST_TRIGGER, 0); + player->KilledMonsterCredit(NPC_LODGE_QUEST_TRIGGER); } - for (std::set<uint64>::const_iterator itr = _finalFlamesSet.begin(); itr != _finalFlamesSet.end(); ++itr) - if (GameObject* gobject = instance->GetGameObject(*itr)) + for (ObjectGuid const guid : _finalFlamesSet) + if (GameObject* gobject = instance->GetGameObject(guid)) { gobject->SetRespawnTime(0); gobject->UpdateObjectVisibility(true); } - for (std::set<uint64>::const_iterator itr = _prisonersSet.begin(); itr != _prisonersSet.end(); ++itr) - if (Creature* orc = instance->GetCreature(*itr)) + for (ObjectGuid const guid : _prisonersSet) + if (Creature* orc = instance->GetCreature(guid)) if (roll_chance_i(25)) orc->HandleEmoteCommand(EMOTE_ONESHOT_CHEER); @@ -330,11 +328,11 @@ public: uint32 _barrelCount; uint32 _attemptsCount; - uint64 _thrallGUID; - uint64 _tarethaGUID; - std::set<uint64> _initalFlamesSet; - std::set<uint64> _finalFlamesSet; - std::set<uint64> _prisonersSet; + ObjectGuid _thrallGUID; + ObjectGuid _tarethaGUID; + GuidSet _initalFlamesSet; + GuidSet _finalFlamesSet; + GuidSet _prisonersSet; EventMap _events; }; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp index 8f9129f728..d5a7c0b119 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp @@ -387,7 +387,7 @@ public: SetEscortPaused(true); SetRun(true); instance->SetData(DATA_ESCORT_PROGRESS, ENCOUNTER_PROGRESS_TARETHA_MEET); - if (Creature* Taretha = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_TARETHA_GUID))) + if (Creature* Taretha = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_TARETHA_GUID))) Taretha->AI()->Talk(SAY_TARETHA_ESCAPED); events.ScheduleEvent(EVENT_THRALL_TALK, 2000); break; @@ -618,7 +618,7 @@ public: case EVENT_TARETHA_FALL: if (Creature* epoch = summons.GetCreatureWithEntry(NPC_EPOCH_HUNTER)) epoch->AI()->Talk(SAY_EPOCH_ENTER2); - if (Creature* Taretha = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_TARETHA_GUID))) + if (Creature* Taretha = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_TARETHA_GUID))) { Taretha->CastSpell(Taretha, SPELL_SHADOW_SPIKE); Taretha->SetStandState(UNIT_STAND_STATE_DEAD); @@ -700,7 +700,7 @@ public: if (!players.isEmpty()) for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) if (Player* player = itr->GetSource()) - player->KilledMonsterCredit(20156, 0); + player->KilledMonsterCredit(20156); me->SetFacingTo(5.76f); break; @@ -709,7 +709,7 @@ public: Talk(SAY_GREET_TARETHA); break; case EVENT_TARETHA_TALK_1: - if (Creature* Taretha = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_TARETHA_GUID))) + if (Creature* Taretha = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_TARETHA_GUID))) Taretha->AI()->Talk(SAY_TARETHA_TALK1); break; case EVENT_THRALL_TALK_5: @@ -751,7 +751,7 @@ public: SetEscortPaused(false); break; case EVENT_TARETHA_TALK_2: - if (Creature* Taretha = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_TARETHA_GUID))) + if (Creature* Taretha = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_TARETHA_GUID))) { Taretha->SetFacingTo(4.233f); Taretha->AI()->Talk(SAY_TARETHA_TALK2); @@ -827,7 +827,7 @@ public: break; case ENCOUNTER_PROGRESS_TARETHA_MEET: SetNextWaypoint(95, false); - if (Creature* Taretha = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_TARETHA_GUID))) + if (Creature* Taretha = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_TARETHA_GUID))) Taretha->SetStandState(UNIT_STAND_STATE_STAND); break; } @@ -881,7 +881,7 @@ public: SetRun(false); Talk(SAY_TARETHA_FREE); me->HandleEmoteCommand(EMOTE_ONESHOT_CHEER); - if (Creature* thrall = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_THRALL_GUID))) + if (Creature* thrall = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THRALL_GUID))) thrall->AI()->DoAction(me->GetEntry()); } else if (waypointId == 9) diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp index 58796db9c4..fe0f96570a 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp @@ -53,7 +53,7 @@ public: void JustReachedHome() override { - if (Unit* medivh = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_MEDIVH))) + if (Unit* medivh = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_MEDIVH))) if (me->GetDistance2d(medivh) < 20.0f) me->CastSpell(me, SPELL_CORRUPT_MEDIVH, false); } @@ -63,7 +63,7 @@ public: Talk(SAY_ENTER); ScriptedAI::InitializeAI(); - if (Unit* medivh = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_MEDIVH))) + if (Unit* medivh = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_MEDIVH))) { me->SetHomePosition(medivh->GetPositionX() + 14.0f * cos(medivh->GetAngle(me)), medivh->GetPositionY() + 14.0f * sin(medivh->GetAngle(me)), medivh->GetPositionZ(), me->GetAngle(medivh)); me->GetMotionMaster()->MoveTargetedHome(); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp index 03f2e6956e..4259123507 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp @@ -32,16 +32,15 @@ public: { instance_the_black_morass_InstanceMapScript(Map* map) : InstanceScript(map) { } - std::set<uint64> encounterNPCs; + GuidSet encounterNPCs; uint32 encounters[MAX_ENCOUNTER]; - uint64 _medivhGUID; + ObjectGuid _medivhGUID; uint8 _currentRift; uint8 _shieldPercent; void Initialize() override { memset(&encounters, 0, sizeof(encounters)); - _medivhGUID = 0; _currentRift = 0; _shieldPercent = 100; encounterNPCs.clear(); @@ -60,9 +59,9 @@ public: medivh->SetRespawnTime(3); } - std::set<uint64> eCopy = encounterNPCs; - for (std::set<uint64>::const_iterator itr = eCopy.begin(); itr != eCopy.end(); ++itr) - if (Creature* creature = instance->GetCreature(*itr)) + GuidSet eCopy = encounterNPCs; + for (ObjectGuid const guid : eCopy) + if (Creature* creature = instance->GetCreature(guid)) creature->DespawnOrUnsummon(); } @@ -184,9 +183,9 @@ public: Unit::Kill(medivh, medivh); // Xinef: delete all spawns - std::set<uint64> eCopy = encounterNPCs; - for (std::set<uint64>::iterator itr = eCopy.begin(); itr != eCopy.end(); ++itr) - if (Creature* creature = instance->GetCreature(*itr)) + GuidSet eCopy = encounterNPCs; + for (ObjectGuid guid : eCopy) + if (Creature* creature = instance->GetCreature(guid)) creature->DespawnOrUnsummon(); } break; @@ -209,7 +208,7 @@ public: return 0; } - void SetData64(uint32 type, uint64 data) override + void SetGuidData(uint32 type, ObjectGuid data) override { if (type == DATA_SUMMONED_NPC) encounterNPCs.insert(data); @@ -217,19 +216,19 @@ public: encounterNPCs.erase(data); } - uint64 GetData64(uint32 data) const override + ObjectGuid GetGuidData(uint32 data) const override { if (data == DATA_MEDIVH) return _medivhGUID; - return 0; + return ObjectGuid::Empty; } void SummonPortalKeeper() { Creature* rift = nullptr; - for (std::set<uint64>::const_iterator itr = encounterNPCs.begin(); itr != encounterNPCs.end(); ++itr) - if (Creature* summon = instance->GetCreature(*itr)) + for (ObjectGuid const guid : encounterNPCs) + if (Creature* summon = instance->GetCreature(guid)) if (summon->GetEntry() == NPC_TIME_RIFT) { rift = summon; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp index dc7c576907..3f78171398 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp @@ -120,7 +120,7 @@ public: void JustSummoned(Creature* summon) override { if (instance) - instance->SetData64(DATA_SUMMONED_NPC, summon->GetGUID()); + instance->SetGuidData(DATA_SUMMONED_NPC, summon->GetGUID()); if (summon->GetEntry() == NPC_DP_CRYSTAL_STALKER) { @@ -141,7 +141,7 @@ public: void SummonedCreatureDespawn(Creature* summon) override { if (instance) - instance->SetData64(DATA_DELETED_NPC, summon->GetGUID()); + instance->SetGuidData(DATA_DELETED_NPC, summon->GetGUID()); } void MoveInLineOfSight(Unit* who) override @@ -285,12 +285,11 @@ public: npc_time_riftAI(Creature* creature) : NullCreatureAI(creature) { instance = creature->GetInstanceScript(); - riftKeeperGUID = 0; } EventMap events; InstanceScript* instance; - uint64 riftKeeperGUID; + ObjectGuid riftKeeperGUID; void Reset() override { @@ -304,7 +303,7 @@ public: events.ScheduleEvent(EVENT_CHECK_DEATH, 8000); } - void SetGUID(uint64 guid, int32) override + void SetGUID(ObjectGuid guid, int32) override { riftKeeperGUID = guid; } @@ -317,7 +316,7 @@ public: if (Creature* summon = me->SummonCreature(entry, pos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 150000)) if (instance) { - if (Unit* medivh = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_MEDIVH))) + if (Unit* medivh = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_MEDIVH))) { float o = medivh->GetAngle(summon) + frand(-1.0f, 1.0f); summon->SetHomePosition(medivh->GetPositionX() + 14.0f * cos(o), medivh->GetPositionY() + 14.0f * sin(o), medivh->GetPositionZ(), summon->GetAngle(medivh)); diff --git a/src/server/scripts/Kalimdor/DireMaul/instance_dire_maul.cpp b/src/server/scripts/Kalimdor/DireMaul/instance_dire_maul.cpp index b008dd22d6..66412b9ef4 100644 --- a/src/server/scripts/Kalimdor/DireMaul/instance_dire_maul.cpp +++ b/src/server/scripts/Kalimdor/DireMaul/instance_dire_maul.cpp @@ -22,7 +22,6 @@ public: _pylonsState = 0; _northWingProgress = 0; _northWingBosses = 0; - _immoltharGUID = 0; } void OnCreatureCreate(Creature* creature) override @@ -140,7 +139,7 @@ public: uint32 _northWingProgress; uint32 _northWingBosses; - uint64 _immoltharGUID; + ObjectGuid _immoltharGUID; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Kalimdor/Maraudon/instance_maraudon.cpp b/src/server/scripts/Kalimdor/Maraudon/instance_maraudon.cpp index 6466fc8a83..06ed51ebdf 100644 --- a/src/server/scripts/Kalimdor/Maraudon/instance_maraudon.cpp +++ b/src/server/scripts/Kalimdor/Maraudon/instance_maraudon.cpp @@ -28,7 +28,7 @@ public: { case GO_CORRUPTION_SPEWER: if (_encounters[TYPE_NOXXION] == DONE) - HandleGameObject(0, true, gameobject); + HandleGameObject(ObjectGuid::Empty, true, gameobject); break; } } diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp index 84d139bcc5..1e31bd667d 100644 --- a/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp +++ b/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp @@ -20,17 +20,16 @@ public: { instance_onyxias_lair_InstanceMapScript(Map* pMap) : InstanceScript(pMap) {Initialize();}; - uint64 m_uiOnyxiasGUID; + ObjectGuid m_uiOnyxiasGUID; uint32 m_auiEncounter[MAX_ENCOUNTER]; std::string str_data; uint16 ManyWhelpsCounter; - std::vector<uint64> minions; + GuidVector minions; bool bDeepBreath; void Initialize() override { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - m_uiOnyxiasGUID = 0; ManyWhelpsCounter = 0; bDeepBreath = true; } @@ -80,8 +79,8 @@ public: bDeepBreath = true; if( uiData == NOT_STARTED ) { - for( std::vector<uint64>::iterator itr = minions.begin(); itr != minions.end(); ++itr ) - if( Creature* c = instance->GetCreature(*itr) ) + for (ObjectGuid guid : minions) + if (Creature* c = instance->GetCreature(guid)) c->DespawnOrUnsummon(); minions.clear(); } @@ -109,15 +108,15 @@ public: return 0; } - uint64 GetData64(uint32 uiData) const override + ObjectGuid GetGuidData(uint32 uiData) const override { - switch(uiData) + switch (uiData) { case DATA_ONYXIA: return m_uiOnyxiasGUID; } - return 0; + return ObjectGuid::Empty; } std::string GetSaveData() override @@ -178,4 +177,4 @@ public: void AddSC_instance_onyxias_lair() { new instance_onyxias_lair(); -}
\ No newline at end of file +} diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp index b8f7b61d03..0a8e4c45f9 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp @@ -180,15 +180,15 @@ public: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0, true)) { DoCast(target, SPELL_PARALYZE); - instance->SetData64(DATA_PARALYZED, target->GetGUID()); + instance->SetGuidData(DATA_PARALYZED, target->GetGUID()); uint8 Index = urand(0, 1); me->SummonCreature(NPC_LARVA, LarvaPos[Index], TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000); } events.ScheduleEvent(EVENT_PARALYZE, 15000); break; case EVENT_SWARMER_ATTACK: - for (std::list<uint64>::iterator i = _swarmers.begin(); i != _swarmers.end(); ++i) - if (Creature* swarmer = me->GetMap()->GetCreature(*i)) + for (ObjectGuid guid : _swarmers) + if (Creature* swarmer = me->GetMap()->GetCreature(guid)) if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) swarmer->AI()->AttackStart(target); @@ -215,7 +215,7 @@ public: } } private: - std::list<uint64> _swarmers; + GuidList _swarmers; uint8 _phase; bool _enraged; }; @@ -242,7 +242,7 @@ public: { if (type == POINT_MOTION_TYPE) if (id == POINT_PARALYZE) - if (Player* target = ObjectAccessor::GetPlayer(*me, _instance->GetData64(DATA_PARALYZED))) + if (Player* target = ObjectAccessor::GetPlayer(*me, _instance->GetGuidData(DATA_PARALYZED))) DoCast(target, SPELL_FEED); // Omnomnom } diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp index 15d9f8fc43..1f6921396b 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp @@ -63,8 +63,8 @@ public: { BossAI::EnterEvadeMode(); - for (std::list<uint64>::iterator i = Eggs.begin(); i != Eggs.end(); ++i) - if (Creature* egg = me->GetMap()->GetCreature(*Eggs.begin())) + for (ObjectGuid guid : Eggs) + if (Creature* egg = me->GetMap()->GetCreature(guid)) egg->Respawn(); Eggs.clear(); @@ -114,7 +114,7 @@ public: } } - void ManageRespawn(uint64 EggGUID) + void ManageRespawn(ObjectGuid EggGUID) { ChaseNewVictim(); Eggs.push_back(EggGUID); @@ -171,7 +171,7 @@ public: } private: uint8 _phase; - std::list<uint64> Eggs; + GuidList Eggs; }; CreatureAI* GetAI(Creature* creature) const override @@ -195,7 +195,7 @@ public: void EnterCombat(Unit* attacker) override { - if (Creature* buru = me->GetMap()->GetCreature(_instance->GetData64(DATA_BURU))) + if (Creature* buru = me->GetMap()->GetCreature(_instance->GetGuidData(DATA_BURU))) if (!buru->IsInCombat()) buru->AI()->AttackStart(attacker); } @@ -203,7 +203,7 @@ public: void JustSummoned(Creature* who) override { if (who->GetEntry() == NPC_HATCHLING) - if (Creature* buru = me->GetMap()->GetCreature(_instance->GetData64(DATA_BURU))) + if (Creature* buru = me->GetMap()->GetCreature(_instance->GetGuidData(DATA_BURU))) if (Unit* target = buru->AI()->SelectTarget(SELECT_TARGET_RANDOM)) who->AI()->AttackStart(target); } @@ -214,7 +214,7 @@ public: DoCastAOE(SPELL_EXPLODE_2, true); // Unknown purpose DoCast(me, SPELL_SUMMON_HATCHLING, true); - if (Creature* buru = me->GetMap()->GetCreature(_instance->GetData64(DATA_BURU))) + if (Creature* buru = me->GetMap()->GetCreature(_instance->GetGuidData(DATA_BURU))) if (boss_buru::boss_buruAI* buruAI = dynamic_cast<boss_buru::boss_buruAI*>(buru->AI())) buruAI->ManageRespawn(me->GetGUID()); } diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp index 100bebc1f1..01c1fb6f9f 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp @@ -66,7 +66,7 @@ public: void JustDied(Unit* /*killer*/) override { _JustDied(); - if (Creature* Ossirian = me->GetMap()->GetCreature(instance->GetData64(DATA_OSSIRIAN))) + if (Creature* Ossirian = me->GetMap()->GetCreature(instance->GetGuidData(DATA_OSSIRIAN))) sCreatureTextMgr->SendChat(Ossirian, SAY_KURINAXX_DEATH, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); } diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp index ffba633653..548a0d1d09 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp @@ -80,8 +80,8 @@ public: SaidIntro = false; } - uint64 TriggerGUID; - uint64 CrystalGUID; + ObjectGuid TriggerGUID; + ObjectGuid CrystalGUID; uint8 CrystalIterator; bool SaidIntro; @@ -89,8 +89,8 @@ public: { _Reset(); CrystalIterator = 0; - TriggerGUID = 0; - CrystalGUID = 0; + TriggerGUID.Clear(); + CrystalGUID.Clear(); } void SpellHit(Unit* caster, SpellInfo const* spell) override @@ -184,7 +184,7 @@ public: { CrystalGUID = Crystal->GetGUID(); ++CrystalIterator; - Crystal->SetOwnerGUID(0); + Crystal->SetOwnerGUID(ObjectGuid::Empty); } } } diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp index 3d9ab4b403..f220ef00cc 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp @@ -18,14 +18,6 @@ public: instance_ruins_of_ahnqiraj_InstanceMapScript(Map* map) : InstanceScript(map) { SetBossNumber(NUM_ENCOUNTER); - - _kurinaxxGUID = 0; - _rajaxxGUID = 0; - _moamGUID = 0; - _buruGUID = 0; - _ayamissGUID = 0; - _ossirianGUID = 0; - _paralyzedGUID = 0; } void OnCreatureCreate(Creature* creature) override @@ -61,13 +53,13 @@ public: return true; } - void SetData64(uint32 type, uint64 data) override + void SetGuidData(uint32 type, ObjectGuid data) override { if (type == DATA_PARALYZED) _paralyzedGUID = data; } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -87,7 +79,7 @@ public: return _paralyzedGUID; } - return 0; + return ObjectGuid::Empty; } std::string GetSaveData() override @@ -134,13 +126,13 @@ public: } private: - uint64 _kurinaxxGUID; - uint64 _rajaxxGUID; - uint64 _moamGUID; - uint64 _buruGUID; - uint64 _ayamissGUID; - uint64 _ossirianGUID; - uint64 _paralyzedGUID; + ObjectGuid _kurinaxxGUID; + ObjectGuid _rajaxxGUID; + ObjectGuid _moamGUID; + ObjectGuid _buruGUID; + ObjectGuid _ayamissGUID; + ObjectGuid _ossirianGUID; + ObjectGuid _paralyzedGUID; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp index 133ea021fd..15b4adc14a 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp @@ -290,11 +290,11 @@ public: switch (urand(0, 2)) { case 0: - if (Creature* kri = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_KRI))) + if (Creature* kri = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_KRI))) DoCast(kri, SPELL_HEAL); break; case 1: - if (Creature* vem = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_VEM))) + if (Creature* vem = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VEM))) DoCast(vem, SPELL_HEAL); break; case 2: diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index 6dd05a02f9..f62eeec61f 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -292,7 +292,7 @@ public: me->SetReactState(REACT_PASSIVE); //Remove any target - me->SetTarget(0); + me->SetTarget(); //Select random target for dark beam to start on if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) @@ -379,7 +379,7 @@ public: //Transition phase case PHASE_CTHUN_TRANSITION: //Remove any target - me->SetTarget(0); + me->SetTarget(); me->SetHealth(0); me->SetVisible(false); break; @@ -415,7 +415,7 @@ public: me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); //Remove Target field - me->SetTarget(0); + me->SetTarget(); //Death animation/respawning; instance->SetData(DATA_CTHUN_PHASE, PHASE_CTHUN_TRANSITION); @@ -470,7 +470,7 @@ public: //------------------- //Phase transition - uint64 HoldPlayer; + ObjectGuid HoldPlayer; //Body Phase uint32 EyeTentacleTimer; @@ -480,10 +480,10 @@ public: uint32 StomachAcidTimer; uint32 StomachEnterTimer; uint32 StomachEnterVisTimer; - uint64 StomachEnterTarget; + ObjectGuid StomachEnterTarget; //Stomach map, bool = true then in stomach - std::unordered_map<uint64, bool> Stomach_Map; + std::unordered_map<ObjectGuid, bool> Stomach_Map; void Reset() override { @@ -494,7 +494,7 @@ public: PhaseTimer = 10000; //Emerge in 10 seconds //No hold player for transition - HoldPlayer = 0; + HoldPlayer.Clear(); //Body Phase EyeTentacleTimer = 30000; @@ -504,7 +504,7 @@ public: StomachAcidTimer = 4000; //Every 4 seconds StomachEnterTimer = 10000; //Every 10 seconds StomachEnterVisTimer = 0; //Always 3.5 seconds after Stomach Enter Timer - StomachEnterTarget = 0; //Target to be teleported to stomach + StomachEnterTarget.Clear(); //Target to be teleported to stomach //Clear players in stomach and outside Stomach_Map.clear(); @@ -536,7 +536,7 @@ public: if (Stomach_Map.empty()) return nullptr; - std::unordered_map<uint64, bool>::const_iterator i = Stomach_Map.begin(); + std::unordered_map<ObjectGuid, bool>::const_iterator i = Stomach_Map.begin(); std::list<Unit*> temp; std::list<Unit*>::const_iterator j; @@ -599,7 +599,7 @@ public: return; } - me->SetTarget(0); + me->SetTarget(); uint32 currentPhase = instance->GetData(DATA_CTHUN_PHASE); if (currentPhase == PHASE_CTHUN_STOMACH || currentPhase == PHASE_CTHUN_WEAK) @@ -671,7 +671,7 @@ public: //Body Phase case PHASE_CTHUN_STOMACH: //Remove Target field - me->SetTarget(0); + me->SetTarget(); //Weaken if (FleshTentaclesKilled > 1) @@ -683,7 +683,7 @@ public: DoCast(me, SPELL_PURPLE_COLORATION, true); - std::unordered_map<uint64, bool>::iterator i = Stomach_Map.begin(); + std::unordered_map<ObjectGuid, bool>::iterator i = Stomach_Map.begin(); //Kick all players out of stomach while (i != Stomach_Map.end()) @@ -715,7 +715,7 @@ public: if (StomachAcidTimer <= diff) { //Apply aura to all players in stomach - std::unordered_map<uint64, bool>::iterator i = Stomach_Map.begin(); + std::unordered_map<ObjectGuid, bool>::iterator i = Stomach_Map.begin(); while (i != Stomach_Map.end()) { @@ -779,7 +779,7 @@ public: DoTeleportPlayer(unit, STOMACH_X, STOMACH_Y, STOMACH_Z, STOMACH_O); } - StomachEnterTarget = 0; + StomachEnterTarget.Clear(); StomachEnterVisTimer = 0; } else StomachEnterVisTimer -= diff; @@ -906,7 +906,6 @@ public: { eye_tentacleAI(Creature* creature) : ScriptedAI(creature) { - Portal = 0; if (Creature* pPortal = me->SummonCreature(NPC_SMALL_PORTAL, *me, TEMPSUMMON_CORPSE_DESPAWN)) { pPortal->SetReactState(REACT_PASSIVE); @@ -918,7 +917,7 @@ public: uint32 MindflayTimer; uint32 KillSelfTimer; - uint64 Portal; + ObjectGuid Portal; void JustDied(Unit* /*killer*/) override { @@ -985,7 +984,6 @@ public: { SetCombatMovement(false); - Portal = 0; if (Creature* pPortal = me->SummonCreature(NPC_SMALL_PORTAL, *me, TEMPSUMMON_CORPSE_DESPAWN)) { pPortal->SetReactState(REACT_PASSIVE); @@ -996,7 +994,7 @@ public: uint32 GroundRuptureTimer; uint32 HamstringTimer; uint32 EvadeTimer; - uint64 Portal; + ObjectGuid Portal; void JustDied(Unit* /*killer*/) override { @@ -1098,7 +1096,6 @@ public: { SetCombatMovement(false); - Portal = 0; if (Creature* pPortal = me->SummonCreature(NPC_GIANT_PORTAL, *me, TEMPSUMMON_CORPSE_DESPAWN)) { pPortal->SetReactState(REACT_PASSIVE); @@ -1110,7 +1107,7 @@ public: uint32 ThrashTimer; uint32 HamstringTimer; uint32 EvadeTimer; - uint64 Portal; + ObjectGuid Portal; void JustDied(Unit* /*killer*/) override { @@ -1221,7 +1218,6 @@ public: { SetCombatMovement(false); - Portal = 0; if (Creature* pPortal = me->SummonCreature(NPC_GIANT_PORTAL, *me, TEMPSUMMON_CORPSE_DESPAWN)) { pPortal->SetReactState(REACT_PASSIVE); @@ -1230,7 +1226,7 @@ public: } uint32 BeamTimer; - uint64 Portal; + ObjectGuid Portal; void JustDied(Unit* /*killer*/) override { diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp index 1491a8be4c..0e7e2168e5 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp @@ -89,7 +89,7 @@ struct boss_twinemperorsAI : public ScriptedAI Creature* GetOtherBoss() { - return ObjectAccessor::GetCreature(*me, instance->GetData64(IAmVeklor() ? DATA_VEKNILASH : DATA_VEKLOR)); + return ObjectAccessor::GetCreature(*me, instance->GetGuidData(IAmVeklor() ? DATA_VEKNILASH : DATA_VEKLOR)); } void DamageTaken(Unit*, uint32& damage, DamageEffectType, SpellSchoolMask) override diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp index 0bc0860bd4..993055029e 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp @@ -253,7 +253,7 @@ public: { InstanceScript* Instance = me->GetInstanceScript(); - if (Creature* Viscidus = me->GetMap()->GetCreature(Instance->GetData64(DATA_VISCIDUS))) + if (Creature* Viscidus = me->GetMap()->GetCreature(Instance->GetGuidData(DATA_VISCIDUS))) { if (BossAI* ViscidusAI = dynamic_cast<BossAI*>(Viscidus->GetAI())) ViscidusAI->SummonedCreatureDespawn(me); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp index 789accc502..bb32b39f61 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp @@ -33,12 +33,12 @@ public: bool IsBossDied[3]; //Storing Skeram, Vem and Kri. - uint64 SkeramGUID; - uint64 VemGUID; - uint64 KriGUID; - uint64 VeklorGUID; - uint64 VeknilashGUID; - uint64 ViscidusGUID; + ObjectGuid SkeramGUID; + ObjectGuid VemGUID; + ObjectGuid KriGUID; + ObjectGuid VeklorGUID; + ObjectGuid VeknilashGUID; + ObjectGuid ViscidusGUID; uint32 BugTrioDeathCount; @@ -50,13 +50,6 @@ public: IsBossDied[1] = false; IsBossDied[2] = false; - SkeramGUID = 0; - VemGUID = 0; - KriGUID = 0; - VeklorGUID = 0; - VeknilashGUID = 0; - ViscidusGUID = 0; - BugTrioDeathCount = 0; CthunPhase = 0; @@ -121,7 +114,7 @@ public: return 0; } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { switch (identifier) { @@ -138,8 +131,9 @@ public: case DATA_VISCIDUS: return ViscidusGUID; } - return 0; - } // end GetData64 + + return ObjectGuid::Empty; + } void SetData(uint32 type, uint32 data) override { diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp index 8c28a4e123..c95dca1c80 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp @@ -100,14 +100,15 @@ public: abselected = 0; // just initialization of variable } - uint64 NearbyGUID[3]; + ObjectGuid NearbyGUID[3]; void ClearBuddyList() { - NearbyGUID[0] = NearbyGUID[1] = NearbyGUID[2] = 0; + for (uint8 i = 0; i < 3; ++i) + NearbyGUID[i].Clear(); } - void AddBuddyToList(uint64 CreatureGUID) + void AddBuddyToList(ObjectGuid CreatureGUID) { if (CreatureGUID == me->GetGUID()) return; diff --git a/src/server/scripts/Kalimdor/WailingCaverns/instance_wailing_caverns.cpp b/src/server/scripts/Kalimdor/WailingCaverns/instance_wailing_caverns.cpp index 91eabb049e..65afe20184 100644 --- a/src/server/scripts/Kalimdor/WailingCaverns/instance_wailing_caverns.cpp +++ b/src/server/scripts/Kalimdor/WailingCaverns/instance_wailing_caverns.cpp @@ -23,9 +23,6 @@ public: void Initialize() override { memset(&_encounters, 0, sizeof(_encounters)); - - DiscipleOfNaralexGUID = 0; - SerpentisGUID = 0; } void OnCreatureCreate(Creature* creature) override @@ -109,8 +106,8 @@ public: private: uint32 _encounters[MAX_ENCOUNTERS]; - uint64 DiscipleOfNaralexGUID; - uint64 SerpentisGUID; + ObjectGuid DiscipleOfNaralexGUID; + ObjectGuid SerpentisGUID; }; }; diff --git a/src/server/scripts/Kalimdor/zone_azshara.cpp b/src/server/scripts/Kalimdor/zone_azshara.cpp index f31c0cd7a1..5defac5969 100644 --- a/src/server/scripts/Kalimdor/zone_azshara.cpp +++ b/src/server/scripts/Kalimdor/zone_azshara.cpp @@ -218,7 +218,7 @@ public: MustDieTimer = 3000; CurrWP = 0; - PlayerGUID = 0; + PlayerGUID.Clear(); MustDie = false; Escape = false; @@ -357,7 +357,7 @@ public: } private: - uint64 PlayerGUID; + ObjectGuid PlayerGUID; uint32 SpellEscapeTimer; uint32 TeleportTimer; uint32 CheckTimer; diff --git a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp index 2972badfc4..1ef1f0314f 100644 --- a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp +++ b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp @@ -50,7 +50,7 @@ public: { npc_draenei_survivorAI(Creature* creature) : ScriptedAI(creature) { } - uint64 pCaster; + ObjectGuid pCaster; uint32 SayThanksTimer; uint32 RunAwayTimer; @@ -60,7 +60,7 @@ public: void Reset() override { - pCaster = 0; + pCaster.Clear(); SayThanksTimer = 0; RunAwayTimer = 0; @@ -384,7 +384,7 @@ public: cage->SetGoState(GO_STATE_READY); } _events.Reset(); - _playerGUID = 0; + _playerGUID.Clear(); _movementComplete = false; } @@ -424,7 +424,7 @@ public: } private: - uint64 _playerGUID; + ObjectGuid _playerGUID; EventMap _events; bool _movementComplete; }; diff --git a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp index 6fcc859132..228eb53283 100644 --- a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp +++ b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp @@ -53,7 +53,7 @@ public: case 0: if (Player* player = killer->ToPlayer()) { - player->KilledMonsterCredit(NPC_EXPEDITION_RESEARCHER, 0); + player->KilledMonsterCredit(NPC_EXPEDITION_RESEARCHER); } spawnCreatureID = NPC_EXPEDITION_RESEARCHER; break; diff --git a/src/server/scripts/Kalimdor/zone_desolace.cpp b/src/server/scripts/Kalimdor/zone_desolace.cpp index 5134c4ad17..f5cbd1c372 100644 --- a/src/server/scripts/Kalimdor/zone_desolace.cpp +++ b/src/server/scripts/Kalimdor/zone_desolace.cpp @@ -78,19 +78,17 @@ public: { npc_cork_gizeltonAI(Creature* creature) : npc_escortAI(creature) { - memset(&summons, 0, sizeof(summons)); } EventMap events; - uint64 summons[MAX_CARAVAN_SUMMONS]; + ObjectGuid summons[MAX_CARAVAN_SUMMONS]; bool headNorth; - uint64 _playerGUID; + ObjectGuid _playerGUID; uint32 _faction; void Initialize() { - _playerGUID = 0; _faction = 35; headNorth = true; me->setActive(true); @@ -129,12 +127,12 @@ public: if (me->IsWithinDist(player, 60.0f)) return; - _playerGUID = 0; + _playerGUID.Clear(); _faction = 35; ImmuneFlagSet(false, _faction); } - void SetGUID(uint64 playerGUID, int32 faction) override + void SetGUID(ObjectGuid playerGUID, int32 faction) override { _playerGUID = playerGUID; _faction = faction; @@ -155,7 +153,7 @@ public: { for (uint8 i = 0; i < MAX_CARAVAN_SUMMONS; ++i) { - if (summons[i] == 0) + if (!summons[i]) { SummonHelpers(); return false; @@ -178,7 +176,7 @@ public: if (Creature* summon = ObjectAccessor::GetCreature(*me, summons[i])) summon->DespawnOrUnsummon(); - summons[i] = 0; + summons[i].Clear(); } } @@ -204,21 +202,21 @@ public: void SummonedCreatureDies(Creature* creature, Unit*) override { if (creature->GetGUID() == summons[0]) - summons[0] = 0; + summons[0].Clear(); else if (creature->GetGUID() == summons[1]) - summons[1] = 0; + summons[1].Clear(); else if (creature->GetGUID() == summons[2]) - summons[2] = 0; + summons[2].Clear(); } void SummonedCreatureDespawn(Creature* creature) override { if (creature->GetGUID() == summons[0]) - summons[0] = 0; + summons[0].Clear(); else if (creature->GetGUID() == summons[1]) - summons[1] = 0; + summons[1].Clear(); else if (creature->GetGUID() == summons[2]) - summons[2] = 0; + summons[2].Clear(); } void SummonsFollow() @@ -304,7 +302,7 @@ public: else player->FailQuest(QUEST_BODYGUARD_FOR_HIRE); } - _playerGUID = 0; + _playerGUID.Clear(); CheckPlayer(); break; // South -> North - complete @@ -316,7 +314,7 @@ public: else player->FailQuest(QUEST_GIZELTON_CARAVAN); } - _playerGUID = 0; + _playerGUID.Clear(); CheckPlayer(); break; // North -> South - spawn attackers @@ -398,7 +396,7 @@ public: case EVENT_RESTART_ESCORT: CheckCaravan(); SetDespawnAtEnd(false); - Start(true, true, 0, 0, false, false, true); + Start(true, true, ObjectGuid::Empty, 0, false, false, true); break; } @@ -483,7 +481,7 @@ public: { if (player->HasAura(SPELL_KODO_KOMBO_PLAYER_BUFF) && creature->HasAura(SPELL_KODO_KOMBO_DESPAWN_BUFF)) { - player->TalkedToCreature(creature->GetEntry(), 0); + player->TalkedToCreature(creature->GetEntry(), ObjectGuid::Empty); player->RemoveAurasDueToSpell(SPELL_KODO_KOMBO_PLAYER_BUFF); } diff --git a/src/server/scripts/Kalimdor/zone_durotar.cpp b/src/server/scripts/Kalimdor/zone_durotar.cpp index 47ae1195aa..da5c729bce 100644 --- a/src/server/scripts/Kalimdor/zone_durotar.cpp +++ b/src/server/scripts/Kalimdor/zone_durotar.cpp @@ -139,8 +139,7 @@ public: struct npc_tiger_matriarchAI : public ScriptedAI { - npc_tiger_matriarchAI(Creature* creature) : ScriptedAI(creature), - _tigerGuid(0) + npc_tiger_matriarchAI(Creature* creature) : ScriptedAI(creature) { } @@ -240,7 +239,7 @@ public: private: EventMap _events; - uint64 _tigerGuid; + ObjectGuid _tigerGuid; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Kalimdor/zone_moonglade.cpp b/src/server/scripts/Kalimdor/zone_moonglade.cpp index 65838f61ec..189ce13404 100644 --- a/src/server/scripts/Kalimdor/zone_moonglade.cpp +++ b/src/server/scripts/Kalimdor/zone_moonglade.cpp @@ -283,7 +283,7 @@ public: public: npc_clintar_spiritAI(Creature* creature) : npc_escortAI(creature) { - PlayerGUID = 0; + PlayerGUID.Clear(); } uint8 Step; @@ -291,7 +291,7 @@ public: uint32 EventTimer; uint32 checkPlayerTimer; - uint64 PlayerGUID; + ObjectGuid PlayerGUID; bool EventOnWait; @@ -302,7 +302,7 @@ public: Step = 0; CurrWP = 0; EventTimer = 0; - PlayerGUID = 0; + PlayerGUID.Clear(); checkPlayerTimer = 1000; EventOnWait = false; } @@ -339,7 +339,7 @@ public: if (player && player->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE) { player->FailQuest(10965); - PlayerGUID = 0; + PlayerGUID.Clear(); Reset(); } } @@ -518,7 +518,7 @@ public: break; case 2: player->TalkedToCreature(me->GetEntry(), me->GetGUID()); - PlayerGUID = 0; + PlayerGUID.Clear(); Reset(); me->setDeathState(JUST_DIED); break; diff --git a/src/server/scripts/Kalimdor/zone_orgrimmar.cpp b/src/server/scripts/Kalimdor/zone_orgrimmar.cpp index fea0e1c48c..8f4988b6a2 100644 --- a/src/server/scripts/Kalimdor/zone_orgrimmar.cpp +++ b/src/server/scripts/Kalimdor/zone_orgrimmar.cpp @@ -58,7 +58,7 @@ public: bool CanEmote; uint32 SaluteTimer; uint32 ResetTimer; - uint64 PlayerGUID; + ObjectGuid PlayerGUID; void Reset() override { @@ -66,7 +66,7 @@ public: CanEmote = false; SaluteTimer = 6000; ResetTimer = 0; - PlayerGUID = 0; + PlayerGUID.Clear(); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Kalimdor/zone_silithus.cpp b/src/server/scripts/Kalimdor/zone_silithus.cpp index 500f51a5bd..cd51a1d23b 100644 --- a/src/server/scripts/Kalimdor/zone_silithus.cpp +++ b/src/server/scripts/Kalimdor/zone_silithus.cpp @@ -89,7 +89,7 @@ public: case GOSSIP_ACTION_INFO_DEF + 6: SendGossipMenuFor(player, 7761, creature->GetGUID()); //'kill' our trigger to update quest status - player->KilledMonsterCredit(TRIGGER_RUTGAR, 0); + player->KilledMonsterCredit(TRIGGER_RUTGAR); break; case GOSSIP_ACTION_INFO_DEF + 9: @@ -115,7 +115,7 @@ public: case GOSSIP_ACTION_INFO_DEF + 14: SendGossipMenuFor(player, 7767, creature->GetGUID()); //'kill' our trigger to update quest status - player->KilledMonsterCredit(TRIGGER_FRANKAL, 0); + player->KilledMonsterCredit(TRIGGER_FRANKAL); break; } return true; @@ -417,24 +417,24 @@ public: uint32 AnimationTimer; uint8 AnimationCount; - uint64 AnachronosQuestTriggerGUID; - uint64 MerithraGUID; - uint64 ArygosGUID; - uint64 CaelestraszGUID; - uint64 FandralGUID; - uint64 PlayerGUID; + ObjectGuid AnachronosQuestTriggerGUID; + ObjectGuid MerithraGUID; + ObjectGuid ArygosGUID; + ObjectGuid CaelestraszGUID; + ObjectGuid FandralGUID; + ObjectGuid PlayerGUID; bool eventEnd; void Reset() override { AnimationTimer = 1500; AnimationCount = 0; - AnachronosQuestTriggerGUID = 0; - MerithraGUID = 0; - ArygosGUID = 0; - CaelestraszGUID = 0; - FandralGUID = 0; - PlayerGUID = 0; + AnachronosQuestTriggerGUID.Clear(); + MerithraGUID.Clear(); + ArygosGUID.Clear(); + CaelestraszGUID.Clear(); + FandralGUID.Clear(); + PlayerGUID.Clear(); eventEnd = false; me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -467,7 +467,7 @@ public: Fandral->AI()->Talk(FANDRAL_SAY_1, me); break; case 2: - Fandral->SetTarget(0); + Fandral->SetTarget(); Merithra->AI()->Talk(MERITHRA_EMOTE_1); break; case 3: @@ -484,7 +484,7 @@ public: Merithra->AI()->Talk(MERITHRA_SAY_2); break; case 7: - Caelestrasz->SetTarget(0); + Caelestrasz->SetTarget(); Merithra->GetMotionMaster()->MoveCharge(-8065, 1530, 2.61f, 10); break; case 8: @@ -741,16 +741,16 @@ public: { npc_qiraj_war_spawnAI(Creature* creature) : ScriptedAI(creature) { } - uint64 MobGUID; - uint64 PlayerGUID; + ObjectGuid MobGUID; + ObjectGuid PlayerGUID; uint32 SpellTimer1, SpellTimer2, SpellTimer3, SpellTimer4; bool Timers; bool hasTarget; void Reset() override { - MobGUID = 0; - PlayerGUID = 0; + MobGUID.Clear(); + PlayerGUID.Clear(); Timers = false; hasTarget = false; } @@ -857,7 +857,7 @@ public: { npc_anachronos_quest_triggerAI(Creature* creature) : ScriptedAI(creature) { } - uint64 PlayerGUID; + ObjectGuid PlayerGUID; uint32 WaveTimer; uint32 AnnounceTimer; @@ -871,7 +871,7 @@ public: void Reset() override { - PlayerGUID = 0; + PlayerGUID.Clear(); WaveTimer = 2000; AnnounceTimer = 1000; diff --git a/src/server/scripts/Kalimdor/zone_tanaris.cpp b/src/server/scripts/Kalimdor/zone_tanaris.cpp index 40b75ff60c..bd58aa62a8 100644 --- a/src/server/scripts/Kalimdor/zone_tanaris.cpp +++ b/src/server/scripts/Kalimdor/zone_tanaris.cpp @@ -520,7 +520,7 @@ public: uint32 PostEventTimer; uint32 PhasePostEvent; - uint64 TortaGUID; + ObjectGuid TortaGUID; void Reset() override { @@ -528,7 +528,7 @@ public: PostEventTimer = 1000; PhasePostEvent = 0; - TortaGUID = 0; + TortaGUID.Clear(); } void MoveInLineOfSight(Unit* who) override diff --git a/src/server/scripts/Kalimdor/zone_the_barrens.cpp b/src/server/scripts/Kalimdor/zone_the_barrens.cpp index ed08a8572c..0e560b90c3 100644 --- a/src/server/scripts/Kalimdor/zone_the_barrens.cpp +++ b/src/server/scripts/Kalimdor/zone_the_barrens.cpp @@ -309,9 +309,9 @@ public: uint8 Wave; uint32 WaveTimer; uint32 ChallengerChecker; - uint64 PlayerGUID; - uint64 AffrayChallenger[6]; - uint64 BigWill; + ObjectGuid PlayerGUID; + ObjectGuid AffrayChallenger[6]; + ObjectGuid BigWill; void Reset() override { @@ -321,14 +321,15 @@ public: WaveTimer = 600000; ChallengerChecker = 0; Wave = 0; - PlayerGUID = 0; + PlayerGUID.Clear(); for (uint8 i = 0; i < 6; ++i) { - AffrayChallenger[i] = 0; + AffrayChallenger[i].Clear(); ChallengerDown[i] = false; } - BigWill = 0; + + BigWill.Clear(); } void EnterCombat(Unit* /*who*/) override { } diff --git a/src/server/scripts/Kalimdor/zone_ungoro_crater.cpp b/src/server/scripts/Kalimdor/zone_ungoro_crater.cpp index 0e1aca4169..b13875a07d 100644 --- a/src/server/scripts/Kalimdor/zone_ungoro_crater.cpp +++ b/src/server/scripts/Kalimdor/zone_ungoro_crater.cpp @@ -189,14 +189,14 @@ public: uint32 EndEventProgress; uint32 EndEventTimer; - uint64 SpraggleGUID; + ObjectGuid SpraggleGUID; void Reset() override { FaintTimer = urand(30000, 60000); EndEventProgress = 0; EndEventTimer = 1000; - SpraggleGUID = 0; + SpraggleGUID.Clear(); } void MoveInLineOfSight(Unit* who) override diff --git a/src/server/scripts/Kalimdor/zone_winterspring.cpp b/src/server/scripts/Kalimdor/zone_winterspring.cpp index f904d43467..6ae96164db 100644 --- a/src/server/scripts/Kalimdor/zone_winterspring.cpp +++ b/src/server/scripts/Kalimdor/zone_winterspring.cpp @@ -89,7 +89,7 @@ public: } } - uint64 playerGUID; + ObjectGuid playerGUID; EventMap events; uint32 changeEntry; bool damaged; @@ -100,7 +100,7 @@ public: me->UpdateEntry(me->GetOriginalEntry()); events.Reset(); - playerGUID = 0; + playerGUID.Clear(); damaged = false; } @@ -108,7 +108,7 @@ public: { if (!damaged) { - if (who && who->GetGUID() != playerGUID && (who->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(who->GetOwnerGUID()))) + if (who && who->GetGUID() != playerGUID && (who->GetTypeId() == TYPEID_PLAYER || who->GetOwnerGUID().IsPlayer())) { damaged = true; me->CastSpell(who, SPELL_FOOLS_PLIGHT, true); @@ -497,11 +497,11 @@ public: uint32 _delayTimer; - uint64 _firstPriestessGUID; - uint64 _secondPriestessGUID; - uint64 _guardEluneGUID; - uint64 _voiceEluneGUID; - uint64 _altarGUID; + ObjectGuid _firstPriestessGUID; + ObjectGuid _secondPriestessGUID; + ObjectGuid _guardEluneGUID; + ObjectGuid _voiceEluneGUID; + ObjectGuid _altarGUID; void Reset() override { diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp index 66bb0f4ed1..eee77a547e 100644 --- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp @@ -26,8 +26,6 @@ public: { SetBossNumber(MAX_ENCOUNTERS); LoadDoorData(doorData); - _krikthirGUID = 0; - _hadronoxGUID = 0; }; void OnCreatureCreate(Creature* creature) override @@ -114,8 +112,8 @@ public: } private: - uint64 _krikthirGUID; - uint64 _hadronoxGUID; + ObjectGuid _krikthirGUID; + ObjectGuid _hadronoxGUID; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp index 51244f071c..a7db073cdb 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp @@ -253,7 +253,7 @@ public: if (me->GetEntry() == NPC_AHNKAHAR_GUARDIAN_ENTRY) { if (InstanceScript* pInstance = me->GetInstanceScript()) - if (Creature* nadox = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_ELDER_NADOX))) + if (Creature* nadox = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_ELDER_NADOX))) nadox->AI()->DoAction(ACTION_GUARDIAN_DIED); me->RemoveAllAuras(); diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp index 2cb2f7469d..23c9deed0e 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp @@ -200,9 +200,9 @@ public: } uint16 phase = 1; - for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr) + for (ObjectGuid guid : summons) { - if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr)) + if (Creature* summon = ObjectAccessor::GetCreature(*me, guid)) phase |= summon->GetPhaseMask(); } diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp index 245bd7ea53..ed7d4270ac 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp @@ -144,7 +144,7 @@ public: uint8 rnd = urand(0, summons.size() - 1); uint8 loop = 0; - for (std::list<uint64>::iterator i = summons.begin(); i != summons.end();) + for (GuidList::iterator i = summons.begin(); i != summons.end();) { Creature* summon = ObjectAccessor::GetCreature(*me, *i); if (summon && summon->GetEntry() == NPC_INITIATE && loop >= rnd) @@ -450,7 +450,7 @@ public: if (!pInstance || Killer == me) return; - Creature* boss = me->GetMap()->GetCreature(pInstance->GetData64(DATA_JEDOGA_SHADOWSEEKER)); + Creature* boss = me->GetMap()->GetCreature(pInstance->GetGuidData(DATA_JEDOGA_SHADOWSEEKER)); if (boss) { if (Timer) @@ -475,7 +475,7 @@ public: { Unit::Kill(me, me); me->DespawnOrUnsummon(5000); - Creature* boss = me->GetMap()->GetCreature(pInstance->GetData64(DATA_JEDOGA_SHADOWSEEKER)); + Creature* boss = me->GetMap()->GetCreature(pInstance->GetGuidData(DATA_JEDOGA_SHADOWSEEKER)); if (boss) boss->AI()->DoAction(ACTION_HERALD); } diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp index 84206994da..4e69e5d1a6 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp @@ -70,7 +70,7 @@ public: InstanceScript* pInstance; EventMap events; SummonList summons; - uint64 vanishTarget; + ObjectGuid vanishTarget; uint32 vanishDamage; void Reset() override @@ -81,7 +81,7 @@ public: events.Reset(); summons.DespawnAll(); vanishDamage = 0; - vanishTarget = 0; + vanishTarget.Clear(); if (pInstance) { @@ -105,7 +105,7 @@ public: me->UpdatePosition(me->GetPositionX(), me->GetPositionY(), DATA_GROUND_POSITION_Z, me->GetOrientation(), true); if (pInstance) - pInstance->HandleGameObject(pInstance->GetData64(DATA_PRINCE_TALDARAM_PLATFORM), true); + pInstance->HandleGameObject(pInstance->GetGuidData(DATA_PRINCE_TALDARAM_PLATFORM), true); } } @@ -126,7 +126,7 @@ public: events.Reset(); events.ScheduleEvent(EVENT_PRINCE_FLAME_SPHERES, 10000); events.ScheduleEvent(EVENT_PRINCE_BLOODTHIRST, 10000); - vanishTarget = 0; + vanishTarget.Clear(); vanishDamage = 0; } @@ -334,7 +334,7 @@ public: if (!pInstance) return false; - Creature* pPrinceTaldaram = ObjectAccessor::GetCreature(*go, pInstance->GetData64(DATA_PRINCE_TALDARAM)); + Creature* pPrinceTaldaram = ObjectAccessor::GetCreature(*go, pInstance->GetGuidData(DATA_PRINCE_TALDARAM)); if (pPrinceTaldaram && pPrinceTaldaram->IsAlive()) { go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp index 66c03e3b2b..186072377c 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp @@ -17,14 +17,14 @@ public: { instance_ahnkahet_InstanceScript(Map* pMap) : InstanceScript(pMap) {Initialize();}; - uint64 Elder_Nadox; - uint64 Prince_Taldaram; - uint64 Jedoga_Shadowseeker; - uint64 Herald_Volazj; - uint64 Amanitar; + ObjectGuid Elder_Nadox; + ObjectGuid Prince_Taldaram; + ObjectGuid Jedoga_Shadowseeker; + ObjectGuid Herald_Volazj; + ObjectGuid Amanitar; - uint64 Prince_TaldaramPlatform; - uint64 Prince_TaldaramGate; + ObjectGuid Prince_TaldaramPlatform; + ObjectGuid Prince_TaldaramGate; uint32 m_auiEncounter[MAX_ENCOUNTER]; uint32 spheres; @@ -36,14 +36,6 @@ public: { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - Elder_Nadox = 0; - Prince_Taldaram = 0; - Jedoga_Shadowseeker = 0; - Herald_Volazj = 0; - Amanitar = 0; - - Prince_TaldaramPlatform = 0; - Prince_TaldaramGate = 0; spheres = NOT_STARTED; nadoxAchievement = false; @@ -87,7 +79,7 @@ public: case 193564: Prince_TaldaramPlatform = pGo->GetGUID(); if (m_auiEncounter[1] == DONE) - HandleGameObject(0, true, pGo); + HandleGameObject(ObjectGuid::Empty, true, pGo); break; case 193093: @@ -113,13 +105,13 @@ public: case 192236: Prince_TaldaramGate = pGo->GetGUID(); // Web gate past Prince Taldaram if (m_auiEncounter[1] == DONE) - HandleGameObject(0, true, pGo); + HandleGameObject(ObjectGuid::Empty, true, pGo); break; } } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { switch(identifier) { @@ -137,7 +129,7 @@ public: return Prince_TaldaramPlatform; } - return 0; + return ObjectGuid::Empty; } bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/, uint32 /*miscvalue1*/) override diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp index b612ad6cde..977250f060 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp @@ -291,7 +291,7 @@ public: // Store dragons for (uint8 i = 0; i < MAX_DRAGONS; ++i) { - Creature* dragon = ObjectAccessor::GetCreature(*me, instance->GetData64(dragons[i])); + Creature* dragon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(dragons[i])); if (!dragon || !dragon->IsAlive() || instance->GetBossState(dragons[i]) == DONE) { continue; @@ -420,7 +420,7 @@ public: summons.RemoveNotExisting(); if (!summons.empty()) { - for (uint64 const summonGuid : summons) + for (ObjectGuid const summonGuid : summons) { Creature* summon = ObjectAccessor::GetCreature(*me, summonGuid); if (summon && summon->GetEntry() == NPC_FIRE_CYCLONE) @@ -486,7 +486,7 @@ public: case EVENT_SARTHARION_CALL_TENEBRON: { Talk(SAY_SARTHARION_CALL_TENEBRON); - if (Creature* tenebron = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_TENEBRON))) + if (Creature* tenebron = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_TENEBRON))) { tenebron->AI()->DoAction(ACTION_CALL_DRAGON); } @@ -495,7 +495,7 @@ public: case EVENT_SARTHARION_CALL_SHADRON: { Talk(SAY_SARTHARION_CALL_SHADRON); - if (Creature* shadron = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SHADRON))) + if (Creature* shadron = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON))) { shadron->AI()->DoAction(ACTION_CALL_DRAGON); } @@ -504,7 +504,7 @@ public: case EVENT_SARTHARION_CALL_VESPERON: { Talk(SAY_SARTHARION_CALL_VESPERON); - if (Creature* vesperon = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_VESPERON))) + if (Creature* vesperon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VESPERON))) { vesperon->AI()->DoAction(ACTION_CALL_DRAGON); } @@ -556,7 +556,7 @@ public: uint8 iter = 0; if (!summons.empty()) { - for (uint64 const summonGuid : summons) + for (ObjectGuid const summonGuid : summons) { Creature* summon = ObjectAccessor::GetCreature(*me, summonGuid); if (summon && summon->GetEntry() == NPC_FIRE_CYCLONE && iter == rand) @@ -636,7 +636,7 @@ public: return; } - for (uint64 const guid : summons) + for (ObjectGuid const guid : summons) { Creature* tsunami = ObjectAccessor::GetCreature(*me, guid); if (!tsunami || tsunami->GetEntry() != NPC_FLAME_TSUNAMI) @@ -664,7 +664,7 @@ public: continue; } - if (Creature* dragon = ObjectAccessor::GetCreature(*me, instance->GetData64(dragons[i]))) + if (Creature* dragon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(dragons[i]))) { if (checkCombat && dragon->IsInCombat()) { @@ -706,9 +706,7 @@ public: struct boss_sartharion_dragonAI : public BossAI { - boss_sartharion_dragonAI(Creature* pCreature, uint32 bossId) : BossAI(pCreature, bossId), - portalGUID(0), - isCalledBySartharion(false) + boss_sartharion_dragonAI(Creature* pCreature, uint32 bossId) : BossAI(pCreature, bossId), isCalledBySartharion(false) { } @@ -722,7 +720,7 @@ struct boss_sartharion_dragonAI : public BossAI me->SetSpeed(MOVE_FLIGHT, 1.0f); me->SetCanFly(false); me->ResetLootMode(); - portalGUID = 0; + portalGUID.Clear(); isCalledBySartharion = false; instance->DoAction(ACTION_CLEAR_PORTAL); } @@ -788,7 +786,7 @@ struct boss_sartharion_dragonAI : public BossAI // Transfer summons to Sartharion if (isCalledBySartharion && instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS) { - if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SARTHARION))) + if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) { sartharion->AI()->JustSummoned(summon); } @@ -872,7 +870,7 @@ struct boss_sartharion_dragonAI : public BossAI Talk(SAY_SHADRON_DEATH); if (isCalledBySartharion) { - if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SARTHARION))) + if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) { sartharion->RemoveAura(SPELL_GIFT_OF_TWILIGHT_FIRE); } @@ -902,7 +900,7 @@ struct boss_sartharion_dragonAI : public BossAI } else { - if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SARTHARION))) + if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) { sartharion->AI()->DoAction(ACTION_DRAKE_DIED); } @@ -989,12 +987,12 @@ protected: gobj->Delete(); } - portalGUID = 0; + portalGUID.Clear(); } } EventMap extraEvents; - uint64 portalGUID; + ObjectGuid portalGUID; bool isCalledBySartharion; }; @@ -1115,7 +1113,7 @@ public: summons.Summon(egg); if (isCalledBySartharion && instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS) { - if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SARTHARION))) + if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) { sartharion->AI()->JustSummoned(egg); } @@ -1131,7 +1129,7 @@ public: { summons.RemoveNotExisting(); summons.DespawnEntry(NPC_TWILIGHT_WHELP); - for (uint64 const summonGuid : summons) + for (ObjectGuid const summonGuid : summons) { Creature const* summon = ObjectAccessor::GetCreature(*me, summonGuid); if (!summon || !summon->IsAlive() || summon->GetEntry() != NPC_TWILIGHT_EGG) @@ -1144,7 +1142,7 @@ public: summons2.Summon(whelp); if (isCalledBySartharion && instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS) { - if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SARTHARION))) + if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) { sartharion->AI()->JustSummoned(whelp); } @@ -1219,7 +1217,7 @@ public: instance->DoAction(ACTION_CLEAR_PORTAL); } - if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SARTHARION))) + if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) { sartharion->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGHT_FIRE); } @@ -1534,9 +1532,9 @@ public: if (InstanceScript* pInstance = GetCaster()->GetInstanceScript()) { - if (Creature* sarth = ObjectAccessor::GetCreature(*GetHitUnit(), pInstance->GetData64(DATA_SARTHARION))) + if (Creature* sarth = ObjectAccessor::GetCreature(*GetHitUnit(), pInstance->GetGuidData(DATA_SARTHARION))) { - sarth->AI()->SetData(DATA_VOLCANO_BLOWS, GetHitUnit()->GetGUIDLow()); + sarth->AI()->SetData(DATA_VOLCANO_BLOWS, GetHitUnit()->GetGUID().GetCounter()); sarth->CastSpell(GetHitUnit(), SPELL_LAVA_STRIKE_SUMMON, true); spawned = true; } diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/instance_obsidian_sanctum.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/instance_obsidian_sanctum.cpp index b87a87bcaa..1ab41c00f1 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/instance_obsidian_sanctum.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/instance_obsidian_sanctum.cpp @@ -20,13 +20,7 @@ public: struct instance_obsidian_sanctum_InstanceMapScript : public InstanceScript { - instance_obsidian_sanctum_InstanceMapScript(Map* pMap) : InstanceScript(pMap), - m_uiSartharionGUID(0), - m_uiTenebronGUID(0), - m_uiShadronGUID(0), - m_uiVesperonGUID(0), - m_uiPortalGUID(0), - portalCount(0) + instance_obsidian_sanctum_InstanceMapScript(Map* pMap) : InstanceScript(pMap), portalCount(0) { SetBossNumber(MAX_ENCOUNTERS); } @@ -61,7 +55,7 @@ public: } } - uint64 GetData64(uint32 uiData) const override + ObjectGuid GetGuidData(uint32 uiData) const override { switch(uiData) { @@ -74,7 +68,8 @@ public: case DATA_VESPERON: return m_uiVesperonGUID; } - return 0; + + return ObjectGuid::Empty; } bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* source, Unit const* /*target*/, uint32 /*miscvalue1*/) override @@ -87,7 +82,7 @@ public: case 7327: { Creature const* sartharion = instance->GetCreature(m_uiSartharionGUID); - return sartharion && !sartharion->AI()->GetData(source->GetGUIDLow()); + return sartharion && !sartharion->AI()->GetData(source->GetGUID().GetCounter()); } // Less Is More (10 player) (624) case 7189: @@ -182,7 +177,7 @@ public: } DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_SHIFT); - m_uiPortalGUID = 0; + m_uiPortalGUID.Clear(); } break; } @@ -232,11 +227,11 @@ public: } private: - uint64 m_uiSartharionGUID; - uint64 m_uiTenebronGUID; - uint64 m_uiShadronGUID; - uint64 m_uiVesperonGUID; - uint64 m_uiPortalGUID; + ObjectGuid m_uiSartharionGUID; + ObjectGuid m_uiTenebronGUID; + ObjectGuid m_uiShadronGUID; + ObjectGuid m_uiVesperonGUID; + ObjectGuid m_uiPortalGUID; uint8 portalCount; }; }; diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp index 7355dd762f..741043d728 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp @@ -168,7 +168,7 @@ public: Talk(SAY_DEATH); BossAI::JustDied(killer); - if (Creature* xerestrasza = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_XERESTRASZA))) + if (Creature* xerestrasza = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_XERESTRASZA))) xerestrasza->AI()->DoAction(ACTION_BALTHARUS_DEATH); } @@ -454,10 +454,10 @@ public: { if (InstanceScript* instance = player->GetInstanceScript()) { - if (Creature* xerestrasza = ObjectAccessor::GetCreature(*player, instance->GetData64(NPC_XERESTRASZA))) + if (Creature* xerestrasza = ObjectAccessor::GetCreature(*player, instance->GetGuidData(NPC_XERESTRASZA))) xerestrasza->AI()->DoAction(ACTION_INTRO_BALTHARUS); - if (Creature* baltharus = ObjectAccessor::GetCreature(*player, instance->GetData64(NPC_BALTHARUS_THE_WARBORN))) + if (Creature* baltharus = ObjectAccessor::GetCreature(*player, instance->GetGuidData(NPC_BALTHARUS_THE_WARBORN))) baltharus->AI()->DoAction(ACTION_INTRO_BALTHARUS); } diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_general_zarithrian.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_general_zarithrian.cpp index 33b80f4509..6a842d836e 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_general_zarithrian.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_general_zarithrian.cpp @@ -140,16 +140,16 @@ public: { case EVENT_SUMMON_ADDS1: Talk(SAY_ADDS); - if (Creature* stalker1 = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ZARITHRIAN_SPAWN_STALKER_1))) + if (Creature* stalker1 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ZARITHRIAN_SPAWN_STALKER_1))) stalker1->CastSpell(stalker1, SPELL_SUMMON_FLAMECALLER, false); - if (Creature* stalker2 = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ZARITHRIAN_SPAWN_STALKER_2))) + if (Creature* stalker2 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ZARITHRIAN_SPAWN_STALKER_2))) stalker2->CastSpell(stalker2, SPELL_SUMMON_FLAMECALLER, false); events.ScheduleEvent(EVENT_SUMMON_ADDS1, 40000); break; case EVENT_SUMMON_ADDS2: - if (Creature* stalker1 = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ZARITHRIAN_SPAWN_STALKER_1))) + if (Creature* stalker1 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ZARITHRIAN_SPAWN_STALKER_1))) stalker1->CastSpell(stalker1, SPELL_SUMMON_FLAMECALLER, false); - if (Creature* stalker2 = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ZARITHRIAN_SPAWN_STALKER_2))) + if (Creature* stalker2 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ZARITHRIAN_SPAWN_STALKER_2))) stalker2->CastSpell(stalker2, SPELL_SUMMON_FLAMECALLER, false); events.ScheduleEvent(EVENT_SUMMON_ADDS2, 40000); break; @@ -213,7 +213,7 @@ public: void IsSummonedBy(Unit* /*summoner*/) override { // Let Zarithrian count as summoner. _instance cant be null since we got GetRubySanctumAI - if (Creature* zarithrian = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_GENERAL_ZARITHRIAN))) + if (Creature* zarithrian = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_GENERAL_ZARITHRIAN))) zarithrian->AI()->JustSummoned(me); } diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 3cb223998d..f39caaf01b 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -275,7 +275,7 @@ public: void JustReachedHome() override { instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); - if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_HALION_CONTROLLER))) + if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_HALION_CONTROLLER))) controller->AI()->DoAction(ACTION_RESET_ENCOUNTER); BossAI::JustReachedHome(); } @@ -312,11 +312,11 @@ public: instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); me->CastSpell(me, SPELL_CLEAR_DEBUFFS, false); - if (Creature* twilightHalion = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_TWILIGHT_HALION))) + if (Creature* twilightHalion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_TWILIGHT_HALION))) if (twilightHalion->IsAlive()) Unit::Kill(twilightHalion, twilightHalion); - if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_HALION_CONTROLLER))) + if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_HALION_CONTROLLER))) if (controller->IsAlive()) Unit::Kill(controller, controller); } @@ -329,7 +329,7 @@ public: if (!attacker || !me->InSamePhase(attacker)) return; - if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_HALION_CONTROLLER))) + if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_HALION_CONTROLLER))) controller->AI()->SetData(DATA_MATERIAL_DAMAGE_TAKEN, damage); } @@ -344,7 +344,7 @@ public: break; case EVENT_TRIGGER_BERSERK: me->CastSpell(me, SPELL_BERSERK, true); - if (Creature* twilightHalion = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_TWILIGHT_HALION))) + if (Creature* twilightHalion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_TWILIGHT_HALION))) twilightHalion->CastSpell(twilightHalion, SPELL_BERSERK, true); break; } @@ -375,8 +375,8 @@ public: events.ScheduleEvent(EVENT_BREATH, urand(10000, 12000)); break; case EVENT_ACTIVATE_FIREWALL: - instance->HandleGameObject(instance->GetData64(GO_FLAME_RING), false, nullptr); - instance->HandleGameObject(instance->GetData64(GO_TWILIGHT_FLAME_RING), false, nullptr); + instance->HandleGameObject(instance->GetGuidData(GO_FLAME_RING), false, nullptr); + instance->HandleGameObject(instance->GetGuidData(GO_TWILIGHT_FLAME_RING), false, nullptr); break; case EVENT_METEOR_STRIKE: _livingEmberCount = summons.GetEntryCount(NPC_LIVING_EMBER); @@ -424,7 +424,7 @@ public: { boss_twilight_halionAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_HALION)); + Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_HALION)); if (!halion) return; @@ -474,7 +474,7 @@ public: void JustDied(Unit* killer) override { - if (Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_HALION))) + if (Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_HALION))) { // Ensure looting if (me->IsDamageEnoughForLootingAndReward()) @@ -484,7 +484,7 @@ public: Unit::Kill(killer, halion); } - if (Creature* controller = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_HALION_CONTROLLER))) + if (Creature* controller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_HALION_CONTROLLER))) if (controller->IsAlive()) Unit::Kill(controller, controller); @@ -497,7 +497,7 @@ public: if (!attacker || !me->InSamePhase(attacker)) return; - if (Creature* controller = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_HALION_CONTROLLER))) + if (Creature* controller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_HALION_CONTROLLER))) controller->AI()->SetData(DATA_TWILIGHT_DAMAGE_TAKEN, damage); } @@ -549,7 +549,7 @@ public: _events.ScheduleEvent(EVENT_SHADOW_PULSARS_SHOOT, 5000); break; case EVENT_SHADOW_PULSARS_SHOOT: - if (Creature* orbCarrier = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_ORB_CARRIER))) + if (Creature* orbCarrier = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_ORB_CARRIER))) orbCarrier->AI()->DoAction(ACTION_SHOOT); break; } @@ -642,7 +642,7 @@ public: _events.ScheduleEvent(EVENT_INTRO_PROGRESS_4, 500); break; case EVENT_INTRO_PROGRESS_4: - if (Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_HALION))) + if (Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_HALION))) { halion->SetVisible(true); halion->SetReactState(REACT_AGGRESSIVE); @@ -708,14 +708,14 @@ public: _instance->DoUpdateWorldState(WORLDSTATE_CORPOREALITY_MATERIAL, _corporeality * 10); _instance->DoUpdateWorldState(WORLDSTATE_CORPOREALITY_TWILIGHT, 100 - _corporeality * 10); - if (Creature* twilightHalion = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_TWILIGHT_HALION))) + if (Creature* twilightHalion = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_TWILIGHT_HALION))) { twilightHalion->RemoveAurasDueToSpell(_corporealityReference[MAX_CORPOREALITY_STATE - 1 - oldValue]); twilightHalion->CastSpell(twilightHalion, _corporealityReference[MAX_CORPOREALITY_STATE - 1 - _corporeality], true); twilightHalion->AI()->Talk(oldValue < _corporeality ? EMOTE_CORPOREALITY_TOT : EMOTE_CORPOREALITY_TIT); } - if (Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_HALION))) + if (Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_HALION))) { halion->RemoveAurasDueToSpell(_corporealityReference[oldValue]); halion->CastSpell(halion, _corporealityReference[_corporeality], true); @@ -928,7 +928,7 @@ public: void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(_markSpell, 0, 0, AURA_REMOVE_BY_EXPIRE); + GetTarget()->RemoveAurasDueToSpell(_markSpell, ObjectGuid::Empty, 0, AURA_REMOVE_BY_EXPIRE); } void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -978,7 +978,7 @@ public: if (Unit* dispelledUnit = GetUnitOwner()) if (dispelledUnit->HasAura(_removeSpellId)) - dispelledUnit->RemoveAurasDueToSpell(_removeSpellId, 0, 0, AURA_REMOVE_BY_EXPIRE); + dispelledUnit->RemoveAurasDueToSpell(_removeSpellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_EXPIRE); } void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -1188,7 +1188,7 @@ public: if (!target) return; - target->RemoveAurasDueToSpell(SPELL_FIERY_COMBUSTION, 0, 0, AURA_REMOVE_BY_ENEMY_SPELL); + target->RemoveAurasDueToSpell(SPELL_FIERY_COMBUSTION, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL); if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; GetTarget()->m_Events.AddEvent(new SendEncounterUnit(GetTarget()->ToPlayer()), GetTarget()->m_Events.CalculateTime(500)); @@ -1221,7 +1221,7 @@ public: if (!target) return; - target->RemoveAurasDueToSpell(SPELL_SOUL_CONSUMPTION, 0, 0, AURA_REMOVE_BY_ENEMY_SPELL); + target->RemoveAurasDueToSpell(SPELL_SOUL_CONSUMPTION, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL); } void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*handle*/) @@ -1373,8 +1373,8 @@ public: void HandleDummy(SpellEffIndex /*effIndex*/) { InstanceScript* instance = GetCaster()->GetInstanceScript(); - Creature* controller = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(NPC_HALION_CONTROLLER)); - Creature* halion = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(NPC_HALION)); + Creature* controller = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(NPC_HALION_CONTROLLER)); + Creature* halion = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(NPC_HALION)); if (!controller || !halion) return; @@ -1449,7 +1449,7 @@ public: me->CastSpell(me, SPELL_BLAZING_AURA, true); if (InstanceScript* instance = me->GetInstanceScript()) - if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_HALION_CONTROLLER))) + if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_HALION_CONTROLLER))) controller->AI()->JustSummoned(me); } diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp index 28001afff0..1cf82e3b97 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp @@ -34,17 +34,6 @@ public: { SetBossNumber(MAX_ENCOUNTERS); LoadDoorData(doorData); - - BaltharusTheWarbornGUID = 0; - XerestraszaGUID = 0; - GeneralZarithrianGUID = 0; - memset(ZarithrianSpawnStalkerGUID, 0, 2 * sizeof(uint64)); - - HalionGUID = 0; - TwilightHalionGUID = 0; - OrbCarrierGUID = 0; - HalionControllerGUID = 0; - FlameRingGUID = 0; } void OnPlayerEnter(Player* /*player*/) override @@ -138,7 +127,7 @@ public: } } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -164,7 +153,7 @@ public: return FlameRingGUID; } - return 0; + return ObjectGuid::Empty; } bool SetBossState(uint32 type, EncounterState state) override @@ -255,16 +244,16 @@ public: } protected: - uint64 BaltharusTheWarbornGUID; - uint64 XerestraszaGUID; - uint64 GeneralZarithrianGUID; - uint64 ZarithrianSpawnStalkerGUID[2]; - - uint64 HalionGUID; - uint64 TwilightHalionGUID; - uint64 HalionControllerGUID; - uint64 OrbCarrierGUID; - uint64 FlameRingGUID; + ObjectGuid BaltharusTheWarbornGUID; + ObjectGuid XerestraszaGUID; + ObjectGuid GeneralZarithrianGUID; + ObjectGuid ZarithrianSpawnStalkerGUID[2]; + + ObjectGuid HalionGUID; + ObjectGuid TwilightHalionGUID; + ObjectGuid HalionControllerGUID; + ObjectGuid OrbCarrierGUID; + ObjectGuid FlameRingGUID; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp index 222a6a20b5..c936626aee 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp @@ -210,7 +210,7 @@ public: InstanceScript* pInstance; EventMap events; bool summoned; - uint64 MemoryGUID; + ObjectGuid MemoryGUID; void Reset() override { @@ -220,7 +220,7 @@ public: { if( Creature* memory = ObjectAccessor::GetCreature(*me, MemoryGUID) ) memory->DespawnOrUnsummon(); - MemoryGUID = 0; + MemoryGUID.Clear(); } me->SetReactState(REACT_PASSIVE); if( pInstance ) @@ -259,7 +259,7 @@ public: { if( param == 1 ) { - MemoryGUID = 0; + MemoryGUID.Clear(); me->RemoveAura(SPELL_SHIELD); Talk(TEXT_PALETRESS_MEMORY_DEFEATED); } @@ -269,7 +269,7 @@ public: if( Creature* memory = ObjectAccessor::GetCreature(*me, MemoryGUID) ) { memory->DespawnOrUnsummon(); - MemoryGUID = 0; + MemoryGUID.Clear(); } } } @@ -403,7 +403,7 @@ public: { me->DespawnOrUnsummon(20000); if( pInstance ) - if( Creature* paletress = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_PALETRESS)) ) + if( Creature* paletress = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_PALETRESS)) ) paletress->AI()->DoAction(1); } @@ -598,7 +598,7 @@ public: break; } - Start(false, true, 0); + Start(false, true); uiWaypoint = uiType; } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp index 9080ca3443..9ac81493bb 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp @@ -162,7 +162,7 @@ public: pInstance->SetData(BOSS_BLACK_KNIGHT, IN_PROGRESS); Talk(TEXT_BK_AGGRO); me->CastSpell((Unit*)nullptr, (pInstance->GetData(DATA_TEAMID_IN_INSTANCE) == TEAM_HORDE ? SPELL_RAISE_DEAD_JAEREN : SPELL_RAISE_DEAD_ARELAS), false); - if( Creature* announcer = pInstance->instance->GetCreature(pInstance->GetData64(DATA_ANNOUNCER)) ) + if( Creature* announcer = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_ANNOUNCER)) ) announcer->DespawnOrUnsummon(); events.Reset(); @@ -327,7 +327,7 @@ public: void Reset() override { - Start(false, true, 0, nullptr); + Start(false, true, ObjectGuid::Empty, nullptr); SetDespawnAtEnd(true); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp index d2b4c980c8..ddc58f11f9 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp @@ -263,7 +263,7 @@ public: break; case EVENT_MOUNT_CHARGE: { - std::vector<uint64> LIST; + GuidVector LIST; Map::PlayerList const& pl = me->GetMap()->GetPlayers(); for( Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr ) if( Player* plr = itr->GetSource() ) @@ -294,7 +294,7 @@ public: break; case EVENT_SHIELD_BREAKER: { - std::vector<uint64> LIST; + GuidVector LIST; Map::PlayerList const& pl = me->GetMap()->GetPlayers(); for( Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr ) if( Player* plr = itr->GetSource() ) @@ -346,7 +346,7 @@ public: SetDespawnAtEnd(false); me->SetReactState(REACT_PASSIVE); BossOrder = 0; - NewMountGUID = 0; + NewMountGUID.Clear(); me->CastSpell(me, SPELL_BOSS_DEFEND_PERIODIC, true); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); @@ -379,8 +379,8 @@ public: EventMap events; uint32 BossOrder; bool MountPhase; - uint64 NewMountGUID; - uint64 UnitTargetGUID; + ObjectGuid NewMountGUID; + ObjectGuid UnitTargetGUID; void Reset() override { @@ -471,7 +471,7 @@ public: if( param == 1 ) { MountPhase = false; - NewMountGUID = 0; + NewMountGUID.Clear(); me->SetHealth(me->GetMaxHealth()); me->SetRegeneratingHealth(true); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); @@ -522,7 +522,7 @@ public: return; } - Start(false, true, 0, nullptr); + Start(false, true); } void DamageTaken(Unit*, uint32& damage, DamageEffectType, SpellSchoolMask) override @@ -621,7 +621,7 @@ public: me->CastSpell(me, SPELL_TRAMPLE_AURA, true); if( pInstance ) pInstance->SetData(DATA_REACHED_NEW_MOUNT, 0); - NewMountGUID = 0; + NewMountGUID.Clear(); } } else if( id == 9 ) @@ -716,7 +716,7 @@ public: break; case EVENT_MOUNT_CHARGE: { - std::vector<uint64> LIST; + GuidVector LIST; Map::PlayerList const& pl = me->GetMap()->GetPlayers(); for( Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr ) if( Player* plr = itr->GetSource() ) @@ -747,7 +747,7 @@ public: break; case EVENT_SHIELD_BREAKER: { - std::vector<uint64> LIST; + GuidVector LIST; Map::PlayerList const& pl = me->GetMap()->GetPlayers(); for( Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr ) if( Player* plr = itr->GetSource() ) @@ -865,7 +865,7 @@ public: } } } - UnitTargetGUID = 0; + UnitTargetGUID.Clear(); } events.RepeatEvent(urand(15000, 20000)); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp index 21520395dc..d255bf38ba 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp @@ -34,24 +34,24 @@ public: uint32 m_auiEncounter[MAX_ENCOUNTER]; std::string str_data; - std::list<uint64> VehicleList; + GuidList VehicleList; EventMap events; uint8 Counter; uint8 temp1, temp2; bool shortver; bool bAchievIveHadWorse; - uint64 NPC_AnnouncerGUID; - uint64 NPC_TirionGUID; - uint64 NPC_GrandChampionGUID[3]; - uint64 NPC_GrandChampionMinionsGUID[3][3]; - uint64 NPC_ArgentChampionGUID; - uint64 NPC_ArgentSoldierGUID[3][3]; - uint64 NPC_MemoryEntry; - uint64 NPC_BlackKnightVehicleGUID; - uint64 NPC_BlackKnightGUID; - uint64 GO_MainGateGUID; - uint64 GO_EnterGateGUID; + ObjectGuid NPC_AnnouncerGUID; + ObjectGuid NPC_TirionGUID; + ObjectGuid NPC_GrandChampionGUID[3]; + ObjectGuid NPC_GrandChampionMinionsGUID[3][3]; + ObjectGuid NPC_ArgentChampionGUID; + ObjectGuid NPC_ArgentSoldierGUID[3][3]; + uint32 NPC_MemoryEntry; + ObjectGuid NPC_BlackKnightVehicleGUID; + ObjectGuid NPC_BlackKnightGUID; + ObjectGuid GO_MainGateGUID; + ObjectGuid GO_EnterGateGUID; void Initialize() override { @@ -68,18 +68,6 @@ public: temp2 = 0; shortver = false; bAchievIveHadWorse = true; - - NPC_AnnouncerGUID = 0; - NPC_TirionGUID = 0; - memset(&NPC_GrandChampionGUID, 0, sizeof(NPC_GrandChampionGUID)); - memset(&NPC_GrandChampionMinionsGUID, 0, sizeof(NPC_GrandChampionMinionsGUID)); - memset(&NPC_ArgentSoldierGUID, 0, sizeof(NPC_ArgentSoldierGUID)); - NPC_ArgentChampionGUID = 0; - NPC_MemoryEntry = 0; - NPC_BlackKnightVehicleGUID = 0; - NPC_BlackKnightGUID = 0; - GO_MainGateGUID = 0; - GO_EnterGateGUID = 0; } bool IsEncounterInProgress() const override @@ -291,8 +279,8 @@ public: case INSTANCE_PROGRESS_CHAMPION_GROUP_DIED_3: // revert to INSTANCE_PROGRESS_INITIAL { - for( std::list<uint64>::const_iterator itr = VehicleList.begin(); itr != VehicleList.end(); ++itr ) - if( Creature* veh = instance->GetCreature(*itr) ) + for (ObjectGuid const guid : VehicleList) + if (Creature* veh = instance->GetCreature(guid)) { veh->DespawnOrUnsummon(); veh->SetRespawnTime(3); @@ -303,11 +291,11 @@ public: { if( Creature* c = instance->GetCreature(NPC_GrandChampionMinionsGUID[i][j]) ) c->DespawnOrUnsummon(); - NPC_GrandChampionMinionsGUID[i][j] = 0; + NPC_GrandChampionMinionsGUID[i][j].Clear(); } if( Creature* c = instance->GetCreature(NPC_GrandChampionGUID[i]) ) c->DespawnOrUnsummon(); - NPC_GrandChampionGUID[i] = 0; + NPC_GrandChampionGUID[i].Clear(); } if( Creature* c = instance->GetCreature(NPC_AnnouncerGUID) ) { @@ -372,14 +360,14 @@ public: { if( Creature* c = instance->GetCreature(NPC_ArgentSoldierGUID[i][j]) ) c->DespawnOrUnsummon(); - NPC_ArgentSoldierGUID[i][j] = 0; + NPC_ArgentSoldierGUID[i][j].Clear(); } if( Creature* c = instance->GetCreature(NPC_ArgentChampionGUID) ) { c->AI()->DoAction(-1); // paletress despawn memory c->DespawnOrUnsummon(); } - NPC_ArgentChampionGUID = 0; + NPC_ArgentChampionGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_AnnouncerGUID) ) { c->DespawnOrUnsummon(); @@ -397,13 +385,13 @@ public: { if( Creature* c = instance->GetCreature(NPC_BlackKnightVehicleGUID) ) c->DespawnOrUnsummon(); - NPC_BlackKnightVehicleGUID = 0; + NPC_BlackKnightVehicleGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_BlackKnightGUID) ) { c->AI()->DoAction(-1); c->DespawnOrUnsummon(); } - NPC_BlackKnightGUID = 0; + NPC_BlackKnightGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_AnnouncerGUID) ) { c->DespawnOrUnsummon(); @@ -444,7 +432,7 @@ public: return 0; } - uint64 GetData64(uint32 uiData) const override + ObjectGuid GetGuidData(uint32 uiData) const override { switch( uiData ) { @@ -454,7 +442,7 @@ public: return NPC_ArgentChampionGUID; } - return 0; + return ObjectGuid::Empty; } void SetData(uint32 uiType, uint32 uiData) override @@ -579,8 +567,8 @@ public: { Counter = 0; InstanceProgress = INSTANCE_PROGRESS_CHAMPIONS_UNMOUNTED; - for( std::list<uint64>::const_iterator itr = VehicleList.begin(); itr != VehicleList.end(); ++itr ) - if( Creature* veh = instance->GetCreature(*itr) ) + for (ObjectGuid const guid : VehicleList) + if (Creature* veh = instance->GetCreature(guid)) veh->DespawnOrUnsummon(); events.ScheduleEvent(EVENT_GRAND_CHAMPIONS_MOVE_SIDE, 0); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index 9809c56481..fb988b05f5 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -157,8 +157,8 @@ public: EventMap events; bool bIntro; bool bPhase3; - uint64 SphereGUID[6]; - uint64 BurrowGUID[4]; + ObjectGuid SphereGUID[6]; + ObjectGuid BurrowGUID[4]; void Reset() override { @@ -200,9 +200,9 @@ public: if( !IsHeroic() ) events.RescheduleEvent(EVENT_RESPAWN_SPHERE, 4000); - for( std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr ) + for (ObjectGuid guid : summons) if (pInstance) - if(Creature* c = pInstance->instance->GetCreature(*itr) ) + if (Creature* c = pInstance->instance->GetCreature(guid)) { c->GetMotionMaster()->MoveIdle(); c->StopMoving(); @@ -621,7 +621,7 @@ public: { // I am summoned by another npc (SPELL_EFFECT_FORCE_CAST), inform Anub'arak if (InstanceScript* pInstance = me->GetInstanceScript()) - if (uint64 guid = pInstance->GetData64(TYPE_ANUBARAK)) + if (ObjectGuid guid = pInstance->GetGuidData(TYPE_ANUBARAK)) if (Creature* anub = pInstance->instance->GetCreature(guid)) CAST_AI(boss_anubarak_trial::boss_anubarak_trialAI, anub->AI())->JustSummoned(me); } @@ -743,7 +743,7 @@ public: } EventMap events; - uint64 TargetGUID; + ObjectGuid TargetGUID; void DoAction(int32 param) override { @@ -751,7 +751,7 @@ public: { if( Unit* target = ObjectAccessor::GetPlayer(*me, TargetGUID) ) target->RemoveAura(SPELL_MARK); - TargetGUID = 0; + TargetGUID.Clear(); me->RemoveAllAuras(); me->GetMotionMaster()->MoveIdle(); events.Reset(); @@ -764,7 +764,7 @@ public: if (TargetGUID) if( Unit* target = ObjectAccessor::GetPlayer(*me, TargetGUID) ) target->RemoveAura(SPELL_MARK); - TargetGUID = 0; + TargetGUID.Clear(); if (!next) { events.Reset(); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp index 3a56174965..96b988f2b0 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp @@ -76,13 +76,13 @@ public: npc_snobold_vassalAI(Creature* pCreature) : ScriptedAI(pCreature) { pInstance = pCreature->GetInstanceScript(); - TargetGUID = 0; + TargetGUID.Clear(); me->SetReactState(REACT_PASSIVE); } InstanceScript* pInstance; EventMap events; - uint64 TargetGUID; + ObjectGuid TargetGUID; void Reset() override { @@ -124,7 +124,7 @@ public: me->CombatStop(true); me->SetHealth(me->GetMaxHealth()); if( pInstance ) - if( Creature* gormok = ObjectAccessor::GetCreature(*me, pInstance->GetData64(TYPE_GORMOK)) ) + if( Creature* gormok = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(TYPE_GORMOK)) ) if( gormok->IsAlive() ) if( Vehicle* vk = gormok->GetVehicleKit() ) for( uint8 i = 0; i < 4; ++i ) @@ -134,7 +134,7 @@ public: Reset(); break; } - TargetGUID = 0; + TargetGUID.Clear(); return; } @@ -161,9 +161,9 @@ public: { if( t->GetTypeId() != TYPEID_PLAYER && pInstance ) { - std::vector<uint64> validPlayers; + GuidVector validPlayers; Map::PlayerList const& pl = me->GetMap()->GetPlayers(); - Creature* gormok = ObjectAccessor::GetCreature(*me, pInstance->GetData64(TYPE_GORMOK)); + Creature* gormok = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(TYPE_GORMOK)); for( Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr ) { @@ -234,13 +234,13 @@ public: InstanceScript* pInstance; EventMap events; SummonList summons; - uint64 PlayerGUID; + ObjectGuid PlayerGUID; void Reset() override { events.Reset(); summons.DespawnAll(); - PlayerGUID = 0; + PlayerGUID.Clear(); } void EnterCombat(Unit* /*who*/) override @@ -298,7 +298,7 @@ public: for( uint8 i = 0; i < 4; ++i ) if( Unit* snobold = vk->GetPassenger(i) ) { - std::vector<uint64> validPlayers; + GuidVector validPlayers; Map::PlayerList const& pl = me->GetMap()->GetPlayers(); for( Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr ) { @@ -358,7 +358,7 @@ public: snobold->ToCreature()->DespawnOrUnsummon(); } } - PlayerGUID = 0; + PlayerGUID.Clear(); } break; } @@ -561,7 +561,7 @@ struct boss_jormungarAI : public ScriptedAI // second one submerge 1.5sec after the first one, used also for synchronizing if( pInstance ) - if( Creature* c = ObjectAccessor::GetCreature(*me, pInstance->GetData64(_TYPE_OTHER)) ) + if( Creature* c = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(_TYPE_OTHER)) ) c->AI()->DoAction(-1); events.Reset(); @@ -647,7 +647,7 @@ struct boss_jormungarAI : public ScriptedAI { if( pInstance ) { - if( Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(_TYPE_OTHER)) ) + if( Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(_TYPE_OTHER)) ) if( c->IsAlive() ) c->AI()->DoAction(-2); pInstance->SetData(TYPE_JORMUNGAR, DONE); @@ -776,7 +776,7 @@ public: InstanceScript* pInstance; EventMap events; - uint64 TargetGUID; + ObjectGuid TargetGUID; float destX, destY, destZ; void AttackStart(Unit* who) override @@ -882,7 +882,7 @@ public: me->SetReactState(REACT_PASSIVE); me->AttackStop(); me->GetMotionMaster()->MoveJump(Locs[LOC_CENTER].GetPositionX(), Locs[LOC_CENTER].GetPositionY(), Locs[LOC_CENTER].GetPositionZ(), 40.0f, 12.0f); - me->SetUInt64Value(UNIT_FIELD_TARGET, 0); + me->SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty); events.Reset(); events.RescheduleEvent(EVENT_SPELL_MASSIVE_CRASH, 2000); break; @@ -893,10 +893,10 @@ public: events.RescheduleEvent(EVENT_GAZE, 2000); break; case EVENT_GAZE: - if( Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 500.0f, true) ) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 500.0f, true) ) { TargetGUID = target->GetGUID(); - me->SetUInt64Value(UNIT_FIELD_TARGET, TargetGUID); + me->SetGuidValue(UNIT_FIELD_TARGET, TargetGUID); me->SetFacingToObject(target); Talk(EMOTE_TRAMPLE_STARE, target); me->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); @@ -958,7 +958,7 @@ public: me->DisableSpline(); me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveCharge(destX, destY, destZ + 1.0f, 65.0f); - me->SetUInt64Value(UNIT_FIELD_TARGET, 0); + me->SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty); events.RescheduleEvent(EVENT_CHECK_TRAMPLE_PLAYERS, 100); break; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp index 8da2a67c30..b66deefec5 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp @@ -187,7 +187,7 @@ struct boss_twin_valkyrAI : public ScriptedAI Creature* GetSister() { - return ObjectAccessor::GetCreature(*me, pInstance->GetData64(me->GetEntry() == NPC_DARKBANE ? NPC_LIGHTBANE : NPC_DARKBANE)); + return ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(me->GetEntry() == NPC_DARKBANE ? NPC_LIGHTBANE : NPC_DARKBANE)); } /*void AttackStart(Unit* victim) @@ -371,7 +371,7 @@ struct boss_twin_valkyrAI : public ScriptedAI events.RepeatEvent(urand(45000,50000)); */ - std::vector<uint64> tList; + GuidVector tList; Map::PlayerList const& pList = me->GetMap()->GetPlayers(); if (pList.getSize()) { diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp index 8c89554882..5bc4e115c2 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp @@ -34,30 +34,30 @@ public: std::string str_data; EventMap events; - uint64 NPC_BarrettGUID; - uint64 NPC_TirionGUID; - uint64 NPC_FizzlebangGUID; - uint64 NPC_GarroshGUID; - uint64 NPC_VarianGUID; - - uint64 NPC_GormokGUID; - uint64 NPC_DreadscaleGUID; - uint64 NPC_AcidmawGUID; - uint64 NPC_IcehowlGUID; - uint64 NPC_JaraxxusGUID; - std::vector<uint64> NPC_ChampionGUIDs; - uint64 NPC_LightbaneGUID; - uint64 NPC_DarkbaneGUID; - uint64 NPC_LichKingGUID; - uint64 NPC_AnubarakGUID; - - uint64 NPC_PurpleGroundGUID; - uint64 NPC_PortalGUID; - - uint64 GO_MainGateGUID; - uint64 GO_EnterGateGUID; - uint64 GO_WebDoorGUID; - uint64 GO_FloorGUID; + ObjectGuid NPC_BarrettGUID; + ObjectGuid NPC_TirionGUID; + ObjectGuid NPC_FizzlebangGUID; + ObjectGuid NPC_GarroshGUID; + ObjectGuid NPC_VarianGUID; + + ObjectGuid NPC_GormokGUID; + ObjectGuid NPC_DreadscaleGUID; + ObjectGuid NPC_AcidmawGUID; + ObjectGuid NPC_IcehowlGUID; + ObjectGuid NPC_JaraxxusGUID; + GuidVector NPC_ChampionGUIDs; + ObjectGuid NPC_LightbaneGUID; + ObjectGuid NPC_DarkbaneGUID; + ObjectGuid NPC_LichKingGUID; + ObjectGuid NPC_AnubarakGUID; + + ObjectGuid NPC_PurpleGroundGUID; + ObjectGuid NPC_PortalGUID; + + ObjectGuid GO_MainGateGUID; + ObjectGuid GO_EnterGateGUID; + ObjectGuid GO_WebDoorGUID; + ObjectGuid GO_FloorGUID; void SpawnAnubArak() { @@ -72,8 +72,8 @@ public: } // move corpses - const uint64 npcs[4] = { NPC_IcehowlGUID, NPC_JaraxxusGUID, NPC_LightbaneGUID, NPC_DarkbaneGUID }; - for (const uint64 i : npcs) + const ObjectGuid npcs[4] = { NPC_IcehowlGUID, NPC_JaraxxusGUID, NPC_LightbaneGUID, NPC_DarkbaneGUID }; + for (const ObjectGuid i : npcs) { if (Creature* c = instance->GetCreature(i)) { @@ -161,30 +161,7 @@ public: events.Reset(); events.RescheduleEvent(EVENT_CHECK_PLAYERS, 0); - NPC_BarrettGUID = 0; - NPC_TirionGUID = 0; - NPC_FizzlebangGUID = 0; - NPC_GarroshGUID = 0; - NPC_VarianGUID = 0; - - NPC_GormokGUID = 0; - NPC_DreadscaleGUID = 0; - NPC_AcidmawGUID = 0; - NPC_IcehowlGUID = 0; - NPC_JaraxxusGUID = 0; NPC_ChampionGUIDs.clear(); - NPC_LightbaneGUID = 0; - NPC_DarkbaneGUID = 0; - NPC_LichKingGUID = 0; - NPC_AnubarakGUID = 0; - - NPC_PurpleGroundGUID = 0; - NPC_PortalGUID = 0; - - GO_MainGateGUID = 0; - GO_EnterGateGUID = 0; - GO_WebDoorGUID = 0; - GO_FloorGUID = 0; } bool IsEncounterInProgress() const override @@ -425,8 +402,8 @@ public: InstanceProgress = INSTANCE_PROGRESS_FACTION_CHAMPIONS_DEAD; events.RescheduleEvent(EVENT_SCENE_FACTION_CHAMPIONS_DEAD, 2500); - for( std::vector<uint64>::iterator itr = NPC_ChampionGUIDs.begin(); itr != NPC_ChampionGUIDs.end(); ++itr ) - if( Creature* c = instance->GetCreature(*itr) ) + for (ObjectGuid guid : NPC_ChampionGUIDs) + if (Creature* c = instance->GetCreature(guid)) c->DespawnOrUnsummon(15000); NPC_ChampionGUIDs.clear(); @@ -478,10 +455,10 @@ public: { EncounterStatus = IN_PROGRESS; AchievementTimer = 0; - for( std::vector<uint64>::iterator itr = NPC_ChampionGUIDs.begin(); itr != NPC_ChampionGUIDs.end(); ++itr ) - if( Creature* c = instance->GetCreature(*itr) ) - if( !c->IsInCombat() ) - if( Unit* target = c->SelectNearestTarget(200.0f) ) + for (ObjectGuid guid : NPC_ChampionGUIDs) + if (Creature* c = instance->GetCreature(guid)) + if (!c->IsInCombat()) + if (Unit* target = c->SelectNearestTarget(200.0f)) c->AI()->AttackStart(target); } break; @@ -549,7 +526,7 @@ public: return 0; } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch( type ) { @@ -566,7 +543,8 @@ public: case TYPE_ANUBARAK: return NPC_AnubarakGUID; } - return 0; + + return ObjectGuid::Empty; } void Update(uint32 diff) override @@ -866,10 +844,10 @@ public: c->SetFacingTo(M_PI / 2); if( Creature* c = instance->GetCreature(NPC_PurpleGroundGUID) ) c->DespawnOrUnsummon(); - NPC_PurpleGroundGUID = 0; + NPC_PurpleGroundGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_PortalGUID) ) c->DespawnOrUnsummon(); - NPC_PortalGUID = 0; + NPC_PortalGUID.Clear(); events.RescheduleEvent(EVENT_SCENE_106, 10000); break; @@ -1115,8 +1093,8 @@ public: } case EVENT_CHAMPIONS_ATTACK: { - for( std::vector<uint64>::iterator itr = NPC_ChampionGUIDs.begin(); itr != NPC_ChampionGUIDs.end(); ++itr ) - if( Creature* c = instance->GetCreature(*itr) ) + for (ObjectGuid guid : NPC_ChampionGUIDs) + if (Creature* c = instance->GetCreature(guid)) { c->SetReactState(REACT_AGGRESSIVE); c->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -1469,16 +1447,16 @@ public: c->AI()->DoAction(-1); // despawn summons c->DespawnOrUnsummon(); } - NPC_GormokGUID = 0; + NPC_GormokGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_AcidmawGUID) ) c->DespawnOrUnsummon(); - NPC_AcidmawGUID = 0; + NPC_AcidmawGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_DreadscaleGUID) ) c->DespawnOrUnsummon(); - NPC_DreadscaleGUID = 0; + NPC_DreadscaleGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_IcehowlGUID) ) c->DespawnOrUnsummon(); - NPC_IcehowlGUID = 0; + NPC_IcehowlGUID.Clear(); northrendBeastsMask = 0; break; case INSTANCE_PROGRESS_BEASTS_DEAD: @@ -1486,16 +1464,16 @@ public: c->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); if( Creature* c = instance->GetCreature(NPC_FizzlebangGUID) ) c->DespawnOrUnsummon(); - NPC_FizzlebangGUID = 0; + NPC_FizzlebangGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_JaraxxusGUID) ) c->DespawnOrUnsummon(); - NPC_JaraxxusGUID = 0; + NPC_JaraxxusGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_PurpleGroundGUID) ) c->DespawnOrUnsummon(); - NPC_PurpleGroundGUID = 0; + NPC_PurpleGroundGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_PortalGUID) ) c->DespawnOrUnsummon(); - NPC_PortalGUID = 0; + NPC_PortalGUID.Clear(); break; case INSTANCE_PROGRESS_JARAXXUS_INTRO_DONE: if( Creature* c = instance->GetCreature(NPC_JaraxxusGUID) ) @@ -1515,8 +1493,8 @@ public: case INSTANCE_PROGRESS_JARAXXUS_DEAD: if( Creature* c = instance->GetCreature(NPC_BarrettGUID) ) c->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - for( std::vector<uint64>::iterator itr = NPC_ChampionGUIDs.begin(); itr != NPC_ChampionGUIDs.end(); ++itr ) - if( Creature* c = instance->GetCreature(*itr) ) + for (ObjectGuid guid : NPC_ChampionGUIDs) + if (Creature* c = instance->GetCreature(guid)) c->DespawnOrUnsummon(); NPC_ChampionGUIDs.clear(); break; @@ -1528,13 +1506,13 @@ public: c->AI()->DoAction(-1); c->DespawnOrUnsummon(); } - NPC_DarkbaneGUID = 0; + NPC_DarkbaneGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_LightbaneGUID) ) { c->AI()->DoAction(-1); c->DespawnOrUnsummon(); } - NPC_LightbaneGUID = 0; + NPC_LightbaneGUID.Clear(); break; case INSTANCE_PROGRESS_VALKYR_DEAD: case INSTANCE_PROGRESS_ANUB_ARAK: @@ -1558,14 +1536,14 @@ public: } if( Creature* c = instance->GetCreature(NPC_LichKingGUID) ) c->DespawnOrUnsummon(); - NPC_LichKingGUID = 0; + NPC_LichKingGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_AnubarakGUID) ) { c->AI()->DoAction(-1); c->DespawnOrUnsummon(); } - NPC_AnubarakGUID = 0; + NPC_AnubarakGUID.Clear(); break; case INSTANCE_PROGRESS_DONE: diff --git a/src/server/scripts/Northrend/DraktharonKeep/boss_novos.cpp b/src/server/scripts/Northrend/DraktharonKeep/boss_novos.cpp index 0b5a49d73b..91e9299120 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/boss_novos.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/boss_novos.cpp @@ -77,7 +77,10 @@ public: BossAI::Reset(); instance->SetBossState(DATA_NOVOS_CRYSTALS, IN_PROGRESS); instance->SetBossState(DATA_NOVOS_CRYSTALS, NOT_STARTED); - _crystalCounter = _summonTargetRightGUID = _summonTargetLeftGUID = _stage = 0; + _crystalCounter = 0; + _summonTargetRightGUID.Clear(); + _summonTargetLeftGUID.Clear(); + _stage = 0; me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -133,7 +136,7 @@ public: } } - me->SetUInt64Value(UNIT_FIELD_TARGET, 0); + me->SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty); me->RemoveAllAuras(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -240,8 +243,8 @@ public: private: uint8 _crystalCounter; uint8 _stage; - uint64 _summonTargetRightGUID; - uint64 _summonTargetLeftGUID; + ObjectGuid _summonTargetRightGUID; + ObjectGuid _summonTargetLeftGUID; bool _achievement; }; diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp index d7b60e187d..63b9af608f 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp @@ -221,7 +221,7 @@ public: void UpdateAI(uint32 diff) override { if (pInstance) - if (Creature* b = pInstance->instance->GetCreature(pInstance->GetData64(DATA_BRONJAHM))) + if (Creature* b = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_BRONJAHM))) { if (me->GetExactDist2d(b) <= 2.0f) { diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp index 8b7ef4dfa5..5ba5412db6 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp @@ -140,7 +140,7 @@ public: me->SetOrientation(me->GetAngle(target)); me->SetControlled(true, UNIT_STATE_ROOT); me->DisableRotate(true); - me->SetUInt64Value(UNIT_FIELD_TARGET, 0); + me->SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty); me->SetReactState(REACT_PASSIVE); me->GetMotionMaster()->Clear(false); me->GetMotionMaster()->MoveIdle(); @@ -337,7 +337,7 @@ public: t->ToCreature()->SetReactState(REACT_AGGRESSIVE); if (t->GetVictim()) { - t->SetUInt64Value(UNIT_FIELD_TARGET, t->GetVictim()->GetGUID()); + t->SetGuidValue(UNIT_FIELD_TARGET, t->GetVictim()->GetGUID()); t->GetMotionMaster()->MoveChase(t->GetVictim()); } } diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/instance_forge_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/instance_forge_of_souls.cpp index f82dc23887..db5d65f646 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/instance_forge_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/instance_forge_of_souls.cpp @@ -24,25 +24,18 @@ public: uint32 m_auiEncounter[MAX_ENCOUNTER]; TeamId teamIdInInstance; std::string str_data; - uint64 NPC_BronjahmGUID; - uint64 NPC_DevourerGUID; + ObjectGuid NPC_BronjahmGUID; + ObjectGuid NPC_DevourerGUID; - uint64 NPC_LeaderFirstGUID; - uint64 NPC_LeaderSecondGUID; - uint64 NPC_GuardFirstGUID; - uint64 NPC_GuardSecondGUID; + ObjectGuid NPC_LeaderFirstGUID; + ObjectGuid NPC_LeaderSecondGUID; + ObjectGuid NPC_GuardFirstGUID; + ObjectGuid NPC_GuardSecondGUID; void Initialize() override { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); teamIdInInstance = TEAM_NEUTRAL; - NPC_BronjahmGUID = 0; - NPC_DevourerGUID = 0; - - NPC_LeaderFirstGUID = 0; - NPC_LeaderSecondGUID = 0; - NPC_GuardFirstGUID = 0; - NPC_GuardSecondGUID = 0; } bool IsEncounterInProgress() const override @@ -150,7 +143,7 @@ public: SaveToDB(); } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -158,7 +151,7 @@ public: return NPC_BronjahmGUID; } - return 0; + return ObjectGuid::Empty; } bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/, uint32 /*miscvalue1*/) override diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp index 1a472ee80b..4f00b420b0 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp @@ -210,7 +210,7 @@ public: if (pInstance) { me->SetVisible(true); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_DARK_RANGER_LORALEN))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_DARK_RANGER_LORALEN))) c->SetVisible(true); } break; @@ -229,7 +229,7 @@ public: shortver = false; me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); me->GetMotionMaster()->MovePoint(0, MoveThronePos); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_DARK_RANGER_LORALEN))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_DARK_RANGER_LORALEN))) c->GetMotionMaster()->MovePoint(0, LoralenFollowPos); // Begining of intro is differents between factions as the speech sequence and timers are differents. if (me->GetEntry() == NPC_JAINA_PART1) @@ -241,7 +241,7 @@ public: shortver = true; me->SetUInt32Value(UNIT_NPC_EMOTESTATE, (me->GetEntry() == NPC_JAINA_PART1 ? EMOTE_STATE_READY2H : EMOTE_STATE_READY1H)); me->GetMotionMaster()->MovePoint(0, MoveThronePos); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_DARK_RANGER_LORALEN))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_DARK_RANGER_LORALEN))) c->GetMotionMaster()->MovePoint(0, LoralenFollowPos); events.ScheduleEvent(EVENT_INTRO_LK_1, 0); break; @@ -256,13 +256,13 @@ public: events.ScheduleEvent(EVENT_INTRO_A2_3, 10000); break; case EVENT_INTRO_A2_3: - pInstance->HandleGameObject(pInstance->GetData64(GO_FROSTMOURNE), true); + pInstance->HandleGameObject(pInstance->GetGuidData(GO_FROSTMOURNE), true); me->CastSpell(me, SPELL_FROSTMOURNE_SPAWN_SOUND, true); me->CastSpell(me, SPELL_ARCANE_CAST_VISUAL, false); events.ScheduleEvent(EVENT_INTRO_A2_4, 10000); break; case EVENT_INTRO_A2_4: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) { pUther->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); pUther->SetVisible(true); @@ -272,7 +272,7 @@ public: events.ScheduleEvent(EVENT_INTRO_A2_5, 2000); break; case EVENT_INTRO_A2_5: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_A2_1); events.ScheduleEvent(EVENT_INTRO_A2_6, 3000); break; @@ -281,7 +281,7 @@ public: events.ScheduleEvent(EVENT_INTRO_A2_7, 6000); break; case EVENT_INTRO_A2_7: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_A2_2); events.ScheduleEvent(EVENT_INTRO_A2_8, 6500); break; @@ -290,7 +290,7 @@ public: events.ScheduleEvent(EVENT_INTRO_A2_9, 2000); break; case EVENT_INTRO_A2_9: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_A2_3); events.ScheduleEvent(EVENT_INTRO_A2_10, 9000); break; @@ -299,7 +299,7 @@ public: events.ScheduleEvent(EVENT_INTRO_A2_11, 5000); break; case EVENT_INTRO_A2_11: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_A2_4); events.ScheduleEvent(EVENT_INTRO_A2_12, 11000); break; @@ -308,7 +308,7 @@ public: events.ScheduleEvent(EVENT_INTRO_A2_13, 4000); break; case EVENT_INTRO_A2_13: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_A2_5); events.ScheduleEvent(EVENT_INTRO_A2_14, 12500); break; @@ -317,12 +317,12 @@ public: events.ScheduleEvent(EVENT_INTRO_A2_15, 10000); break; case EVENT_INTRO_A2_15: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_A2_6); events.ScheduleEvent(EVENT_INTRO_A2_16, 24000); break; case EVENT_INTRO_A2_16: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_A2_7); events.ScheduleEvent(EVENT_INTRO_A2_17, 4000); break; @@ -331,7 +331,7 @@ public: events.ScheduleEvent(EVENT_INTRO_A2_18, 2000); break; case EVENT_INTRO_A2_18: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) { pUther->HandleEmoteCommand(EMOTE_ONESHOT_NO); pUther->AI()->Talk(SAY_UTHER_INTRO_A2_8); @@ -350,13 +350,13 @@ public: break; case EVENT_INTRO_H2_3: Talk(SAY_SYLVANAS_INTRO_3); - pInstance->HandleGameObject(pInstance->GetData64(GO_FROSTMOURNE), true); + pInstance->HandleGameObject(pInstance->GetGuidData(GO_FROSTMOURNE), true); me->CastSpell(me, SPELL_FROSTMOURNE_SPAWN_SOUND, true); me->CastSpell(me, SPELL_ARCANE_CAST_VISUAL, false); events.ScheduleEvent(EVENT_INTRO_H2_4, 6000); break; case EVENT_INTRO_H2_4: - if (Creature* pUther = pInstance->instance->GetCreature(pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_UTHER))) { pUther->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); pUther->SetVisible(true); @@ -366,7 +366,7 @@ public: events.ScheduleEvent(EVENT_INTRO_H2_5, 2000); break; case EVENT_INTRO_H2_5: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_H2_1); events.ScheduleEvent(EVENT_INTRO_H2_6, 11000); break; @@ -375,7 +375,7 @@ public: events.ScheduleEvent(EVENT_INTRO_H2_7, 3000); break; case EVENT_INTRO_H2_7: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_H2_2); events.ScheduleEvent(EVENT_INTRO_H2_8, 6000); break; @@ -384,7 +384,7 @@ public: events.ScheduleEvent(EVENT_INTRO_H2_9, 5000); break; case EVENT_INTRO_H2_9: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_H2_3); events.ScheduleEvent(EVENT_INTRO_H2_10, 19000); break; @@ -393,7 +393,7 @@ public: events.ScheduleEvent(EVENT_INTRO_H2_11, 1500); break; case EVENT_INTRO_H2_11: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_H2_4); events.ScheduleEvent(EVENT_INTRO_H2_12, 19500); break; @@ -402,7 +402,7 @@ public: events.ScheduleEvent(EVENT_INTRO_H2_13, 2000); break; case EVENT_INTRO_H2_13: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) { pUther->HandleEmoteCommand(EMOTE_ONESHOT_NO); pUther->AI()->Talk(SAY_UTHER_INTRO_H2_5); @@ -410,7 +410,7 @@ public: events.ScheduleEvent(EVENT_INTRO_H2_14, 12000); break; case EVENT_INTRO_H2_14: - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->AI()->Talk(SAY_UTHER_INTRO_H2_6); events.ScheduleEvent(EVENT_INTRO_H2_15, 8000); break; @@ -421,15 +421,15 @@ public: // Remaining Intro Events common for both faction case EVENT_INTRO_LK_1: - if (Creature* pLichKing = pInstance->instance->GetCreature(pInstance->GetData64(NPC_LICH_KING_EVENT))) + if (Creature* pLichKing = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_LICH_KING_EVENT))) { - pInstance->HandleGameObject(pInstance->GetData64(GO_ARTHAS_DOOR), true); + pInstance->HandleGameObject(pInstance->GetGuidData(GO_ARTHAS_DOOR), true); pLichKing->SetVisible(true); pLichKing->GetMotionMaster()->MovePoint(0, LichKingMoveThronePos, false); } if (!shortver) - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) { if (me->GetEntry() == NPC_JAINA_PART1) pUther->AI()->Talk(SAY_UTHER_INTRO_A2_9); @@ -444,52 +444,52 @@ public: case EVENT_INTRO_LK_1_2: if (!shortver) - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_COWER); break; case EVENT_INTRO_LK_1_3: - pInstance->HandleGameObject(pInstance->GetData64(GO_ARTHAS_DOOR), false); + pInstance->HandleGameObject(pInstance->GetGuidData(GO_ARTHAS_DOOR), false); break; case EVENT_INTRO_LK_2: if (!shortver) - if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_LICH_KING_EVENT))) + if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_LICH_KING_EVENT))) pLichKing->AI()->Talk(SAY_LK_INTRO_1); events.ScheduleEvent(EVENT_INTRO_LK_3, 2000); break; case EVENT_INTRO_LK_3: if (!shortver) - if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_UTHER))) + if (Creature* pUther = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_UTHER))) pUther->SetVisible(false); events.ScheduleEvent(EVENT_INTRO_LK_4, 4000); break; case EVENT_INTRO_LK_4: - if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_LICH_KING_EVENT))) + if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_LICH_KING_EVENT))) pLichKing->AI()->Talk(SAY_LK_INTRO_2); events.ScheduleEvent(EVENT_INTRO_LK_4_2, 10000); break; case EVENT_INTRO_LK_4_2: - if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_LICH_KING_EVENT))) + if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_LICH_KING_EVENT))) { pLichKing->LoadEquipment(1, true); pLichKing->SendMovementFlagUpdate(); pLichKing->CastSpell(pLichKing, SPELL_FROSTMOURNE_EQUIP, false); - pInstance->HandleGameObject(pInstance->GetData64(GO_FROSTMOURNE), false); + pInstance->HandleGameObject(pInstance->GetGuidData(GO_FROSTMOURNE), false); events.ScheduleEvent(EVENT_INTRO_LK_4_3, 1750); } events.ScheduleEvent(EVENT_INTRO_LK_5, 6000); break; case EVENT_INTRO_LK_4_3: - if (GameObject* go = pInstance->instance->GetGameObject(pInstance->GetData64(GO_FROSTMOURNE))) + if (GameObject* go = pInstance->instance->GetGameObject(pInstance->GetGuidData(GO_FROSTMOURNE))) go->SetPhaseMask(2, true); break; case EVENT_INTRO_LK_5: - if (Creature* pFalric = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_FALRIC))) + if (Creature* pFalric = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_FALRIC))) { pFalric->UpdatePosition(5274.9f, 2039.2f, 709.319f, 5.4619f, true); pFalric->StopMovingOnCurrentPos(); @@ -501,7 +501,7 @@ public: a->SetDuration(8000); } } - if (Creature* pMarwyn = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_MARWYN))) + if (Creature* pMarwyn = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_MARWYN))) { pMarwyn->UpdatePosition(5343.77f, 1973.86f, 709.319f, 2.35173f, true); pMarwyn->StopMovingOnCurrentPos(); @@ -514,7 +514,7 @@ public: } } - if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_LICH_KING_EVENT))) + if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_LICH_KING_EVENT))) pLichKing->AI()->Talk(SAY_LK_INTRO_3); events.ScheduleEvent(EVENT_INTRO_LK_5_2, 5000); @@ -522,30 +522,30 @@ public: break; case EVENT_INTRO_LK_5_2: - if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_LICH_KING_EVENT))) + if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_LICH_KING_EVENT))) pLichKing->GetMotionMaster()->MovePoint(0, LichKingMoveAwayPos, false); break; case EVENT_INTRO_LK_6: - if (Creature* pFalric = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_FALRIC))) + if (Creature* pFalric = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_FALRIC))) pFalric->AI()->Talk(SAY_FALRIC_INTRO_1); events.ScheduleEvent(EVENT_INTRO_LK_7, 2000); break; case EVENT_INTRO_LK_7: - if (Creature* pMarwyn = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_MARWYN))) + if (Creature* pMarwyn = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_MARWYN))) pMarwyn->AI()->Talk(SAY_MARWYN_INTRO_1); events.ScheduleEvent(EVENT_INTRO_LK_8, 2000); break; case EVENT_INTRO_LK_8: - if (Creature* pFalric = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_FALRIC))) + if (Creature* pFalric = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_FALRIC))) pFalric->AI()->Talk(SAY_FALRIC_INTRO_2); pInstance->SetData(ACTION_SHOW_TRASH, 1); - pInstance->HandleGameObject(pInstance->GetData64(GO_ARTHAS_DOOR), true); + pInstance->HandleGameObject(pInstance->GetGuidData(GO_ARTHAS_DOOR), true); events.ScheduleEvent(EVENT_INTRO_LK_9, 5000); break; @@ -557,20 +557,20 @@ public: Talk(SAY_SYLVANAS_INTRO_END); me->GetMotionMaster()->MovePoint(0, LichKingMoveAwayPos, false); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_DARK_RANGER_LORALEN))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_DARK_RANGER_LORALEN))) c->GetMotionMaster()->MovePoint(0, LichKingMoveAwayPos, false); events.ScheduleEvent(EVENT_INTRO_END, 14000); break; case EVENT_INTRO_END: - pInstance->HandleGameObject(pInstance->GetData64(GO_ARTHAS_DOOR), false); - pInstance->HandleGameObject(pInstance->GetData64(GO_FRONT_DOOR), false); + pInstance->HandleGameObject(pInstance->GetGuidData(GO_ARTHAS_DOOR), false); + pInstance->HandleGameObject(pInstance->GetGuidData(GO_FRONT_DOOR), false); events.ScheduleEvent(EVENT_INTRO_END_SET, 10000); break; case EVENT_INTRO_END_SET: - if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_LICH_KING_EVENT))) + if (Creature* pLichKing = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_LICH_KING_EVENT))) pLichKing->SetVisible(false); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_DARK_RANGER_LORALEN))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_DARK_RANGER_LORALEN))) c->SetVisible(false); me->SetVisible(false); pInstance->SetData(DATA_INTRO, DONE); @@ -1395,7 +1395,7 @@ public: else me->RemoveAura(SPELL_REMORSELESS_WINTER); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_SYLVANAS_PART2))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_SYLVANAS_PART2))) c->AI()->DoAction(ACTION_INFORM_WALL_DESTROYED); } } @@ -1411,7 +1411,7 @@ public: { Talk(SAY_LK_IW_1); me->SetOrientation(4.15f); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_ICE_WALL_TARGET))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_ICE_WALL_TARGET))) { me->CastSpell(c, SPELL_SUMMON_ICE_WALL, false); events.ScheduleEvent(EVENT_LK_REMORSELESS_WINTER, 4000); @@ -1468,7 +1468,7 @@ public: case EVENT_LK_CHECK_COMBAT: if (me->isActiveObject()) // during fight { - if (Creature* leader = pInstance->instance->GetCreature(pInstance->GetData64(NPC_SYLVANAS_PART2))) + if (Creature* leader = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_SYLVANAS_PART2))) if (leader->IsAlive() && leader->GetPositionX() < 5575.0f && me->GetExactDist2d(leader) <= 12.5f && !leader->HasAura(SPELL_HARVEST_SOUL) && me->HasAura(SPELL_REMORSELESS_WINTER)) { me->GetMotionMaster()->MovementExpired(); @@ -1506,7 +1506,7 @@ public: events.ScheduleEvent(EVENT_LK_CHECK_COMBAT, 1000); break; case EVENT_LK_KILL_LEADER: - if (Creature* leader = pInstance->instance->GetCreature(pInstance->GetData64(NPC_SYLVANAS_PART2))) + if (Creature* leader = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_SYLVANAS_PART2))) { leader->CastSpell(leader, SPELL_HOR_SUICIDE, true); Unit::Kill(me, leader); @@ -1591,7 +1591,7 @@ public: break; case EVENT_LK_SUMMON_NEXT_ICE_WALL: Talk(SAY_LK_IW_1 + currentWall); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_ICE_WALL_TARGET + currentWall))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_ICE_WALL_TARGET + currentWall))) me->CastSpell(c, SPELL_SUMMON_ICE_WALL, false); break; } @@ -1693,12 +1693,12 @@ public: switch(events.ExecuteEvent()) { case EVENT_LK_SAY_AGGRO: - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_LICH_KING_BOSS))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_LICH_KING_BOSS))) c->AI()->Talk(me->GetEntry() == NPC_JAINA_PART2 ? SAY_LK_AGGRO_ALLY : SAY_LK_AGGRO_HORDE); events.ScheduleEvent(me->GetEntry() == NPC_JAINA_PART2 ? EVENT_JAINA_IMMOBILIZE_LK : EVENT_SYLVANAS_IMMOBILIZE_JUMP, 12000); break; case EVENT_JAINA_IMMOBILIZE_LK: - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_LICH_KING_BOSS))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_LICH_KING_BOSS))) { c->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); @@ -1707,7 +1707,7 @@ public: } break; case EVENT_SYLVANAS_IMMOBILIZE_JUMP: - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_LICH_KING_BOSS))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_LICH_KING_BOSS))) { c->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); @@ -1716,7 +1716,7 @@ public: } break; case EVENT_SYLVANAS_DARK_BINDING: - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_LICH_KING_BOSS))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_LICH_KING_BOSS))) me->CastSpell(c, SPELL_SYLVANAS_DARK_BINDING, false); events.ScheduleEvent(EVENT_SAY_LEAVE, 3500); break; @@ -1725,7 +1725,7 @@ public: Map::PlayerList const& pl = pInstance->instance->GetPlayers(); for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) if (Player* p = itr->GetSource()) - p->KilledMonsterCredit(me->GetEntry(), 0); // for quest + p->KilledMonsterCredit(me->GetEntry()); // for quest Talk(me->GetEntry() == NPC_JAINA_PART2 ? SAY_JAINA_LEAVE : SAY_SYLVANAS_LEAVE); me->GetMotionMaster()->MovePoint(0, LeaderEscapePos); @@ -1742,7 +1742,7 @@ public: pInstance->SetData(ACTION_START_LK_FIGHT, 1); me->setActive(true); MoveToNextStopPoint(); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(NPC_LICH_KING_BOSS))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_LICH_KING_BOSS))) { c->setActive(true); c->SetInCombatWithZone(); @@ -1831,7 +1831,7 @@ public: { me->SetCorpseDelay(10); if (InstanceScript* pInstance = me->GetInstanceScript()) - if (Creature* lk = pInstance->instance->GetCreature(pInstance->GetData64(NPC_LICH_KING_BOSS))) + if (Creature* lk = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_LICH_KING_BOSS))) lk->AI()->DoAction(ACTION_INFORM_TRASH_DIED); } }; @@ -1900,7 +1900,7 @@ public: { me->SetCorpseDelay(10); if (InstanceScript* pInstance = me->GetInstanceScript()) - if (Creature* lk = pInstance->instance->GetCreature(pInstance->GetData64(NPC_LICH_KING_BOSS))) + if (Creature* lk = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_LICH_KING_BOSS))) lk->AI()->DoAction(ACTION_INFORM_TRASH_DIED); } }; @@ -1965,7 +1965,7 @@ public: { me->SetCorpseDelay(10); if (InstanceScript* pInstance = me->GetInstanceScript()) - if (Creature* lk = pInstance->instance->GetCreature(pInstance->GetData64(NPC_LICH_KING_BOSS))) + if (Creature* lk = pInstance->instance->GetCreature(pInstance->GetGuidData(NPC_LICH_KING_BOSS))) lk->AI()->DoAction(ACTION_INFORM_TRASH_DIED); } }; diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp index 1d6efa5ac0..6df3158a85 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp @@ -117,28 +117,28 @@ public: uint32 EncounterMask; TeamId TeamIdInInstance; - uint64 NPC_FalricGUID; - uint64 NPC_MarwynGUID; - uint64 NPC_LichKingIntroGUID; - uint64 NPC_LeaderIntroGUID; - uint64 NPC_GuardGUID; - uint64 NPC_UtherGUID; - uint64 NPC_LichKingGUID; - uint64 NPC_LeaderGUID; - uint64 NPC_IceWallTargetGUID[4]; - uint64 NPC_AltarBunnyGUID; - uint64 NPC_QuelDelarGUID; - uint64 NPC_ShipCaptainGUID; - uint64 GO_FrostmourneGUID; - uint64 GO_FrostmourneAltarGUID; - uint64 GO_FrontDoorGUID; - uint64 GO_ArthasDoorGUID; - uint64 GO_CaveInGUID; - uint64 GO_DoorBeforeThroneGUID; - uint64 GO_DoorAfterThroneGUID; - uint64 GO_IceWallGUID; - - uint64 NPC_TrashGUID[NUM_OF_TRASH]; + ObjectGuid NPC_FalricGUID; + ObjectGuid NPC_MarwynGUID; + ObjectGuid NPC_LichKingIntroGUID; + ObjectGuid NPC_LeaderIntroGUID; + ObjectGuid NPC_GuardGUID; + ObjectGuid NPC_UtherGUID; + ObjectGuid NPC_LichKingGUID; + ObjectGuid NPC_LeaderGUID; + ObjectGuid NPC_IceWallTargetGUID[4]; + ObjectGuid NPC_AltarBunnyGUID; + ObjectGuid NPC_QuelDelarGUID; + ObjectGuid NPC_ShipCaptainGUID; + ObjectGuid GO_FrostmourneGUID; + ObjectGuid GO_FrostmourneAltarGUID; + ObjectGuid GO_FrontDoorGUID; + ObjectGuid GO_ArthasDoorGUID; + ObjectGuid GO_CaveInGUID; + ObjectGuid GO_DoorBeforeThroneGUID; + ObjectGuid GO_DoorAfterThroneGUID; + ObjectGuid GO_IceWallGUID; + + ObjectGuid NPC_TrashGUID[NUM_OF_TRASH]; bool TrashActive[NUM_OF_TRASH]; uint8 TrashCounter; uint32 chosenComposition[8][5]; @@ -152,8 +152,8 @@ public: bool IsDuringLKFight; uint32 BatteredHiltStatus; - uint64 NPC_FrostswornGeneralGUID; - uint64 NPC_SpiritualReflectionGUID[5]; + ObjectGuid NPC_FrostswornGeneralGUID; + ObjectGuid NPC_SpiritualReflectionGUID[5]; uint32 outroTimer; uint8 outroStep; @@ -163,28 +163,6 @@ public: { EncounterMask = 0; TeamIdInInstance = TEAM_NEUTRAL; - NPC_FalricGUID = 0; - NPC_MarwynGUID = 0; - NPC_LichKingIntroGUID = 0; - NPC_LeaderIntroGUID = 0; - NPC_GuardGUID = 0; - NPC_UtherGUID = 0; - NPC_LichKingGUID = 0; - NPC_LeaderGUID = 0; - memset(&NPC_IceWallTargetGUID, 0, sizeof(NPC_IceWallTargetGUID)); - NPC_AltarBunnyGUID = 0; - NPC_QuelDelarGUID = 0; - NPC_ShipCaptainGUID = 0; - GO_FrostmourneGUID = 0; - GO_FrostmourneAltarGUID = 0; - GO_FrontDoorGUID = 0; - GO_ArthasDoorGUID = 0; - GO_CaveInGUID = 0; - GO_DoorBeforeThroneGUID = 0; - GO_DoorAfterThroneGUID = 0; - GO_IceWallGUID = 0; - - memset(&NPC_TrashGUID, 0, sizeof(NPC_TrashGUID)); memset(&TrashActive, 0, sizeof(TrashActive)); TrashCounter = 0; memset(&chosenComposition, 0, sizeof(chosenComposition)); @@ -198,9 +176,6 @@ public: IsDuringLKFight = false; BatteredHiltStatus = 0; - NPC_FrostswornGeneralGUID = 0; - memset(&NPC_SpiritualReflectionGUID, 0, sizeof(NPC_SpiritualReflectionGUID)); - outroTimer = 0; outroStep = 0; T1 = nullptr; @@ -378,7 +353,7 @@ public: { case GO_FROSTMOURNE: GO_FrostmourneGUID = go->GetGUID(); - HandleGameObject(0, false, go); + HandleGameObject(ObjectGuid::Empty, false, go); if (EncounterMask & (1 << DATA_INTRO)) go->SetPhaseMask(2, true); break; @@ -387,11 +362,11 @@ public: break; case GO_FRONT_DOOR: GO_FrontDoorGUID = go->GetGUID(); - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_ARTHAS_DOOR: GO_ArthasDoorGUID = go->GetGUID(); - HandleGameObject(0, (EncounterMask & (1 << DATA_MARWYN)), go); + HandleGameObject(ObjectGuid::Empty, (EncounterMask & (1 << DATA_MARWYN)), go); break; case GO_CAVE_IN: GO_CaveInGUID = go->GetGUID(); @@ -573,7 +548,7 @@ public: [[fallthrough]]; case ACTION_DELETE_ICE_WALL: HandleGameObject(GO_IceWallGUID, true); - GO_IceWallGUID = 0; + GO_IceWallGUID.Clear(); break; case DATA_LICH_KING: if (data == DONE) @@ -683,7 +658,7 @@ public: return 0; } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch(type) { @@ -714,7 +689,7 @@ public: return GO_FrontDoorGUID; } - return 0; + return ObjectGuid::Empty; } std::string GetSaveData() override @@ -1198,7 +1173,7 @@ public: outroTimer = 0; for (Map::PlayerList::const_iterator itr = instance->GetPlayers().begin(); itr != instance->GetPlayers().end(); ++itr) if (Player* p = itr->GetSource()) - p->KilledMonsterCredit(NPC_WRATH_OF_THE_LICH_KING_CREDIT, 0); + p->KilledMonsterCredit(NPC_WRATH_OF_THE_LICH_KING_CREDIT); if (TeamIdInInstance == TEAM_ALLIANCE) if (Creature* c = instance->GetCreature(NPC_LeaderGUID)) { diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp index 4c667647c6..a4fdc29ea5 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp @@ -114,7 +114,7 @@ public: { phase = 1; me->SetReactState(REACT_PASSIVE); - me->SetTarget(0); + me->SetTarget(); me->SendMeleeAttackStop(me->GetVictim()); events.DelayEvents(8000); me->CastSpell(me, SPELL_THUNDERING_STOMP, false); @@ -127,7 +127,7 @@ public: events.CancelEvent(EVENT_SPELL_CHILLING_WAVE); phase = 2; me->SetReactState(REACT_PASSIVE); - me->SetTarget(0); + me->SetTarget(); me->SendMeleeAttackStop(me->GetVictim()); events.DelayEvents(8000); me->CastSpell(me, SPELL_THUNDERING_STOMP, false); diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp index 7abd6a1b2f..26a7de062e 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp @@ -307,7 +307,7 @@ public: { pInstance->SetData(DATA_INSTANCE_PROGRESS, INSTANCE_PROGRESS_FINISHED_KRICK_SCENE); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_LEADER_FIRST_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_LEADER_FIRST_GUID))) { c->GetMotionMaster()->Clear(); c->UpdatePosition(SBSLeaderStartPos, true); @@ -322,7 +322,7 @@ public: Talk(SAY_OUTRO_KRICK_1); if (pInstance) { - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_LEADER_FIRST_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_LEADER_FIRST_GUID))) { float angle = me->GetAngle(c); me->SetFacingTo(angle); @@ -332,7 +332,7 @@ public: } for (uint8 i = 0; i < 2; ++i) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_GUARD_1_GUID + i))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_GUARD_1_GUID + i))) c->DespawnOrUnsummon(); } @@ -341,13 +341,13 @@ public: case 2: if (pInstance) { - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) { c->setActive(true); c->UpdatePosition(SBSTyrannusStartPos, true); c->SetHomePosition(SBSTyrannusStartPos); } - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_LEADER_FIRST_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_LEADER_FIRST_GUID))) c->AI()->Talk(c->GetEntry() == NPC_JAINA_PART1 ? SAY_JAINA_KRICK_1 : SAY_SYLVANAS_KRICK_1); } @@ -361,9 +361,9 @@ public: case 4: if (pInstance) { - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) c->GetMotionMaster()->MovePath(PATH_BEGIN_VALUE + 10, false); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_LEADER_FIRST_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_LEADER_FIRST_GUID))) c->AI()->Talk(c->GetEntry() == NPC_JAINA_PART1 ? SAY_JAINA_KRICK_2 : SAY_SYLVANAS_KRICK_2); } @@ -376,7 +376,7 @@ public: break; case 6: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) { c->SetFacingToObject(me); c->AI()->Talk(SAY_TYRANNUS_KRICK_1); @@ -401,7 +401,7 @@ public: break; case 9: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) c->CastSpell(c, 69753, false); me->SetReactState(REACT_PASSIVE); @@ -419,7 +419,7 @@ public: break; case 10: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) c->AI()->Talk(SAY_TYRANNUS_KRICK_2); events.RescheduleEvent(11, 9000); @@ -427,9 +427,9 @@ public: case 11: if (pInstance) { - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) c->GetMotionMaster()->MovePoint(1, 809.39f, 74.69f, 541.54f); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_LEADER_FIRST_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_LEADER_FIRST_GUID))) { c->AI()->Talk(c->GetEntry() == NPC_JAINA_PART1 ? SAY_JAINA_KRICK_3 : SAY_SYLVANAS_KRICK_3); c->GetMotionMaster()->MovePath(PATH_BEGIN_VALUE + 11, false); diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp index 6bb0761a89..bac0b65114 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp @@ -51,7 +51,7 @@ public: { pInstance = me->GetInstanceScript(); me->SetReactState(REACT_PASSIVE); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_RIMEFANG_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_RIMEFANG_GUID))) { c->SetCanFly(true); } @@ -68,13 +68,13 @@ public: { if (!pInstance) return; - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_MARTIN_OR_GORKUN_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_MARTIN_OR_GORKUN_GUID))) { c->AI()->DoAction(1); c->DespawnOrUnsummon(); - pInstance->SetData64(DATA_MARTIN_OR_GORKUN_GUID, 0); + pInstance->SetGuidData(DATA_MARTIN_OR_GORKUN_GUID, ObjectGuid::Empty); } - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_RIMEFANG_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_RIMEFANG_GUID))) { c->GetMotionMaster()->Clear(); c->GetMotionMaster()->MoveIdle(); @@ -93,7 +93,7 @@ public: if (param == 1) { Position exitPos = {1023.46f, 159.12f, 628.2f, 5.23f}; - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_RIMEFANG_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_RIMEFANG_GUID))) { c->RemoveAura(46598); c->GetMotionMaster()->Clear(); @@ -166,13 +166,13 @@ public: break; case EVENT_RIMEFANG_SPELL_ICY_BLAST: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 190.0f, true)) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_RIMEFANG_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_RIMEFANG_GUID))) c->CastSpell(target, RIMEFANG_SPELL_ICY_BLAST, false); events.RepeatEvent(5000); break; case EVENT_SPELL_MARK_OF_RIMEFANG: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 190.0f, true)) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_RIMEFANG_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_RIMEFANG_GUID))) { Talk(SAY_MARK); c->AI()->Talk(EMOTE_RIMEFANG_ICEBOLT, target); diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp index 7749692127..b070a51fd7 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp @@ -21,21 +21,21 @@ public: uint32 InstanceProgress; std::string str_data; - uint64 NPC_LeaderFirstGUID; - uint64 NPC_LeaderSecondGUID; - uint64 NPC_TyrannusEventGUID; - uint64 NPC_Necrolyte1GUID; - uint64 NPC_Necrolyte2GUID; - uint64 NPC_GuardFirstGUID; - uint64 NPC_GuardSecondGUID; - uint64 NPC_SindragosaGUID; - - uint64 NPC_GarfrostGUID; - uint64 NPC_MartinOrGorkunGUID; - uint64 NPC_RimefangGUID; - uint64 NPC_TyrannusGUID; - - uint64 GO_IceWallGUID; + ObjectGuid NPC_LeaderFirstGUID; + ObjectGuid NPC_LeaderSecondGUID; + ObjectGuid NPC_TyrannusEventGUID; + ObjectGuid NPC_Necrolyte1GUID; + ObjectGuid NPC_Necrolyte2GUID; + ObjectGuid NPC_GuardFirstGUID; + ObjectGuid NPC_GuardSecondGUID; + ObjectGuid NPC_SindragosaGUID; + + ObjectGuid NPC_GarfrostGUID; + ObjectGuid NPC_MartinOrGorkunGUID; + ObjectGuid NPC_RimefangGUID; + ObjectGuid NPC_TyrannusGUID; + + ObjectGuid GO_IceWallGUID; bool bAchievEleven; bool bAchievDontLookUp; @@ -46,22 +46,6 @@ public: teamIdInInstance = TEAM_NEUTRAL; InstanceProgress = INSTANCE_PROGRESS_NONE; - NPC_LeaderFirstGUID = 0; - NPC_LeaderSecondGUID = 0; - NPC_TyrannusEventGUID = 0; - NPC_Necrolyte1GUID = 0; - NPC_Necrolyte2GUID = 0; - NPC_GuardFirstGUID = 0; - NPC_GuardSecondGUID = 0; - NPC_SindragosaGUID = 0; - - NPC_GarfrostGUID = 0; - NPC_MartinOrGorkunGUID = 0; - NPC_RimefangGUID = 0; - NPC_TyrannusGUID = 0; - - GO_IceWallGUID = 0; - bAchievEleven = true; bAchievDontLookUp = true; } @@ -77,11 +61,11 @@ public: void OnPlayerEnter(Player* /*plr*/) override { instance->LoadGrid(LeaderIntroPos.GetPositionX(), LeaderIntroPos.GetPositionY()); - if (Creature* c = instance->GetCreature(GetData64(DATA_LEADER_FIRST_GUID))) + if (Creature* c = instance->GetCreature(GetGuidData(DATA_LEADER_FIRST_GUID))) c->AI()->SetData(DATA_START_INTRO, 0); } - uint32 GetCreatureEntry(uint32 /*guidLow*/, CreatureData const* data) override + uint32 GetCreatureEntry(ObjectGuid::LowType /*guidLow*/, CreatureData const* data) override { if (teamIdInInstance == TEAM_NEUTRAL) { @@ -303,7 +287,7 @@ public: SaveToDB(); } - void SetData64(uint32 type, uint64 data) override + void SetGuidData(uint32 type, ObjectGuid data) override { switch(type) { @@ -338,7 +322,7 @@ public: return 0; } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -368,7 +352,7 @@ public: return NPC_SindragosaGUID; } - return 0; + return ObjectGuid::Empty; } bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/, uint32 /*miscvalue1*/) override diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp index ea096176bc..75927c748e 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp @@ -94,7 +94,7 @@ public: break; case 2: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) { c->setActive(true); c->AI()->Talk(SAY_TYRANNUS_INTRO_1); @@ -104,7 +104,7 @@ public: break; case 3: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) c->AI()->Talk(SAY_TYRANNUS_INTRO_2); events.RescheduleEvent(4, 14000); @@ -112,8 +112,8 @@ public: case 4: if (pInstance) { - Creature* n1 = pInstance->instance->GetCreature(pInstance->GetData64(DATA_NECROLYTE_1_GUID)); - Creature* n2 = pInstance->instance->GetCreature(pInstance->GetData64(DATA_NECROLYTE_2_GUID)); + Creature* n1 = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_NECROLYTE_1_GUID)); + Creature* n2 = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_NECROLYTE_2_GUID)); if (n1 && n2) { if (!n1->IsInCombat() && n1->IsAlive()) @@ -157,7 +157,7 @@ public: break; case 6: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) c->AI()->Talk(SAY_TYRANNUS_INTRO_3); events.RescheduleEvent(7, 5000); @@ -165,9 +165,9 @@ public: case 7: if (pInstance) { - if (Creature* n1 = pInstance->instance->GetCreature(pInstance->GetData64(DATA_NECROLYTE_1_GUID))) + if (Creature* n1 = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_NECROLYTE_1_GUID))) n1->AI()->DoAction(1337); // remove invincibility - if (Creature* n2 = pInstance->instance->GetCreature(pInstance->GetData64(DATA_NECROLYTE_2_GUID))) + if (Creature* n2 = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_NECROLYTE_2_GUID))) n2->AI()->DoAction(1337); // remove invincibility for (SummonList::iterator itr = summons.begin(); itr != summons.end(); ++itr) @@ -193,7 +193,7 @@ public: break; case 8: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) c->CastSpell(c, 69753, false); events.RescheduleEvent(9, 400); @@ -235,7 +235,7 @@ public: case 12: if (pInstance) { - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) c->AI()->Talk(SAY_TYRANNUS_INTRO_4); for (SummonList::iterator itr = summons.begin(); itr != summons.end(); ++itr) @@ -285,7 +285,7 @@ public: { me->CastSpell(me, 59514, false); for (uint8 i = 0; i < 2; ++i) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_GUARD_1_GUID + i))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_GUARD_1_GUID + i))) c->CastSpell(c, 70513, false); } } @@ -295,13 +295,13 @@ public: case 15: if (pInstance) { - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_EVENT_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_EVENT_GUID))) c->GetMotionMaster()->MovePoint(0, SBSTyrannusStartPos); if (me->GetEntry() == NPC_JAINA_PART1) { for (uint8 i = 0; i < 2; ++i) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_GUARD_1_GUID + i))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_GUARD_1_GUID + i))) c->CastSpell(c, 70464, false); } } @@ -313,7 +313,7 @@ public: if (pInstance) { for (uint8 i = 0; i < 2; ++i) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_GUARD_1_GUID + i))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_GUARD_1_GUID + i))) c->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); for (SummonList::iterator itr = summons.begin(); itr != summons.end(); ++itr) @@ -403,11 +403,11 @@ public: if (me->GetPositionY() < 206.0f) { - pInstance->SetData64(DATA_NECROLYTE_1_GUID, me->GetGUID()); + pInstance->SetGuidData(DATA_NECROLYTE_1_GUID, me->GetGUID()); } else { - pInstance->SetData64(DATA_NECROLYTE_2_GUID, me->GetGUID()); + pInstance->SetGuidData(DATA_NECROLYTE_2_GUID, me->GetGUID()); } } } @@ -428,7 +428,7 @@ public: events.RescheduleEvent(1, 0); events.RescheduleEvent(2, urand(5000, 9000)); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_LEADER_FIRST_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_LEADER_FIRST_GUID))) c->AI()->SetData(DATA_START_INTRO, 0); } @@ -524,7 +524,7 @@ public: case 1: { if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_GARFROST_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_GARFROST_GUID))) { float angle = c->GetAngle(me); float x = c->GetPositionX() + cos(angle) * 12.0f; @@ -573,14 +573,12 @@ public: { pInstance = me->GetInstanceScript(); killsLeft = 0; - deathbringerGUID[0] = 0; - deathbringerGUID[1] = 0; } InstanceScript* pInstance; EventMap events; uint32 killsLeft; - uint64 deathbringerGUID[2]; + ObjectGuid deathbringerGUID[2]; void MovementInform(uint32 type, uint32 id) override { @@ -916,7 +914,7 @@ public: events.RescheduleEvent(2, 15000); if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_GUID))) { c->AI()->Talk(SAY_PREFIGHT_1); c->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); @@ -960,8 +958,8 @@ public: TSSpawnPos.GetAngle(&TSMidPos); - for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr) - if (Creature* c = pInstance->instance->GetCreature(*itr)) + for (ObjectGuid guid : summons) + if (Creature* c = pInstance->instance->GetCreature(guid)) { float hx, hy, hz, ho; c->GetHomePosition(hx, hy, hz, ho); @@ -974,10 +972,10 @@ public: else if (p == 3) { if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_SINDRAGOSA_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_SINDRAGOSA_GUID))) { - for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr) - if (Creature* s = pInstance->instance->GetCreature(*itr)) + for (ObjectGuid guid : summons) + if (Creature* s = pInstance->instance->GetCreature(guid)) if (s->IsAlive()) Unit::Kill(c, s); if (me->IsAlive()) @@ -1022,14 +1020,14 @@ public: break; case 3: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_GUID))) c->AI()->Talk(SAY_PREFIGHT_2); me->SetFacingTo(5.26f); me->SetOrientation(5.26f); me->SetHomePosition(*me); - for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr) - if (Creature* c = pInstance->instance->GetCreature(*itr)) + for (ObjectGuid guid : summons) + if (Creature* c = pInstance->instance->GetCreature(guid)) { c->SetFacingTo(5.26f); c->SetOrientation(5.26f); @@ -1041,14 +1039,14 @@ public: break; case 4: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_TYRANNUS_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_TYRANNUS_GUID))) c->AI()->DoAction(1); break; case 5: me->SetFacingTo(TSCenterPos.GetOrientation()); Talk(me->GetEntry() == NPC_MARTIN_VICTUS_2 ? SAY_GENERAL_ALLIANCE_OUTRO_1 : SAY_GENERAL_HORDE_OUTRO_1); if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_LEADER_SECOND_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_LEADER_SECOND_GUID))) c->AI()->DoAction(1); break; case 10: @@ -1058,8 +1056,8 @@ public: float offset = frand(0.0f, 10.0f); c->GetMotionMaster()->MovePoint(0, 1047.0f + offset, 118.0f + offset, 628.2f); c->SetHomePosition(*me); - for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr) - if (Creature* s = pInstance->instance->GetCreature(*itr)) + for (ObjectGuid guid : summons) + if (Creature* s = pInstance->instance->GetCreature(guid)) { if (s->GetEntry() == NPC_FALLEN_WARRIOR) continue; @@ -1137,20 +1135,20 @@ public: npc_pos_leader_secondAI(Creature* creature) : NullCreatureAI(creature) { pInstance = me->GetInstanceScript(); - barrierGUID = 0; + barrierGUID.Clear(); events.Reset(); me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); if (pInstance) { - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_RIMEFANG_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_RIMEFANG_GUID))) { c->RemoveAllAuras(); c->GetMotionMaster()->Clear(); c->GetMotionMaster()->MoveIdle(); c->SetVisible(false); } - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_MARTIN_OR_GORKUN_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_MARTIN_OR_GORKUN_GUID))) { c->AI()->DoAction(2); } @@ -1159,7 +1157,7 @@ public: InstanceScript* pInstance; EventMap events; - uint64 barrierGUID; + ObjectGuid barrierGUID; void DoAction(int32 p) override { @@ -1222,7 +1220,7 @@ public: break; case 2: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_MARTIN_OR_GORKUN_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_MARTIN_OR_GORKUN_GUID))) c->AI()->Talk(SAY_GENERAL_OUTRO_2); events.RescheduleEvent(3, me->GetEntry() == NPC_JAINA_PART2 ? 7000 : 8000); @@ -1242,9 +1240,9 @@ public: break; case 5: if (pInstance) - if (Creature* x = pInstance->instance->GetCreature(pInstance->GetData64(DATA_MARTIN_OR_GORKUN_GUID))) + if (Creature* x = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_MARTIN_OR_GORKUN_GUID))) { - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_SINDRAGOSA_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_SINDRAGOSA_GUID))) c->CastSpell(x->GetPositionX(), x->GetPositionY(), x->GetPositionZ(), SPELL_SINDRAGOSA_FROST_BOMB_POS, true); } @@ -1253,18 +1251,18 @@ public: break; case 6: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_SINDRAGOSA_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_SINDRAGOSA_GUID))) c->GetMotionMaster()->MovePoint(0, TSSindragosaPos1); events.RescheduleEvent(7, 4500); break; case 7: if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_SINDRAGOSA_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_SINDRAGOSA_GUID))) c->SetVisible(false); if (GameObject* barrier = pInstance->instance->GetGameObject(barrierGUID)) barrier->Delete(); - barrierGUID = 0; + barrierGUID.Clear(); events.RescheduleEvent(8, 2000); break; @@ -1272,7 +1270,7 @@ public: me->GetMotionMaster()->MovePath(me->GetEntry() == NPC_JAINA_PART2 ? PATH_BEGIN_VALUE + 16 : PATH_BEGIN_VALUE + 17, false); break; case 10: - if (Creature* x = pInstance->instance->GetCreature(pInstance->GetData64(DATA_MARTIN_OR_GORKUN_GUID))) + if (Creature* x = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_MARTIN_OR_GORKUN_GUID))) x->AI()->DoAction(3); break; @@ -1540,7 +1538,7 @@ public: if (inst->GetData(DATA_INSTANCE_PROGRESS) < INSTANCE_PROGRESS_AFTER_TUNNEL_WARN) return false; - if (inst->GetData(DATA_GARFROST) == DONE && inst->GetData(DATA_ICK) == DONE && inst->GetData(DATA_TYRANNUS) != DONE && !inst->GetData64(DATA_MARTIN_OR_GORKUN_GUID)) + if (inst->GetData(DATA_GARFROST) == DONE && inst->GetData(DATA_ICK) == DONE && inst->GetData(DATA_TYRANNUS) != DONE && !inst->GetGuidData(DATA_MARTIN_OR_GORKUN_GUID)) { if (Creature* c = inst->instance->SummonCreature(NPC_GORKUN_IRONSKULL_2, TSSpawnPos)) c->GetMotionMaster()->MovePoint(0, TSMidPos); diff --git a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp index a9a463c75d..ad4ccce587 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp @@ -343,7 +343,7 @@ public: { if (me->ToTempSummon()) { - if (who->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(who->GetOwnerGUID())) + if (who->GetTypeId() == TYPEID_PLAYER || who->GetOwnerGUID().IsPlayer()) if (Unit* summoner = me->ToTempSummon()->GetSummoner()) summoner->GetAI()->DoAction(ACTION_INFORM); return; diff --git a/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp b/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp index 268a025b04..81d3265f5e 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp @@ -60,7 +60,7 @@ public: } uint8 phaseCounter; - std::set<uint64> impaledList; + GuidSet impaledList; void Reset() override { diff --git a/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp b/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp index 035f299df9..5efc4ab702 100644 --- a/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp +++ b/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp @@ -32,10 +32,10 @@ public: { } - uint64 _sladRanAltarGUID; - uint64 _moorabiAltarGUID; - uint64 _drakkariAltarGUID; - uint64 _bridgeGUIDs[6]; + ObjectGuid _sladRanAltarGUID; + ObjectGuid _moorabiAltarGUID; + ObjectGuid _drakkariAltarGUID; + ObjectGuid _bridgeGUIDs[6]; uint32 _keysInCount; uint32 _activateTimer; @@ -44,12 +44,8 @@ public: SetBossNumber(MAX_ENCOUNTERS); LoadDoorData(doorData); - _sladRanAltarGUID = 0; - _moorabiAltarGUID = 0; - _drakkariAltarGUID = 0; _keysInCount = 0; _activateTimer = 0; - memset(&_bridgeGUIDs, 0, sizeof(_bridgeGUIDs)); } void OnGameObjectCreate(GameObject* gameobject) override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index 5aea844336..25c473bc33 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -224,13 +224,13 @@ public: void EnterCombat(Unit* who) override { bool valid = true; - if (Creature* keleseth = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_KELESETH_GUID))) + if (Creature* keleseth = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_KELESETH_GUID))) if (!keleseth->IsAlive() || keleseth->IsInEvadeMode()) valid = false; - if (Creature* taldaram = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_TALDARAM_GUID))) + if (Creature* taldaram = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID))) if (!taldaram->IsAlive() || taldaram->IsInEvadeMode()) valid = false; - if (Creature* valanar = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) if (!valanar->IsAlive() || valanar->IsInEvadeMode()) valid = false; if (!valid) @@ -248,10 +248,10 @@ public: me->SetReactState(REACT_AGGRESSIVE); instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me); - if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_TALDARAM_GUID))) + if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID))) if (!taldaram->IsInEvadeMode()) taldaram->SetInCombatWithZone(); - if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) if (!valanar->IsInEvadeMode()) valanar->SetInCombatWithZone(); @@ -289,10 +289,10 @@ public: } Talk(SAY_KELESETH_DEATH); - if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_TALDARAM_GUID))) + if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID))) if (taldaram->IsAlive()) Unit::Kill(taldaram, taldaram); - if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) if (valanar->IsAlive()) Unit::Kill(valanar, valanar); } @@ -413,9 +413,9 @@ public: me->SetHealth(me->GetMaxHealth()); DoAction(ACTION_REMOVE_INVOCATION); _evading = true; - if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_TALDARAM_GUID))) + if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID))) taldaram->AI()->EnterEvadeMode(); - if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) valanar->AI()->EnterEvadeMode(); ScriptedAI::EnterEvadeMode(); _evading = false; @@ -483,13 +483,13 @@ public: void EnterCombat(Unit* who) override { bool valid = true; - if (Creature* keleseth = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_KELESETH_GUID))) + if (Creature* keleseth = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_KELESETH_GUID))) if (!keleseth->IsAlive() || keleseth->IsInEvadeMode()) valid = false; - if (Creature* taldaram = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_TALDARAM_GUID))) + if (Creature* taldaram = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID))) if (!taldaram->IsAlive() || taldaram->IsInEvadeMode()) valid = false; - if (Creature* valanar = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) if (!valanar->IsAlive() || valanar->IsInEvadeMode()) valid = false; if (!valid) @@ -507,10 +507,10 @@ public: me->SetReactState(REACT_AGGRESSIVE); instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me); - if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_KELESETH_GUID))) + if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_KELESETH_GUID))) if (!keleseth->IsInEvadeMode()) keleseth->SetInCombatWithZone(); - if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) if (!valanar->IsInEvadeMode()) valanar->SetInCombatWithZone(); @@ -543,10 +543,10 @@ public: } Talk(EMOTE_TALDARAM_DEATH); - if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_KELESETH_GUID))) + if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_KELESETH_GUID))) if (keleseth->IsAlive()) Unit::Kill(keleseth, keleseth); - if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) if (valanar->IsAlive()) Unit::Kill(valanar, valanar); } @@ -697,9 +697,9 @@ public: me->SetHealth(me->GetMaxHealth()); DoAction(ACTION_REMOVE_INVOCATION); _evading = true; - if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_KELESETH_GUID))) + if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_KELESETH_GUID))) keleseth->AI()->EnterEvadeMode(); - if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) valanar->AI()->EnterEvadeMode(); ScriptedAI::EnterEvadeMode(); _evading = false; @@ -767,13 +767,13 @@ public: void EnterCombat(Unit* who) override { bool valid = true; - if (Creature* keleseth = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_KELESETH_GUID))) + if (Creature* keleseth = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_KELESETH_GUID))) if (!keleseth->IsAlive() || keleseth->IsInEvadeMode()) valid = false; - if (Creature* taldaram = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_TALDARAM_GUID))) + if (Creature* taldaram = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID))) if (!taldaram->IsAlive() || taldaram->IsInEvadeMode()) valid = false; - if (Creature* valanar = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) if (!valanar->IsAlive() || valanar->IsInEvadeMode()) valid = false; if (!valid) @@ -793,10 +793,10 @@ public: me->SetReactState(REACT_AGGRESSIVE); instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me); - if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_KELESETH_GUID))) + if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_KELESETH_GUID))) if (!keleseth->IsInEvadeMode()) keleseth->SetInCombatWithZone(); - if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_TALDARAM_GUID))) + if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID))) if (!taldaram->IsInEvadeMode()) taldaram->SetInCombatWithZone(); @@ -838,10 +838,10 @@ public: Talk(SAY_VALANAR_DEATH); instance->SetBossState(DATA_BLOOD_PRINCE_COUNCIL, DONE); - if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_KELESETH_GUID))) + if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_KELESETH_GUID))) if (keleseth->IsAlive()) Unit::Kill(keleseth, keleseth); - if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_TALDARAM_GUID))) + if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID))) if (taldaram->IsAlive()) Unit::Kill(taldaram, taldaram); } @@ -944,8 +944,8 @@ public: bool CheckRoom() { - Creature* keleseth = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_KELESETH_GUID)); - Creature* taldaram = instance->instance->GetCreature(instance->GetData64(DATA_PRINCE_TALDARAM_GUID)); + Creature* keleseth = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_KELESETH_GUID)); + Creature* taldaram = instance->instance->GetCreature(instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID)); if (keleseth && taldaram && CheckBoundary(me) && CheckBoundary(keleseth) && CheckBoundary(taldaram)) return true; @@ -968,10 +968,10 @@ public: case EVENT_INVOCATION_OF_BLOOD: { uint32 visualSpellId = 0; - Creature* current = instance->instance->GetCreature(instance->GetData64(invocationOrder[currentInvocationIndex])); + Creature* current = instance->instance->GetCreature(instance->GetGuidData(invocationOrder[currentInvocationIndex])); if (++currentInvocationIndex >= 3) currentInvocationIndex = 0; - Creature* next = instance->instance->GetCreature(instance->GetData64(invocationOrder[currentInvocationIndex])); + Creature* next = instance->instance->GetCreature(instance->GetGuidData(invocationOrder[currentInvocationIndex])); switch (invocationOrder[currentInvocationIndex]) { case DATA_PRINCE_KELESETH_GUID: @@ -1036,9 +1036,9 @@ public: me->SetHealth(me->GetMaxHealth()); DoAction(ACTION_REMOVE_INVOCATION); _evading = true; - if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_KELESETH_GUID))) + if (Creature* keleseth = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_KELESETH_GUID))) keleseth->AI()->EnterEvadeMode(); - if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_TALDARAM_GUID))) + if (Creature* taldaram = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID))) taldaram->AI()->EnterEvadeMode(); BossAI::EnterEvadeMode(); _evading = false; @@ -1127,15 +1127,15 @@ public: me->GetMotionMaster()->MovePoint(POINT_INTRO_DESPAWN, introFinalPos); _events.Reset(); - if (Creature* keleseth = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_PRINCE_KELESETH_GUID))) + if (Creature* keleseth = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_PRINCE_KELESETH_GUID))) { keleseth->AI()->DoAction(ACTION_STAND_UP); } - if (Creature* taldaram = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_PRINCE_TALDARAM_GUID))) + if (Creature* taldaram = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_PRINCE_TALDARAM_GUID))) { taldaram->AI()->DoAction(ACTION_STAND_UP); } - if (Creature* valanar = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) { valanar->AI()->DoAction(ACTION_STAND_UP); } @@ -1240,7 +1240,6 @@ public: { npc_ball_of_flameAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - _chaseGUID = 0; _exploded = false; _started = false; if (me->GetEntry() == NPC_BALL_OF_INFERNO_FLAME) @@ -1249,7 +1248,7 @@ public: } InstanceScript* _instance; - uint64 _chaseGUID; + ObjectGuid _chaseGUID; bool _exploded; bool _started; @@ -1276,7 +1275,7 @@ public: } } - void SetGUID(uint64 guid, int32 /*type*/) override + void SetGUID(ObjectGuid guid, int32 /*type*/) override { _chaseGUID = guid; } @@ -1358,7 +1357,7 @@ public: { if (InstanceScript* instance = me->GetInstanceScript()) { - if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PRINCE_VALANAR_GUID))) + if (Creature* valanar = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PRINCE_VALANAR_GUID))) { valanar->AI()->JustSummoned(me); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index 5621e9dcc1..7784d3eca3 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -133,18 +133,18 @@ public: bool _creditBloodQuickening; bool _killMinchar; - uint64 _tankGUID; - uint64 _offtankGUID; - std::set<uint64> _bloodboltedPlayers; - std::set<uint64> _vampires; + ObjectGuid _tankGUID; + ObjectGuid _offtankGUID; + GuidSet _bloodboltedPlayers; + GuidSet _vampires; bool bEnteredCombat; // needed for failing an attempt in JustReachedHome() void Reset() override { _creditBloodQuickening = false; _killMinchar = false; - _tankGUID = 0; - _offtankGUID = 0; + _tankGUID.Clear(); + _offtankGUID.Clear(); _vampires.clear(); CleanAuras(); me->SetReactState(REACT_AGGRESSIVE); @@ -202,7 +202,7 @@ public: Map::PlayerList const& pl = me->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) if (Player* p = itr->GetSource()) - p->KilledMonsterCredit(RAID_MODE(NPC_INFILTRATOR_MINCHAR_BQ, NPC_BLOOD_QUICKENING_CREDIT_25), 0); + p->KilledMonsterCredit(RAID_MODE(NPC_INFILTRATOR_MINCHAR_BQ, NPC_BLOOD_QUICKENING_CREDIT_25)); if (Creature* minchar = me->FindNearestCreature(NPC_INFILTRATOR_MINCHAR_BQ, 200.0f)) { minchar->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); @@ -369,8 +369,8 @@ public: if (target->GetDistance(me->GetVictim()) > 39.0f || me->GetDistance(me->GetVictim()) > 39.0f) { - _tankGUID = 0; - _offtankGUID = 0; + _tankGUID.Clear(); + _offtankGUID.Clear(); events.ScheduleEvent(EVENT_BLOOD_MIRROR, 2500); break; } @@ -514,17 +514,17 @@ public: instance->DoRemoveAurasDueToSpellOnPlayers(PRESENCE_OF_THE_DARKFALLEN); } - bool WasVampire(uint64 guid) + bool WasVampire(ObjectGuid guid) { return _vampires.count(guid) != 0; } - bool WasBloodbolted(uint64 guid) + bool WasBloodbolted(ObjectGuid guid) { return _bloodboltedPlayers.count(guid) != 0; } - void SetGUID(uint64 guid, int32 type = 0) override + void SetGUID(ObjectGuid guid, int32 type = 0) override { switch (type) { @@ -760,7 +760,7 @@ public: void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { if (InstanceScript* instance = GetTarget()->GetInstanceScript()) - if (Creature* bloodQueen = ObjectAccessor::GetCreature(*GetTarget(), instance->GetData64(DATA_BLOOD_QUEEN_LANA_THEL))) + if (Creature* bloodQueen = ObjectAccessor::GetCreature(*GetTarget(), instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL))) bloodQueen->AI()->Talk(EMOTE_BLOODTHIRST, GetTarget()); } @@ -769,7 +769,7 @@ public: Unit* target = GetTarget(); if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) if (InstanceScript* instance = target->GetInstanceScript()) - if (Creature* bloodQueen = ObjectAccessor::GetCreature(*target, instance->GetData64(DATA_BLOOD_QUEEN_LANA_THEL))) + if (Creature* bloodQueen = ObjectAccessor::GetCreature(*target, instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL))) if (bloodQueen->IsAlive() && bloodQueen->IsInCombat()) { // this needs to be done BEFORE charm aura or we hit an assert in Unit::SetCharmedBy @@ -871,7 +871,7 @@ public: return; uint32 spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_FRENZIED_BLOODTHIRST, GetCaster()); - GetCaster()->RemoveAura(spellId, 0, 0, AURA_REMOVE_BY_ENEMY_SPELL); + GetCaster()->RemoveAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL); GetCaster()->CastSpell(GetCaster(), SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_PLR, TRIGGERED_FULL_MASK); if (Aura* aura = GetCaster()->GetAura(SPELL_GUSHING_WOUND)) @@ -886,7 +886,7 @@ public: } if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* bloodQueen = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(DATA_BLOOD_QUEEN_LANA_THEL))) + if (Creature* bloodQueen = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL))) bloodQueen->AI()->SetGUID(GetHitUnit()->GetGUID(), GUID_VAMPIRE); } @@ -952,7 +952,7 @@ public: return; if (InstanceScript* instance = GetHitUnit()->GetInstanceScript()) - GetHitUnit()->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, instance->GetData64(DATA_BLOOD_QUEEN_LANA_THEL)); + GetHitUnit()->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL)); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index 0b048df6b9..1cea287066 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -299,7 +299,7 @@ public: Talk(SAY_DEATH); instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_MARK_OF_THE_FALLEN_CHAMPION); - if (Creature* creature = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SAURFANG_EVENT_NPC))) + if (Creature* creature = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SAURFANG_EVENT_NPC))) creature->AI()->DoAction(ACTION_START_OUTRO); } @@ -364,7 +364,7 @@ public: if (type != POINT_MOTION_TYPE && id != POINT_SAURFANG) return; - instance->HandleGameObject(instance->GetData64(GO_SAURFANG_S_DOOR), false); + instance->HandleGameObject(instance->GetGuidData(GO_SAURFANG_S_DOOR), false); } void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell) override @@ -485,7 +485,7 @@ public: void EnterEvadeMode() override { BossAI::EnterEvadeMode(); - if (Creature* creature = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SAURFANG_EVENT_NPC))) + if (Creature* creature = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SAURFANG_EVENT_NPC))) creature->AI()->DoAction(ACTION_EVADE); } @@ -532,7 +532,7 @@ public: if (_events.GetPhaseMask() & PHASE_INTRO_MASK) return; - Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG)); + Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG)); if (!deathbringer || deathbringer->IsInEvadeMode()) return; @@ -550,11 +550,11 @@ public: _events.SetPhase(PHASE_INTRO_H); _events.ScheduleEvent(EVENT_INTRO_HORDE_2, 5000, 0, PHASE_INTRO_H); _events.ScheduleEvent(EVENT_INTRO_HORDE_3, 18500, 0, PHASE_INTRO_H); - _instance->HandleGameObject(_instance->GetData64(GO_SAURFANG_S_DOOR), true); + _instance->HandleGameObject(_instance->GetGuidData(GO_SAURFANG_S_DOOR), true); - if (GameObject* teleporter = ObjectAccessor::GetGameObject(*me, _instance->GetData64(GO_SCOURGE_TRANSPORTER_SAURFANG))) + if (GameObject* teleporter = ObjectAccessor::GetGameObject(*me, _instance->GetGuidData(GO_SCOURGE_TRANSPORTER_SAURFANG))) { - _instance->HandleGameObject(0, false, teleporter); + _instance->HandleGameObject(ObjectGuid::Empty, false, teleporter); teleporter->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); } @@ -629,7 +629,7 @@ public: _events.ScheduleEvent(EVENT_INTRO_FINISH, 46700 + 1000 + 9000, 0, PHASE_INTRO_H); break; /*case POINT_CORPSE: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) { deathbringer->CastSpell(me, SPELL_RIDE_VEHICLE, true); deathbringer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -639,7 +639,7 @@ public: _events.ScheduleEvent(EVENT_OUTRO_HORDE_5, 4000); break; case POINT_FINAL: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) deathbringer->DespawnOrUnsummon(); me->DespawnOrUnsummon(); break;*/ @@ -657,7 +657,7 @@ public: case 0: break; case EVENT_INTRO_HORDE_2: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) deathbringer->AI()->Talk(SAY_INTRO_HORDE_2); break; case EVENT_INTRO_HORDE_3: @@ -665,7 +665,7 @@ public: me->GetMotionMaster()->MovePoint(POINT_FIRST_STEP, firstStepPos.GetPositionX(), firstStepPos.GetPositionY(), firstStepPos.GetPositionZ()); break; case EVENT_INTRO_HORDE_4: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) deathbringer->AI()->Talk(SAY_INTRO_HORDE_4); break; case EVENT_INTRO_HORDE_5: @@ -684,14 +684,14 @@ public: me->GetMotionMaster()->MoveCharge(chargePos[0].GetPositionX(), chargePos[0].GetPositionY(), chargePos[0].GetPositionZ(), 8.5f, POINT_CHARGE); break; case EVENT_INTRO_HORDE_9: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) { deathbringer->AI()->DoCast(me, SPELL_GRIP_OF_AGONY); deathbringer->AI()->Talk(SAY_INTRO_HORDE_9); } break; case EVENT_INTRO_FINISH: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) { deathbringer->AI()->DoAction(ACTION_INTRO_DONE); deathbringer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); @@ -701,7 +701,7 @@ public: break; /*case EVENT_OUTRO_HORDE_1: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) me->SetFacingToObject(deathbringer); Talk(SAY_OUTRO_HORDE_2); break; @@ -709,7 +709,7 @@ public: Talk(SAY_OUTRO_HORDE_3); break; case EVENT_OUTRO_HORDE_3: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) { float x, y, z; deathbringer->GetClosePoint(x, y, z, deathbringer->GetObjectSize()); @@ -793,7 +793,7 @@ public: if (_events.GetPhaseMask() & PHASE_INTRO_MASK) return; - Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG)); + Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG)); if (!deathbringer || deathbringer->IsInEvadeMode()) return; @@ -812,11 +812,11 @@ public: _events.ScheduleEvent(EVENT_INTRO_ALLIANCE_2, 2500, 0, PHASE_INTRO_A); _events.ScheduleEvent(EVENT_INTRO_ALLIANCE_3, 20000, 0, PHASE_INTRO_A); _events.ScheduleEvent(EVENT_INTRO_ALLIANCE_4, 2500 + 17500 + 9500, 0, PHASE_INTRO_A); - _instance->HandleGameObject(_instance->GetData64(GO_SAURFANG_S_DOOR), true); + _instance->HandleGameObject(_instance->GetGuidData(GO_SAURFANG_S_DOOR), true); - if (GameObject* teleporter = ObjectAccessor::GetGameObject(*me, _instance->GetData64(GO_SCOURGE_TRANSPORTER_SAURFANG))) + if (GameObject* teleporter = ObjectAccessor::GetGameObject(*me, _instance->GetGuidData(GO_SCOURGE_TRANSPORTER_SAURFANG))) { - _instance->HandleGameObject(0, false, teleporter); + _instance->HandleGameObject(ObjectGuid::Empty, false, teleporter); teleporter->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); } @@ -898,11 +898,11 @@ public: case 0: break; case EVENT_INTRO_ALLIANCE_2: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) deathbringer->AI()->Talk(SAY_INTRO_ALLIANCE_2); break; case EVENT_INTRO_ALLIANCE_3: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) deathbringer->AI()->Talk(SAY_INTRO_ALLIANCE_3); break; case EVENT_INTRO_ALLIANCE_4: @@ -916,20 +916,20 @@ public: me->GetMotionMaster()->MoveCharge(chargePos[0].GetPositionX(), chargePos[0].GetPositionY(), chargePos[0].GetPositionZ(), 8.5f, POINT_CHARGE); break; case EVENT_INTRO_ALLIANCE_6: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) { deathbringer->AI()->Talk(SAY_INTRO_ALLIANCE_7); deathbringer->AI()->DoCast(me, SPELL_GRIP_OF_AGONY); } break; case EVENT_INTRO_ALLIANCE_7: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) { deathbringer->AI()->Talk(SAY_INTRO_ALLIANCE_6); } break; case EVENT_INTRO_FINISH: - if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG))) + if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG))) { deathbringer->AI()->DoAction(ACTION_INTRO_DONE); deathbringer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); @@ -1113,7 +1113,7 @@ public: if (Map* map = eventInfo.GetActor()->FindMap()) if (InstanceMap* imap = map->ToInstanceMap()) if (InstanceScript* isc = imap->GetInstanceScript()) - if (uint64 sguid = isc->GetData64(3) //DATA_DEATHBRINGER_SAURFANG + if (ObjectGuid sguid = isc->GetGuidData(3) //DATA_DEATHBRINGER_SAURFANG if (Creature* saurfang = ObjectAccessor::GetCreature(*eventInfo.GetActor(), sguid)) markCount = saurfang->IsAIEnabled ? saurfang->AI()->GetData(123456) : 0; //FALLEN_CHAMPION_CAST_COUNT */ diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp index 450027e59d..9a24263b95 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp @@ -74,10 +74,10 @@ public: { boss_festergutAI(Creature* creature) : BossAI(creature, DATA_FESTERGUT) { - _gasDummyGUID = 0; + _gasDummyGUID.Clear(); } - uint64 _gasDummyGUID; + ObjectGuid _gasDummyGUID; uint32 _maxInoculatedStack; uint32 _inhaleCounter; @@ -118,7 +118,7 @@ public: if (Creature* gasDummy = me->FindNearestCreature(NPC_GAS_DUMMY, 100.0f, true)) _gasDummyGUID = gasDummy->GetGUID(); - if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) professor->AI()->DoAction(ACTION_FESTERGUT_COMBAT); } @@ -126,7 +126,7 @@ public: { _JustDied(); Talk(SAY_DEATH); - if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) professor->AI()->DoAction(ACTION_FESTERGUT_DEATH); RemoveBlight(); @@ -141,7 +141,7 @@ public: void EnterEvadeMode() override { ScriptedAI::EnterEvadeMode(); - if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) professor->AI()->EnterEvadeMode(); } @@ -238,7 +238,7 @@ public: break; case EVENT_FESTERGUT_GOO: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me))) - if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) professor->CastSpell(target, SPELL_MALLABLE_GOO_H, true); events.ScheduleEvent(EVENT_FESTERGUT_GOO, urand(15000, 20000)); default: @@ -297,7 +297,7 @@ public: caster->ToCreature()->AI()->Talk(EMOTE_PUNGENT_BLIGHT); if (InstanceScript* inst = caster->GetInstanceScript()) - if (Creature* professor = ObjectAccessor::GetCreature(*caster, inst->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*caster, inst->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) professor->AI()->DoAction(ACTION_FESTERGUT_GAS); } @@ -342,7 +342,7 @@ public: } GetTarget()->CastSpell(GetTarget(), SPELL_INOCULATED, true); if (InstanceScript* instance = GetTarget()->GetInstanceScript()) - if (Creature* festergut = ObjectAccessor::GetCreature(*GetTarget(), instance->GetData64(DATA_FESTERGUT))) + if (Creature* festergut = ObjectAccessor::GetCreature(*GetTarget(), instance->GetGuidData(DATA_FESTERGUT))) festergut->AI()->SetData(DATA_INOCULATED_STACK, inoculatedStack); } @@ -463,7 +463,7 @@ public: void JustDied(Unit* /*killer*/) override { if (InstanceScript* _instance = me->GetInstanceScript()) - if (Creature* festergut = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_FESTERGUT))) + if (Creature* festergut = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FESTERGUT))) if (festergut->IsAlive()) festergut->AI()->Talk(SAY_STINKY_DEAD); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp index 67494c6b97..bbc6fc4b0c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -393,8 +393,13 @@ public: void ResetSlots(TeamId teamId, MotionTransport* t) { _transport = t; - memset(_controlledSlots, 0, sizeof(uint64)* MAX_SLOTS); - memset(_respawnCooldowns, 0, sizeof(time_t)* MAX_SLOTS); + + for (uint8 i = 0; i < MAX_SLOTS; ++i) + { + _controlledSlots[i].Clear(); + _respawnCooldowns[i] = time_t(0); + } + _spawnPoint = teamId == TEAM_HORDE ? &OrgrimsHammerAddsSpawnPos : &SkybreakerAddsSpawnPos; _slotInfo = teamId == TEAM_HORDE ? OrgrimsHammerSlotInfo : SkybreakerSlotInfo; } @@ -440,7 +445,7 @@ public: void ClearSlot(PassengerSlots slot) { - _controlledSlots[slot] = 0; + _controlledSlots[slot].Clear(); _respawnCooldowns[slot] = time(nullptr) + _slotInfo[slot].Cooldown; } @@ -457,7 +462,7 @@ private: return newPos; } - uint64 _controlledSlots[MAX_SLOTS]; + ObjectGuid _controlledSlots[MAX_SLOTS]; time_t _respawnCooldowns[MAX_SLOTS]; MotionTransport* _transport; Position const* _spawnPoint; @@ -489,7 +494,7 @@ private: class ResetEncounterEvent : public BasicEvent { public: - ResetEncounterEvent(Unit* caster, uint32 spellId, uint64 otherTransport) : _caster(caster), _spellId(spellId), _otherTransport(otherTransport) { } + ResetEncounterEvent(Unit* caster, uint32 spellId, ObjectGuid otherTransport) : _caster(caster), _spellId(spellId), _otherTransport(otherTransport) { } bool Execute(uint64, uint32) override { @@ -497,10 +502,10 @@ public: _caster->GetTransport()->ToMotionTransport()->UnloadNonStaticPassengers(); _caster->GetTransport()->AddObjectToRemoveList(); - if (GameObject* go = HashMapHolder<GameObject>::Find(_otherTransport)) + if (Transport* transport = ObjectAccessor::GetTransport(*_caster, _otherTransport)) { - go->ToMotionTransport()->UnloadNonStaticPassengers(); - go->AddObjectToRemoveList(); + transport->ToMotionTransport()->UnloadNonStaticPassengers(); + transport->AddObjectToRemoveList(); } return true; @@ -509,7 +514,7 @@ public: private: Unit* _caster; uint32 _spellId; - uint64 _otherTransport; + ObjectGuid _otherTransport; }; class npc_gunship : public CreatureScript @@ -586,7 +591,7 @@ public: } uint32 cannonEntry = _teamIdInInstance == TEAM_HORDE ? NPC_HORDE_GUNSHIP_CANNON : NPC_ALLIANCE_GUNSHIP_CANNON; - if (GameObject* go = _instance->instance->GetGameObject(_instance->GetData64(DATA_ICECROWN_GUNSHIP_BATTLE))) + if (GameObject* go = _instance->instance->GetGameObject(_instance->GetGuidData(DATA_ICECROWN_GUNSHIP_BATTLE))) if (MotionTransport* t = go->ToMotionTransport()) { Transport::PassengerSet const& passengers = t->GetStaticPassengers(); @@ -598,7 +603,7 @@ public: cannon->CastSpell(cannon, SPELL_EJECT_ALL_PASSENGERS, true); WorldPacket data(SMSG_PLAYER_VEHICLE_DATA, cannon->GetPackGUID().size() + 4); - data.append(cannon->GetPackGUID()); + data << cannon->GetPackGUID(); data << uint32(0); cannon->SendMessageToSet(&data, true); @@ -618,8 +623,8 @@ public: if (isVictory) { - if (GameObject* go = HashMapHolder<GameObject>::Find(_instance->GetData64(DATA_ICECROWN_GUNSHIP_BATTLE))) - if (MotionTransport* otherTransport = go->ToMotionTransport()) + if (Transport * transport = _instance->instance->GetTransport(_instance->GetGuidData(DATA_ICECROWN_GUNSHIP_BATTLE))) + if (MotionTransport* otherTransport = transport->ToMotionTransport()) otherTransport->EnableMovement(true); me->GetTransport()->ToMotionTransport()->EnableMovement(true); @@ -632,7 +637,7 @@ public: } for (uint8 i = 0; i < 2; ++i) - if (GameObject* go = _instance->instance->GetGameObject(_instance->GetData64(i == 0 ? DATA_ICECROWN_GUNSHIP_BATTLE : DATA_ENEMY_GUNSHIP))) + if (GameObject* go = _instance->instance->GetGameObject(_instance->GetGuidData(i == 0 ? DATA_ICECROWN_GUNSHIP_BATTLE : DATA_ENEMY_GUNSHIP))) if (MotionTransport* t = go->ToMotionTransport()) { Transport::PassengerSet const& passengers = t->GetPassengers(); @@ -649,16 +654,16 @@ public: else { uint32 teleportSpellId = _teamIdInInstance == TEAM_HORDE ? SPELL_TELEPORT_PLAYERS_ON_RESET_H : SPELL_TELEPORT_PLAYERS_ON_RESET_A; - me->m_Events.AddEvent(new ResetEncounterEvent(me, teleportSpellId, _instance->GetData64(DATA_ENEMY_GUNSHIP)), me->m_Events.CalculateTime(8000)); + me->m_Events.AddEvent(new ResetEncounterEvent(me, teleportSpellId, _instance->GetGuidData(DATA_ENEMY_GUNSHIP)), me->m_Events.CalculateTime(8000)); } } - void SetGUID(uint64 guid, int32 id/* = 0*/) override + void SetGUID(ObjectGuid guid, int32 id/* = 0*/) override { if (id != ACTION_SHIP_VISITS_ENEMY && id != ACTION_SHIP_VISITS_SELF) return; - std::map<uint64, uint32>::iterator itr = _shipVisits.find(guid); + std::map<ObjectGuid, uint32>::iterator itr = _shipVisits.find(guid); if (itr == _shipVisits.end()) { if (id == ACTION_SHIP_VISITS_ENEMY) @@ -693,7 +698,7 @@ public: if (id != ACTION_SHIP_VISITS_ENEMY) return 0; - for (std::map<uint64, uint32>::const_iterator itr = _shipVisits.begin(); itr != _shipVisits.end(); ++itr) + for (std::map<ObjectGuid, uint32>::const_iterator itr = _shipVisits.begin(); itr != _shipVisits.end(); ++itr) if (itr->second == 0) return 0; @@ -703,7 +708,7 @@ public: private: InstanceScript* _instance; TeamId _teamIdInInstance; - std::map<uint64, uint32> _shipVisits; + std::map<ObjectGuid, uint32> _shipVisits; bool _died; bool _summonedFirstMage; }; @@ -951,8 +956,8 @@ public: me->SummonCreature(NPC_TELEPORT_PORTAL, x, y, z, o, TEMPSUMMON_TIMED_DESPAWN, 21000); } - if (GameObject* go = HashMapHolder<GameObject>::Find(_instance->GetData64(DATA_ICECROWN_GUNSHIP_BATTLE))) - if (MotionTransport* skybreaker = go->ToMotionTransport()) + if (Transport* transport = _instance->instance->GetTransport(_instance->GetGuidData(DATA_ICECROWN_GUNSHIP_BATTLE))) + if (MotionTransport* skybreaker = transport->ToMotionTransport()) { float x, y, z, o; SkybreakerTeleportExit.GetPosition(x, y, z, o); @@ -1290,8 +1295,8 @@ public: me->SummonCreature(NPC_TELEPORT_PORTAL, x, y, z, o, TEMPSUMMON_TIMED_DESPAWN, 21000); } - if (GameObject* go = HashMapHolder<GameObject>::Find(_instance->GetData64(DATA_ICECROWN_GUNSHIP_BATTLE))) - if (MotionTransport* orgrimsHammer = go->ToMotionTransport()) + if (Transport* transport = _instance->instance->GetTransport(_instance->GetGuidData(DATA_ICECROWN_GUNSHIP_BATTLE))) + if (MotionTransport* orgrimsHammer = transport->ToMotionTransport()) { float x, y, z, o; OrgrimsHammerTeleportExit.GetPosition(x, y, z, o); @@ -1570,8 +1575,8 @@ struct npc_gunship_boarding_addAI : public ScriptedAI if (!myTransport) return; - if (GameObject* go = HashMapHolder<GameObject>::Find(Instance->GetData64(DATA_ICECROWN_GUNSHIP_BATTLE))) - if (Transport* destTransport = go->ToTransport()) + if (Transport* transport = Instance->instance->GetTransport(Instance->GetGuidData(DATA_ICECROWN_GUNSHIP_BATTLE))) + if (Transport* destTransport = transport->ToTransport()) destTransport->CalculatePassengerPosition(x, y, z, &o); float angle = frand(0, M_PI * 2.0f); @@ -2119,7 +2124,7 @@ public: void SelectTransport(WorldObject*& target) { if (InstanceScript* instance = target->GetInstanceScript()) - target = HashMapHolder<GameObject>::Find(instance->GetData64(DATA_ICECROWN_GUNSHIP_BATTLE)); + target = instance->instance->GetTransport(instance->GetGuidData(DATA_ICECROWN_GUNSHIP_BATTLE)); } void RelocateDest(SpellEffIndex /*effIndex*/) @@ -2225,7 +2230,7 @@ public: bool operator()(WorldObject* unit) { - return unit->GetTransGUID() != _inst->GetData64(DATA_ENEMY_GUNSHIP); + return unit->GetTransGUID() != _inst->GetGuidData(DATA_ENEMY_GUNSHIP); } private: @@ -2316,7 +2321,7 @@ public: if (Player* player = passenger->ToPlayer()) { WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, GetUnitOwner()->GetPackGUID().size() + 1); - data.append(GetUnitOwner()->GetPackGUID()); + data << GetUnitOwner()->GetPackGUID(); data << uint8(value); player->GetSession()->SendPacket(&data); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp index ad7ed6eb08..6b7629eb4f 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp @@ -230,13 +230,13 @@ public: struct boss_lady_deathwhisperAI : public BossAI { - boss_lady_deathwhisperAI(Creature* creature) : BossAI(creature, DATA_LADY_DEATHWHISPER), _introDone(false), _darnavanGUID(0) { } + boss_lady_deathwhisperAI(Creature* creature) : BossAI(creature, DATA_LADY_DEATHWHISPER), _introDone(false) { } void Reset() override { if (Creature* darnavan = ObjectAccessor::GetCreature(*me, _darnavanGUID)) darnavan->DespawnOrUnsummon(); - _darnavanGUID = 0; + _darnavanGUID.Clear(); _waveCounter = 0; _Reset(); me->SetPower(POWER_MANA, me->GetMaxPower(POWER_MANA)); @@ -369,8 +369,8 @@ public: { // shouldn't be casted on any victim of summoned mobs bool valid = true; - for (std::list<uint64>::const_iterator itr = summons.begin(); itr != summons.end(); ++itr) - if (Creature* c = ObjectAccessor::GetCreature(*me, (*itr))) + for (ObjectGuid const guid : summons) + if (Creature* c = ObjectAccessor::GetCreature(*me, guid)) if (c->IsAlive() && c->GetVictim() && c->GetVictim()->GetGUID() == plr->GetGUID()) { valid = false; @@ -516,10 +516,10 @@ public: for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next()) if (Player* member = itr->GetSource()) if (member->IsInMap(owner)) - member->KilledMonsterCredit(NPC_DARNAVAN_CREDIT, 0); + member->KilledMonsterCredit(NPC_DARNAVAN_CREDIT); } else - owner->KilledMonsterCredit(NPC_DARNAVAN_CREDIT, 0); + owner->KilledMonsterCredit(NPC_DARNAVAN_CREDIT); } } } @@ -642,7 +642,7 @@ public: private: bool _introDone; - uint64 _darnavanGUID; + ObjectGuid _darnavanGUID; uint32 _waveCounter; }; @@ -739,7 +739,7 @@ public: DoZoneInCombat(me); me->CastSpell(me, SPELL_FANATIC_S_DETERMINATION); - if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_LADY_DEATHWHISPER))) + if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_LADY_DEATHWHISPER))) ladyDeathwhisper->AI()->Talk(SAY_ANIMATE_DEAD); break; case EVENT_SPELL_CULTIST_DARK_MARTYRDOM: @@ -860,7 +860,7 @@ public: DoZoneInCombat(me); me->CastSpell(me, SPELL_ADHERENT_S_DETERMINATION); - if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_LADY_DEATHWHISPER))) + if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_LADY_DEATHWHISPER))) ladyDeathwhisper->AI()->Talk(SAY_ANIMATE_DEAD); break; case EVENT_SPELL_CULTIST_DARK_MARTYRDOM: @@ -898,11 +898,11 @@ public: { me->SetControlled(true, UNIT_STATE_ROOT); unroot_timer = 500; - targetGUID = 0; + targetGUID.Clear(); } uint16 unroot_timer; - uint64 targetGUID; + ObjectGuid targetGUID; void Reset() override { @@ -1140,7 +1140,7 @@ public: if (InstanceScript* instance = player->GetInstanceScript()) if (instance->GetBossState(DATA_LADY_DEATHWHISPER) != DONE) if (!player->IsGameMaster()) - if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*player, instance->GetData64(DATA_LADY_DEATHWHISPER))) + if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_LADY_DEATHWHISPER))) ladyDeathwhisper->AI()->DoAction(ACTION_START_INTRO); return true; } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index f0343d0381..d2e132af69 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -98,7 +98,7 @@ public: bool _introDone; bool _boneSlice; - uint64 _lastBoneSliceTargets[3]; + ObjectGuid _lastBoneSliceTargets[3]; void Reset() override { @@ -111,7 +111,9 @@ public: events.ScheduleEvent(EVENT_ENRAGE, 600000); _boneSlice = false; - memset(_lastBoneSliceTargets, 0, 3 * sizeof(uint64)); + + for (uint8 i = 0; i < 3; ++i) + _lastBoneSliceTargets[i].Clear(); instance->SetData(DATA_BONED_ACHIEVEMENT, uint32(true)); } @@ -135,12 +137,12 @@ public: } } - uint64 GetGUID(int32 id) const override + ObjectGuid GetGUID(int32 id) const override { if (id >= 0 && id <= 2) return _lastBoneSliceTargets[id]; - return (uint64)0; + return ObjectGuid::Empty; } void UpdateAI(uint32 diff) override @@ -243,7 +245,10 @@ public: DoCastVictim(SPELL_BONE_SLICE); if (_boneSlice && me->isAttackReady() && me->GetVictim() && !me->HasUnitState(UNIT_STATE_CASTING) && me->IsWithinMeleeRange(me->GetVictim())) - memset(_lastBoneSliceTargets, 0, 3 * sizeof(uint64)); + { + for (uint8 i = 0; i < 3; ++i) + _lastBoneSliceTargets[i].Clear(); + } DoMeleeAttackIfReady(); } @@ -406,8 +411,8 @@ public: if (u->GetEntry() == NPC_BONE_SPIKE && u->GetTypeId() == TYPEID_UNIT) u->ToCreature()->AI()->DoAction(-1337); - uint64 petGUID = summoner->GetPetGUID(); - summoner->SetPetGUID(0); + ObjectGuid petGUID = summoner->GetPetGUID(); + summoner->SetPetGUID(ObjectGuid::Empty); me->CastSpell(summoner, SPELL_IMPALED, true); summoner->CastSpell(me, SPELL_RIDE_VEHICLE, true); //summoner->ClearUnitState(UNIT_STATE_ONVEHICLE); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index 40ce72a1a5..a9b243871c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -140,7 +140,7 @@ class AbominationDespawner public: explicit AbominationDespawner(Unit* owner) : _owner(owner) { } - bool operator()(uint64 guid) + bool operator()(ObjectGuid guid) { if (Unit* summon = ObjectAccessor::GetUnit(*_owner, guid)) { @@ -411,7 +411,7 @@ public: switch (id) { case POINT_FESTERGUT: - if (Creature* c = instance->instance->GetCreature(instance->GetData64(DATA_FESTERGUT))) + if (Creature* c = instance->instance->GetCreature(instance->GetGuidData(DATA_FESTERGUT))) { if (c->IsInCombat()) { @@ -427,7 +427,7 @@ public: } break; case POINT_ROTFACE: - if (Creature* c = instance->instance->GetCreature(instance->GetData64(DATA_ROTFACE))) + if (Creature* c = instance->instance->GetCreature(instance->GetGuidData(DATA_ROTFACE))) { if (c->IsInCombat()) { @@ -730,13 +730,12 @@ public: npc_putricide_oozeAI(Creature* creature, uint32 hitTargetSpellId) : ScriptedAI(creature), _hitTargetSpellId(hitTargetSpellId), _newTargetSelectTimer(0) { - targetGUID = 0; me->SetReactState(REACT_PASSIVE); } - uint64 targetGUID; + ObjectGuid targetGUID; - void SetGUID(uint64 guid, int32 type) override + void SetGUID(ObjectGuid guid, int32 type) override { if (type == -1) targetGUID = guid; @@ -745,7 +744,7 @@ public: void IsSummonedBy(Unit* /*summoner*/) override { if (InstanceScript* instance = me->GetInstanceScript()) - if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) { if (!professor->IsInCombat()) me->DespawnOrUnsummon(1); @@ -756,7 +755,7 @@ public: void SelectNewTarget() { - targetGUID = 0; + targetGUID.Clear(); me->InterruptNonMeleeSpells(true); me->AttackStop(); me->GetMotionMaster()->Clear(); @@ -1274,7 +1273,7 @@ public: if (!GetHitUnit()->HasAura(plagueId)) { - if (Creature* professor = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) { if (Aura* oldPlague = GetCaster()->GetAura(plagueId, professor->GetGUID())) { @@ -1414,7 +1413,7 @@ public: if (!instance) return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; - Creature* professor = ObjectAccessor::GetCreature(*GetExplTargetUnit(), instance->GetData64(DATA_PROFESSOR_PUTRICIDE)); + Creature* professor = ObjectAccessor::GetCreature(*GetExplTargetUnit(), instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE)); if (!professor) return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; @@ -1508,7 +1507,7 @@ public: if (!instance) return; - Creature* putricide = ObjectAccessor::GetCreature(*caster, instance->GetData64(DATA_PROFESSOR_PUTRICIDE)); + Creature* putricide = ObjectAccessor::GetCreature(*caster, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE)); if (!putricide) return; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index ad4883690c..e883556580 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -118,13 +118,17 @@ public: } uint32 infectionCooldown; - uint64 _oozeFloodDummyGUIDs[4][2]; + ObjectGuid _oozeFloodDummyGUIDs[4][2]; uint8 _oozeFloodStage; void Reset() override { infectionCooldown = 14000; - memset(&_oozeFloodDummyGUIDs, 0, sizeof(_oozeFloodDummyGUIDs)); + + for (uint8 i = 0; i < 4; ++i) + for (uint8 j = 0; j < 2; ++j) + _oozeFloodDummyGUIDs[i][j].Clear(); + _oozeFloodStage = 0; _Reset(); events.Reset(); @@ -152,7 +156,7 @@ public: Talk(SAY_AGGRO); DoZoneInCombat(); - if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) professor->AI()->DoAction(ACTION_ROTFACE_COMBAT); instance->SetData(DATA_OOZE_DANCE_ACHIEVEMENT, uint32(true)); // reset @@ -178,7 +182,7 @@ public: instance->DoRemoveAurasDueToSpellOnPlayers(MUTATED_INFECTION); _JustDied(); Talk(SAY_DEATH); - if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) professor->AI()->DoAction(ACTION_ROTFACE_DEATH); } @@ -207,7 +211,7 @@ public: me->SetControlled(false, UNIT_STATE_ROOT); me->DisableRotate(false); ScriptedAI::EnterEvadeMode(); - if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) professor->AI()->EnterEvadeMode(); } @@ -285,7 +289,7 @@ public: events.ScheduleEvent(EVENT_MUTATED_INFECTION, infectionCooldown); break; case EVENT_ROTFACE_OOZE_FLOOD: - if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) { professor->AI()->Talk(SAY_ROTFACE_OOZE_FLOOD); me->CastSpell((Unit*)nullptr, oozeFloodSpells[_oozeFloodStage], true); @@ -304,7 +308,7 @@ public: minDist = -5.0f; if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, minDist, true)) - if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) + if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) professor->CastSpell(target, SPELL_VILE_GAS_H, true); // triggered, to skip LoS check } events.ScheduleEvent(EVENT_ROTFACE_VILE_GAS, urand(15000, 20000)); @@ -333,7 +337,7 @@ public: npc_little_oozeAI(Creature* creature) : ScriptedAI(creature), instance(creature->GetInstanceScript()) { firstUpdate = true; - if (Creature* rotface = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ROTFACE))) + if (Creature* rotface = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ROTFACE))) rotface->AI()->JustSummoned(me); } @@ -352,7 +356,7 @@ public: void JustDied(Unit* /*killer*/) override { - if (Creature* rotface = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ROTFACE))) + if (Creature* rotface = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ROTFACE))) rotface->AI()->SummonedCreatureDespawn(me); me->DespawnOrUnsummon(0); } @@ -412,7 +416,7 @@ public: npc_big_oozeAI(Creature* creature) : ScriptedAI(creature), instance(creature->GetInstanceScript()) { firstUpdate = true; - if (Creature* rotface = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ROTFACE))) + if (Creature* rotface = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ROTFACE))) rotface->AI()->JustSummoned(me); } @@ -428,7 +432,7 @@ public: void JustDied(Unit* /*killer*/) override { - if (Creature* rotface = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ROTFACE))) + if (Creature* rotface = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ROTFACE))) rotface->AI()->SummonedCreatureDespawn(me); me->DespawnOrUnsummon(); } @@ -650,7 +654,7 @@ public: GetCaster()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_BUFF_COMBINE); GetCaster()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_COMBINE); if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* rotface = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(DATA_ROTFACE))) + if (Creature* rotface = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_ROTFACE))) if (rotface->IsAlive()) { if (GetCaster()->GetTypeId() == TYPEID_UNIT) @@ -713,7 +717,7 @@ public: GetCaster()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_BUFF_COMBINE); GetCaster()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_COMBINE); if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* rotface = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(DATA_ROTFACE))) + if (Creature* rotface = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_ROTFACE))) if (rotface->IsAlive()) { if (GetCaster()->GetTypeId() == TYPEID_UNIT) @@ -804,7 +808,7 @@ public: GetExplTargetDest()->GetPosition(x, y, z); // let Rotface handle the cast - caster dies before this executes if (InstanceScript* script = GetCaster()->GetInstanceScript()) - if (Creature* rotface = script->instance->GetCreature(script->GetData64(DATA_ROTFACE))) + if (Creature* rotface = script->instance->GetCreature(script->GetGuidData(DATA_ROTFACE))) rotface->CastSpell(x, y, z, triggered_spell_id, true/*, nullptr, nullptr, GetCaster()->GetGUID()*/); // caster not available on clientside, no log in such case } @@ -893,7 +897,7 @@ public: { summons.DespawnAll(); if (InstanceScript* _instance = me->GetInstanceScript()) - if (Creature* rotface = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_ROTFACE))) + if (Creature* rotface = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_ROTFACE))) if (rotface->IsAlive()) rotface->AI()->Talk(SAY_PRECIOUS_DIES); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 924fff4680..20934c45fc 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -174,7 +174,7 @@ private: class FrostBombExplosion : public BasicEvent { public: - FrostBombExplosion(Creature* owner, uint64 sindragosaGUID) : _owner(owner), _sindragosaGUID(sindragosaGUID) { } + FrostBombExplosion(Creature* owner, ObjectGuid sindragosaGUID) : _owner(owner), _sindragosaGUID(sindragosaGUID) { } bool Execute(uint64 /*eventTime*/, uint32 /*updateTime*/) override { @@ -185,13 +185,13 @@ public: private: Creature* _owner; - uint64 _sindragosaGUID; + ObjectGuid _sindragosaGUID; }; class IceTombSummonEvent : public BasicEvent { public: - IceTombSummonEvent(Unit* owner, uint64 sindragosaGUID) : _owner(owner), _sindragosaGUID(sindragosaGUID) { } + IceTombSummonEvent(Unit* owner, ObjectGuid sindragosaGUID) : _owner(owner), _sindragosaGUID(sindragosaGUID) { } bool Execute(uint64 /*eventTime*/, uint32 /*updateTime*/) override { @@ -222,7 +222,7 @@ public: private: Unit* _owner; - uint64 _sindragosaGUID; + ObjectGuid _sindragosaGUID; }; struct LastPhaseIceTombTargetSelector : public acore::unary_function<Unit*, bool> @@ -712,16 +712,15 @@ public: npc_ice_tombAI(Creature* creature) : NullCreatureAI(creature) { me->SetReactState(REACT_PASSIVE); - _trappedPlayerGUID = 0; _existenceCheckTimer = 1000; _asphyxiationTimer = 22500; } - uint64 _trappedPlayerGUID; + ObjectGuid _trappedPlayerGUID; uint32 _existenceCheckTimer; uint16 _asphyxiationTimer; - void SetGUID(uint64 guid, int32 type) override + void SetGUID(ObjectGuid guid, int32 type) override { if (type == DATA_TRAPPED_PLAYER) _trappedPlayerGUID = guid; @@ -739,7 +738,7 @@ public: if (Player* player = ObjectAccessor::GetPlayer(*me, _trappedPlayerGUID)) { - _trappedPlayerGUID = 0; + _trappedPlayerGUID.Clear(); player->RemoveAurasDueToSpell(SPELL_ICE_TOMB_DAMAGE); player->RemoveAurasDueToSpell(SPELL_ASPHYXIATION); player->RemoveAurasDueToSpell(SPELL_ICE_TOMB_UNTARGETABLE); @@ -1273,7 +1272,7 @@ public: // for standard creatures check full LOS if (Creature* c = unit->ToCreature()) - if (!c->IsPet() && c->GetDBTableGUIDLow()) + if (!c->IsPet() && c->GetSpawnId()) return !_caster->IsWithinLOSInMap(unit); // for players and pets check only dynamic los (ice block gameobjects) @@ -1375,7 +1374,7 @@ public: { if (!me->isDead()) { - _instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, me->GetDBTableGUIDLow()); // this cannot be in Reset because reset also happens on evade + _instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, me->GetSpawnId()); // this cannot be in Reset because reset also happens on evade Reset(); } } @@ -1408,7 +1407,7 @@ public: void JustRespawned() override { ScriptedAI::JustRespawned(); - _instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, me->GetDBTableGUIDLow()); // this cannot be in Reset because reset also happens on evade + _instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, me->GetSpawnId()); // this cannot be in Reset because reset also happens on evade } void JustDied(Unit* /*killer*/) override @@ -1509,7 +1508,7 @@ public: { if (!me->isDead()) { - _instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, me->GetDBTableGUIDLow()); // this cannot be in Reset because reset also happens on evade + _instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, me->GetSpawnId()); // this cannot be in Reset because reset also happens on evade Reset(); } } @@ -1542,7 +1541,7 @@ public: void JustRespawned() override { ScriptedAI::JustRespawned(); - _instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, me->GetDBTableGUIDLow()); // this cannot be in Reset because reset also happens on evade + _instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, me->GetSpawnId()); // this cannot be in Reset because reset also happens on evade } void JustDied(Unit* /*killer*/) override @@ -1729,14 +1728,14 @@ public: if (InstanceScript* instance = player->GetInstanceScript()) { if (!instance->GetData(DATA_SPINESTALKER)) - if (Creature* spinestalker = ObjectAccessor::GetCreature(*player, instance->GetData64(DATA_SPINESTALKER))) + if (Creature* spinestalker = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_SPINESTALKER))) spinestalker->AI()->DoAction(ACTION_START_FROSTWYRM); if (!instance->GetData(DATA_RIMEFANG)) - if (Creature* rimefang = ObjectAccessor::GetCreature(*player, instance->GetData64(DATA_RIMEFANG))) + if (Creature* rimefang = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_RIMEFANG))) rimefang->AI()->DoAction(ACTION_START_FROSTWYRM); - if (!instance->GetData(DATA_SINDRAGOSA_FROSTWYRMS) && !instance->GetData64(DATA_SINDRAGOSA) && instance->GetBossState(DATA_SINDRAGOSA) != DONE) + if (!instance->GetData(DATA_SINDRAGOSA_FROSTWYRMS) && !instance->GetGuidData(DATA_SINDRAGOSA) && instance->GetBossState(DATA_SINDRAGOSA) != DONE) { if (instance->GetData(DATA_HAS_LIMITED_ATTEMPTS) && !instance->GetData(DATA_HEROIC_ATTEMPTS)) return true; @@ -1771,7 +1770,7 @@ public: if (!me->isDead()) { if (me->GetEntry() == NPC_FROSTWING_WHELP) - _instance->SetData(_frostwyrmId, me->GetDBTableGUIDLow()); // this cannot be in Reset because reset also happens on evade + _instance->SetData(_frostwyrmId, me->GetSpawnId()); // this cannot be in Reset because reset also happens on evade Reset(); } } @@ -1814,7 +1813,7 @@ public: // Increase add count if (me->GetEntry() == NPC_FROSTWING_WHELP) - _instance->SetData(_frostwyrmId, me->GetDBTableGUIDLow()); // this cannot be in Reset because reset also happens on evade + _instance->SetData(_frostwyrmId, me->GetSpawnId()); // this cannot be in Reset because reset also happens on evade } void SetData(uint32 type, uint32 data) override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 009782bda3..a0e28e75ea 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -729,7 +729,7 @@ public: me->CastSpell((Unit*)nullptr, SPELL_SUMMON_BROKEN_FROSTMOURNE, true); me->CastSpell((Unit*)nullptr, SPELL_SUMMON_BROKEN_FROSTMOURNE_2, false); SetEquipmentSlots(false, EQUIP_BROKEN_FROSTMOURNE); - if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HIGHLORD_TIRION_FORDRING))) + if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_HIGHLORD_TIRION_FORDRING))) tirion->AI()->DoAction(ACTION_BREAK_FROSTMOURNE); break; case ACTION_TELEPORT_BACK: @@ -791,7 +791,7 @@ public: me->CastSpell((Unit*)nullptr, SPELL_FURY_OF_FROSTMOURNE, false); me->SetWalk(true); - if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HIGHLORD_TIRION_FORDRING))) + if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_HIGHLORD_TIRION_FORDRING))) tirion->AI()->DoAction(ACTION_OUTRO); return; } @@ -819,7 +819,7 @@ public: if (!_bFordringMustFallYell && me->GetHealth() < 500000) { _bFordringMustFallYell = true; - if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HIGHLORD_TIRION_FORDRING))) + if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_HIGHLORD_TIRION_FORDRING))) { tirion->MonsterYell("The Lich King must fall!", LANG_UNIVERSAL, 0); tirion->PlayDirectSound(17389); @@ -1249,7 +1249,7 @@ public: BossAI::EnterEvadeMode(); me->SetReactState(REACT_AGGRESSIVE); - if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HIGHLORD_TIRION_FORDRING))) + if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_HIGHLORD_TIRION_FORDRING))) tirion->AI()->EnterEvadeMode(); } }; @@ -1285,7 +1285,7 @@ public: switch (id) { case POINT_TIRION_INTRO: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { if (!theLichKing->IsAlive() || !theLichKing->IsVisible()) break; @@ -1351,7 +1351,7 @@ public: void sGossipSelect(Player* /*player*/, uint32 sender, uint32 action) override { - Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING)); + Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING)); if (me->GetCreatureTemplate()->GossipMenuId == sender && !action && me->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP) && theLichKing && !theLichKing->IsInEvadeMode()) { if (me->GetMap()->IsHeroic() && !_instance->GetData(DATA_LK_HC_AVAILABLE)) @@ -1379,7 +1379,7 @@ public: switch (_events.ExecuteEvent()) { case EVENT_INTRO_LK_MOVE: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { Movement::PointsArray path; path.push_back(G3D::Vector3(theLichKing->GetPositionX(), theLichKing->GetPositionY(), theLichKing->GetPositionZ())); @@ -1391,7 +1391,7 @@ public: } break; case EVENT_INTRO_LK_TALK_1: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->AI()->Talk(SAY_LK_INTRO_2); theLichKing->HandleEmoteCommand(EMOTE_ONESHOT_TALK_NO_SHEATHE); @@ -1402,15 +1402,15 @@ public: } break; case EVENT_INTRO_LK_EMOTE_CAST_SHOUT: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) theLichKing->CastSpell(theLichKing, SPELL_EMOTE_SHOUT_NO_SHEATH, false); break; case EVENT_INTRO_LK_EMOTE_1: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) theLichKing->HandleEmoteCommand(EMOTE_ONESHOT_POINT_NO_SHEATHE); break; case EVENT_INTRO_LK_CAST_FREEZE: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->AI()->Talk(SAY_LK_INTRO_3); theLichKing->CastSpell((Unit*)nullptr, SPELL_ICE_LOCK, false); @@ -1439,7 +1439,7 @@ public: me->GetMotionMaster()->MovePoint(0, TirionCharge); break; case EVENT_INTRO_FINISH: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->SetWalk(false); theLichKing->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); @@ -1451,7 +1451,7 @@ public: break; case EVENT_OUTRO_LK_TALK_1: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->AI()->Talk(SAY_LK_OUTRO_1); theLichKing->CastSpell((Unit*)nullptr, SPELL_FURY_OF_FROSTMOURNE_NO_REZ, true); @@ -1463,25 +1463,25 @@ public: } break; case EVENT_OUTRO_LK_TALK_2: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->AI()->Talk(SAY_LK_OUTRO_2); theLichKing->CastSpell((Unit*)nullptr, SPELL_EMOTE_QUESTION_NO_SHEATH, false); } break; case EVENT_OUTRO_LK_EMOTE_TALK: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) theLichKing->HandleEmoteCommand(EMOTE_ONESHOT_TALK_NO_SHEATHE); break; case EVENT_OUTRO_LK_TALK_3: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->SetFacingToObject(me); theLichKing->AI()->Talk(SAY_LK_OUTRO_3); } break; case EVENT_OUTRO_LK_MOVE_CENTER: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->GetMotionMaster()->MovePoint(0, CenterPosition); uint32 travelTime = 1000 * theLichKing->GetExactDist(&CenterPosition) / theLichKing->GetSpeed(MOVE_WALK) + 1000; @@ -1492,14 +1492,14 @@ public: } break; case EVENT_OUTRO_LK_TALK_4: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->SetFacingTo(0.01745329f); theLichKing->AI()->Talk(SAY_LK_OUTRO_4); } break; case EVENT_OUTRO_LK_RAISE_DEAD: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->CastSpell((Unit*)nullptr, SPELL_RAISE_DEAD, false); theLichKing->ClearUnitState(UNIT_STATE_CASTING); @@ -1507,7 +1507,7 @@ public: } break; case EVENT_OUTRO_LK_TALK_5: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->AI()->Talk(SAY_LK_OUTRO_5); _events.ScheduleEvent(EVENT_OUTRO_FORDRING_TALK_1, 7000); @@ -1517,7 +1517,7 @@ public: } break; case EVENT_OUTRO_LK_TALK_6: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->AI()->Talk(SAY_LK_OUTRO_6); me->SetFacingToObject(theLichKing); @@ -1540,7 +1540,7 @@ public: frostmourne->CastSpell((Unit*)nullptr, SPELL_BROKEN_FROSTMOURNE_KNOCK, false); break; case EVENT_OUTRO_SOUL_BARRAGE: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { theLichKing->CastSpell((Unit*)nullptr, SPELL_SOUL_BARRAGE, TRIGGERED_IGNORE_CAST_IN_PROGRESS); sCreatureTextMgr->SendSound(theLichKing, SOUND_PAIN, CHAT_MSG_MONSTER_YELL, 0, TEXT_RANGE_NORMAL, TEAM_NEUTRAL, false); @@ -1573,7 +1573,7 @@ public: { terenas->AI()->Talk(SAY_TERENAS_OUTRO_2); terenas->CastSpell((Unit*)nullptr, SPELL_MASS_RESURRECTION, false); - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { lichKing->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); @@ -1587,11 +1587,11 @@ public: } break; case EVENT_OUTRO_LK_TALK_7: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) theLichKing->AI()->Talk(SAY_LK_OUTRO_7); break; case EVENT_OUTRO_LK_TALK_8: - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) theLichKing->AI()->Talk(SAY_LK_OUTRO_8); break; case EVENT_OUTRO_FORDRING_TALK_1: @@ -1603,7 +1603,7 @@ public: case EVENT_OUTRO_FORDRING_REMOVE_ICE: me->RemoveAurasDueToSpell(SPELL_ICE_LOCK); SetEquipmentSlots(false, EQUIP_ASHBRINGER_GLOWING); - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { me->SetFacingToObject(lichKing); me->GetMap()->SetZoneMusic(AREA_THE_FROZEN_THRONE, MUSIC_FINAL); @@ -1628,7 +1628,7 @@ public: if (!me->IsAlive()) return; - if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* theLichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) if (theLichKing->IsInEvadeMode()) { ScriptedAI::EnterEvadeMode(); @@ -1671,7 +1671,7 @@ public: void FilterTargets(std::list<WorldObject*>& targets) { - if (GameObject* platform = ObjectAccessor::GetGameObject(*GetCaster(), GetCaster()->GetInstanceScript()->GetData64(DATA_ARTHAS_PLATFORM))) + if (GameObject* platform = ObjectAccessor::GetGameObject(*GetCaster(), GetCaster()->GetInstanceScript()->GetGuidData(DATA_ARTHAS_PLATFORM))) targets.remove_if(HeightDifferenceCheck(platform, 5.0f, false)); } @@ -2189,12 +2189,12 @@ public: { npc_icc_ice_sphereAI(Creature* creature) : ScriptedAI(creature) { - targetGUID = 0; + targetGUID.Clear(); timer = 250; me->SetReactState(REACT_PASSIVE); } - uint64 targetGUID; + ObjectGuid targetGUID; uint16 timer; void DoAction(int32 a) override @@ -2204,7 +2204,7 @@ public: me->RemoveAllAuras(); me->CastSpell(me, SPELL_ICE_BURST, true); me->DespawnOrUnsummon(1000); - targetGUID = 0; + targetGUID.Clear(); timer = 9999; me->InterruptNonMeleeSpells(true); me->AttackStop(); @@ -2217,7 +2217,7 @@ public: { if (!me->HasAura(SPELL_ICE_SPHERE)) me->CastSpell(me, SPELL_ICE_SPHERE, true); - targetGUID = 0; + targetGUID.Clear(); me->InterruptNonMeleeSpells(true); me->AttackStop(); me->GetMotionMaster()->Clear(); @@ -2325,13 +2325,13 @@ public: void IsSummonedBy(Unit* /*summoner*/) override { // player is the spellcaster so register summon manually - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) lichKing->AI()->JustSummoned(me); } void JustDied(Unit* /*killer*/) override { - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) lichKing->AI()->SummonedCreatureDespawn(me); if (TempSummon* summon = me->ToTempSummon()) { @@ -2498,7 +2498,7 @@ public: struct npc_valkyr_shadowguardAI : public NullCreatureAI { - npc_valkyr_shadowguardAI(Creature* creature) : NullCreatureAI(creature), _grabbedPlayer(0), didbelow50pct(false), dropped(false), _instance(creature->GetInstanceScript()) + npc_valkyr_shadowguardAI(Creature* creature) : NullCreatureAI(creature), didbelow50pct(false), dropped(false), _instance(creature->GetInstanceScript()) { me->SetReactState(REACT_PASSIVE); me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); @@ -2510,7 +2510,7 @@ public: EventMap _events; Position _destPoint; - uint64 _grabbedPlayer; + ObjectGuid _grabbedPlayer; bool didbelow50pct; bool dropped; InstanceScript* _instance; @@ -2565,7 +2565,7 @@ public: bool valid = false; if (Player* target = ObjectAccessor::GetPlayer(*me, _grabbedPlayer)) if (target->FindMap() == me->GetMap() && target->GetExactDist(me) < 15.0f && !target->GetVehicle()) - if (GameObject* platform = ObjectAccessor::GetGameObject(*me, _instance->GetData64(DATA_ARTHAS_PLATFORM))) + if (GameObject* platform = ObjectAccessor::GetGameObject(*me, _instance->GetGuidData(DATA_ARTHAS_PLATFORM))) { std::list<Creature*> triggers; GetCreatureListWithEntryInGrid(triggers, me, NPC_WORLD_TRIGGER, 150.0f); @@ -2589,7 +2589,7 @@ public: { _events.Reset(); _events.ScheduleEvent(EVENT_GRAB_PLAYER, 500); - _grabbedPlayer = 0; + _grabbedPlayer.Clear(); } } break; @@ -2631,7 +2631,7 @@ public: } } - void SetGUID(uint64 guid, int32 /* = 0*/) override + void SetGUID(ObjectGuid guid, int32 /* = 0*/) override { _grabbedPlayer = guid; } @@ -2681,7 +2681,7 @@ public: break; } if (!target) - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) target = lichKing->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankLKTargetSelector(lichKing, true, false, 100.0f)); if (target) me->CastSpell(target, SPELL_LIFE_SIPHON, false); @@ -2804,7 +2804,7 @@ public: targets.remove_if(acore::UnitAuraCheck(true, SPELL_BOSS_HITTIN_YA_AURA)); // done in dbc, but just to be sure xd targets.remove_if(acore::UnitAuraCheck(true, SPELL_HARVEST_SOUL_VALKYR)); if (InstanceScript* _instance = caster->GetInstanceScript()) - if (Creature* lichKing = ObjectAccessor::GetCreature(*caster, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*caster, _instance->GetGuidData(DATA_THE_LICH_KING))) if (Spell* s = lichKing->GetCurrentSpell(CURRENT_GENERIC_SPELL)) if (s->GetSpellInfo()->Id == SPELL_DEFILE && s->m_targets.GetUnitTarget()) targets.remove(s->m_targets.GetUnitTarget()); @@ -3077,7 +3077,7 @@ public: { // m_originalCaster to allow stacking from different casters, meh if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_DEATH) - GetTarget()->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, GetTarget()->GetInstanceScript()->GetData64(DATA_THE_LICH_KING)); + GetTarget()->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, GetTarget()->GetInstanceScript()->GetGuidData(DATA_THE_LICH_KING)); } void Register() override @@ -3109,7 +3109,7 @@ public: if (!summoner) return; - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) { me->SetWalk(false); Movement::PointsArray path; @@ -3117,8 +3117,8 @@ public: path.push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), 843.0f)); me->GetMotionMaster()->MoveSplinePath(&path); - uint64 petGUID = summoner->GetPetGUID(); - summoner->SetPetGUID(0); + ObjectGuid petGUID = summoner->GetPetGUID(); + summoner->SetPetGUID(ObjectGuid::Empty); summoner->StopMoving(); me->CastSpell(summoner, SPELL_HARVEST_SOUL_VEHICLE, true); //summoner->ClearUnitState(UNIT_STATE_ONVEHICLE); @@ -3155,24 +3155,24 @@ public: if (summoner->GetTypeId() == TYPEID_PLAYER && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap()) { if (buff) - summoner->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, _instance->GetData64(DATA_THE_LICH_KING)); + summoner->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, _instance->GetGuidData(DATA_THE_LICH_KING)); me->CastSpell(summoner, SPELL_HARVEST_SOUL_TELEPORT_BACK, false); } else if (buff) - me->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, _instance->GetData64(DATA_THE_LICH_KING)); + me->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, _instance->GetGuidData(DATA_THE_LICH_KING)); summoner->RemoveAurasDueToSpell(IsHeroic() ? SPELL_HARVEST_SOULS_TELEPORT : SPELL_HARVEST_SOUL_TELEPORT); } else - me->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, _instance->GetData64(DATA_THE_LICH_KING)); + me->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, _instance->GetGuidData(DATA_THE_LICH_KING)); } _events.Reset(); me->RemoveAllAuras(); me->DespawnOrUnsummon(500); - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) lichKing->AI()->SummonedCreatureDespawn(me); } @@ -3207,7 +3207,7 @@ public: } break; case EVENT_MOVE_TO_LICH_KING: - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) if (me->GetExactDist(lichKing) > 8.0f) { float dist = float(rand_norm()) * 5.0f + 8.0f; @@ -3219,7 +3219,7 @@ public: } break; case EVENT_DESPAWN_SELF: - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) lichKing->AI()->SummonedCreatureDespawn(me); me->DespawnOrUnsummon(1); break; @@ -3333,7 +3333,7 @@ public: _events.ScheduleEvent(EVENT_TELEPORT_BACK, 1000); break; case EVENT_TELEPORT_BACK: - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING))) lichKing->AI()->DoAction(ACTION_TELEPORT_BACK); break; default: @@ -3421,7 +3421,7 @@ public: for (std::list<WorldObject*>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr) if (Unit* target = (*itr)->ToUnit()) target->RemoveAurasDueToSpell(target->GetMap()->IsHeroic() ? SPELL_HARVEST_SOULS_TELEPORT : SPELL_HARVEST_SOUL_TELEPORT); - if (Creature* lichKing = ObjectAccessor::GetCreature(*GetCaster(), _instance->GetData64(DATA_THE_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*GetCaster(), _instance->GetGuidData(DATA_THE_LICH_KING))) lichKing->AI()->DoAction(ACTION_TELEPORT_BACK); if (Creature* spawner = GetCaster()->FindNearestCreature(NPC_WORLD_TRIGGER_INFINITE_AOI, 50.0f, true)) { @@ -3474,7 +3474,7 @@ public: void JustDied(Unit* /*killer*/) override { - if (Creature* terenas = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_TERENAS_MENETHIL))) + if (Creature* terenas = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_TERENAS_MENETHIL))) terenas->AI()->DoAction(ACTION_TELEPORT_BACK); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index fae1f34973..8089eb328c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -140,7 +140,7 @@ public: bool operator()(Creature* creature) { return creature->IsAlive() && creature->GetEntry() == NPC_RISEN_ARCHMAGE && - creature->GetDBTableGUIDLow() && !creature->IsInCombat(); + creature->GetSpawnId() && !creature->IsInCombat(); } }; @@ -159,7 +159,7 @@ struct ManaVoidSelector : public acore::unary_function<Unit*, bool> class DelayedCastEvent : public BasicEvent { public: - DelayedCastEvent(Creature* trigger, uint32 spellId, uint64 originalCaster, uint32 despawnTime) : _trigger(trigger), _originalCaster(originalCaster), _spellId(spellId), _despawnTime(despawnTime) + DelayedCastEvent(Creature* trigger, uint32 spellId, ObjectGuid originalCaster, uint32 despawnTime) : _trigger(trigger), _originalCaster(originalCaster), _spellId(spellId), _despawnTime(despawnTime) { } @@ -173,7 +173,7 @@ public: private: Creature* _trigger; - uint64 _originalCaster; + ObjectGuid _originalCaster; uint32 _spellId; uint32 _despawnTime; }; @@ -234,7 +234,7 @@ public: creature->DespawnOrUnsummon(); return; case NPC_RISEN_ARCHMAGE: - if (!creature->GetDBTableGUIDLow()) + if (!creature->GetSpawnId()) { creature->DespawnOrUnsummon(); return; @@ -279,7 +279,7 @@ public: { me->SetReactState(REACT_PASSIVE); _spawnHealth = 1; // just in case if not set below - if (CreatureData const* data = sObjectMgr->GetCreatureData(me->GetDBTableGUIDLow())) + if (CreatureData const* data = sObjectMgr->GetCreatureData(me->GetSpawnId())) if (data->curhealth) _spawnHealth = data->curhealth; } @@ -338,9 +338,9 @@ public: _events.ScheduleEvent(EVENT_DREAM_SLIP, 3500); _instance->SetBossState(DATA_VALITHRIA_DREAMWALKER, DONE); - if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_VALITHRIA_TRIGGER))) + if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER))) trigger->AI()->EnterEvadeMode(); - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_VALITHRIA_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) lichKing->AI()->Reset(); } else if (!_over75PercentTalkDone && me->HealthAbovePctHealed(75, heal)) @@ -349,7 +349,7 @@ public: Talk(SAY_VALITHRIA_75_PERCENT); } else if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) == NOT_STARTED) - if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_VALITHRIA_TRIGGER))) + if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER))) trigger->AI()->DoAction(ACTION_ENTER_COMBAT); } @@ -371,7 +371,7 @@ public: _justDied = true; Talk(SAY_VALITHRIA_DEATH); _instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); - if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_VALITHRIA_TRIGGER))) + if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER))) trigger->AI()->EnterEvadeMode(); } } @@ -388,7 +388,7 @@ public: me->SetDisplayId(11686); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->DespawnOrUnsummon(4000); - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_VALITHRIA_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) lichKing->CastSpell(lichKing, SPELL_SPAWN_CHEST, false); _instance->SetData(DATA_WEEKLY_QUEST_ID, 0); // show hidden npc if necessary } @@ -518,9 +518,9 @@ public: me->setActive(true); me->SetInCombatWithZone(); instance->SetBossState(DATA_VALITHRIA_DREAMWALKER, IN_PROGRESS); - if (Creature* valithria = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_VALITHRIA_DREAMWALKER))) + if (Creature* valithria = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER))) valithria->AI()->DoAction(ACTION_ENTER_COMBAT); - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_VALITHRIA_LICH_KING))) + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) lichKing->AI()->DoAction(ACTION_ENTER_COMBAT); std::list<Creature*> archmages; @@ -712,8 +712,8 @@ public: { me->FinishSpell(CURRENT_CHANNELED_SPELL, false); me->SetInCombatWithZone(); - if (me->GetDBTableGUIDLow()) - if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_VALITHRIA_TRIGGER))) + if (me->GetSpawnId()) + if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER))) trigger->AI()->DoAction(ACTION_ENTER_COMBAT); } @@ -726,7 +726,7 @@ public: void JustSummoned(Creature* summon) override { if (summon->GetEntry() == NPC_COLUMN_OF_FROST) - summon->m_Events.AddEvent(new DelayedCastEvent(summon, SPELL_COLUMN_OF_FROST_DAMAGE, 0, 8000), summon->m_Events.CalculateTime(2000)); + summon->m_Events.AddEvent(new DelayedCastEvent(summon, SPELL_COLUMN_OF_FROST_DAMAGE, ObjectGuid::Empty, 8000), summon->m_Events.CalculateTime(2000)); else if (summon->GetEntry() == NPC_MANA_VOID) summon->DespawnOrUnsummon(36000); } @@ -734,7 +734,7 @@ public: void UpdateAI(uint32 diff) override { if (!me->IsInCombat()) - if (me->GetDBTableGUIDLow()) + if (me->GetSpawnId()) if (!me->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) me->CastSpell(me, SPELL_CORRUPTION, false); @@ -861,7 +861,7 @@ public: me->GetMotionMaster()->Clear(false); me->GetMotionMaster()->MoveIdle(); // must use originalCaster the same for all clouds to allow stacking - me->CastSpell(me, EMERALD_VIGOR, false, nullptr, nullptr, _instance->GetData64(DATA_VALITHRIA_DREAMWALKER)); + me->CastSpell(me, EMERALD_VIGOR, false, nullptr, nullptr, _instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)); me->DespawnOrUnsummon(1000); break; default: @@ -959,7 +959,7 @@ public: void IsSummonedBy(Unit* /*summoner*/) override { - if (Creature* valithria = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_VALITHRIA_DREAMWALKER))) + if (Creature* valithria = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER))) AttackStart(valithria); } @@ -969,7 +969,7 @@ public: return; if (!me->GetVictim()) - if (Creature* valithria = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_VALITHRIA_DREAMWALKER))) + if (Creature* valithria = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER))) if (valithria->IsAlive()) AttackStart(valithria); @@ -1169,7 +1169,7 @@ public: return; if (InstanceScript* instance = GetHitUnit()->GetInstanceScript()) - GetHitUnit()->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, instance->GetData64(DATA_VALITHRIA_DREAMWALKER)); + GetHitUnit()->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)); } void Register() override @@ -1326,7 +1326,7 @@ public: if (!GetHitUnit()) return; - GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, GetCaster()->GetInstanceScript()->GetData64(DATA_VALITHRIA_LICH_KING)); + GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); } void Register() override @@ -1410,7 +1410,7 @@ public: if (!GetHitUnit()) return; - GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, GetCaster()->GetInstanceScript()->GetData64(DATA_VALITHRIA_LICH_KING)); + GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index 12b45d4e44..f0f9ab7ab5 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -367,9 +367,9 @@ public: void Reset() override { _events.Reset(); - _theLichKing = 0; - _bolvarFordragon = 0; - _factionNPC = 0; + _theLichKing.Clear(); + _bolvarFordragon.Clear(); + _factionNPC.Clear(); _damnedKills = 0; } @@ -517,7 +517,7 @@ public: case EVENT_SAURFANG_RUN: if (Creature* factionNPC = ObjectAccessor::GetCreature(*me, _factionNPC)) { - factionNPC->GetMotionMaster()->MovePath(factionNPC->GetDBTableGUIDLow() * 10, false); + factionNPC->GetMotionMaster()->MovePath(factionNPC->GetSpawnId() * 10, false); factionNPC->DespawnOrUnsummon(46500); std::list<Creature*> followers; factionNPC->GetCreaturesWithEntryInRange(followers, 30, _instance->GetData(DATA_TEAMID_IN_INSTANCE) == TEAM_HORDE ? NPC_KOR_KRON_GENERAL : NPC_ALLIANCE_COMMANDER); @@ -561,9 +561,9 @@ public: private: EventMap _events; InstanceScript* const _instance; - uint64 _theLichKing; - uint64 _bolvarFordragon; - uint64 _factionNPC; + ObjectGuid _theLichKing; + ObjectGuid _bolvarFordragon; + ObjectGuid _factionNPC; uint16 _damnedKills; }; @@ -733,10 +733,10 @@ public: me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_IMMUNE_TO_PC); // Load Grid with Sister Svalna me->GetMap()->LoadGrid(4356.71f, 2484.33f); - if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_SISTER_SVALNA))) + if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SISTER_SVALNA))) svalna->AI()->DoAction(ACTION_START_GAUNTLET); for (uint32 i = 0; i < 4; ++i) - if (Creature* crusader = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_CAPTAIN_ARNATH + i))) + if (Creature* crusader = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_CAPTAIN_ARNATH + i))) crusader->AI()->DoAction(ACTION_START_GAUNTLET); Talk(SAY_CROK_INTRO_1); @@ -757,7 +757,7 @@ public: } } - void SetGUID(uint64 guid, int32 type/* = 0*/) override + void SetGUID(ObjectGuid guid, int32 type/* = 0*/) override { if (type == ACTION_VRYKUL_DEATH) { @@ -769,7 +769,7 @@ public: { _handledWP4 = true; Talk(SAY_CROK_FINAL_WP); - if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_SISTER_SVALNA))) + if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SISTER_SVALNA))) svalna->AI()->DoAction(ACTION_RESURRECT_CAPTAINS); } } @@ -800,7 +800,7 @@ public: { _handledWP4 = true; Talk(SAY_CROK_FINAL_WP); - if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_SISTER_SVALNA))) + if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SISTER_SVALNA))) svalna->AI()->DoAction(ACTION_RESURRECT_CAPTAINS); } break; @@ -820,12 +820,12 @@ public: break; case 1: minY = 2550.0f; - if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_SISTER_SVALNA))) + if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SISTER_SVALNA))) svalna->AI()->DoAction(ACTION_KILL_CAPTAIN); break; case 2: minY = 2515.0f; - if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_SISTER_SVALNA))) + if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SISTER_SVALNA))) svalna->AI()->DoAction(ACTION_KILL_CAPTAIN); break; case 4: @@ -910,7 +910,7 @@ public: switch (_events.ExecuteEvent()) { case EVENT_ARNATH_INTRO_2: - if (Creature* arnath = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_CAPTAIN_ARNATH))) + if (Creature* arnath = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_CAPTAIN_ARNATH))) arnath->AI()->Talk(SAY_ARNATH_INTRO_2); break; case EVENT_CROK_INTRO_3: @@ -956,7 +956,7 @@ public: private: EventMap _events; - std::set<uint64> _aliveTrash; + GuidSet _aliveTrash; InstanceScript* _instance; uint32 _currentWPid; uint32 _wipeCheckTimer; @@ -1004,12 +1004,12 @@ public: _JustDied(); Talk(SAY_SVALNA_DEATH); - if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_CROK_SCOURGEBANE))) // _isEventDone = true, setActive(false) + if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CROK_SCOURGEBANE))) // _isEventDone = true, setActive(false) crok->AI()->DoAction(ACTION_RESET_EVENT); uint64 delay = 6000; for (uint32 i = 0; i < 4; ++i) - if (Creature* crusader = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_CAPTAIN_ARNATH + i))) + if (Creature* crusader = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CAPTAIN_ARNATH + i))) if (crusader->IsAlive()) { if (crusader->GetEntry() == crusader->GetCreatureData()->id) @@ -1033,7 +1033,7 @@ public: } _EnterCombat(); me->LowerPlayerDamageReq(me->GetMaxHealth()); - if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_CROK_SCOURGEBANE))) + if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CROK_SCOURGEBANE))) { crok->AI()->Talk(SAY_CROK_COMBAT_SVALNA); crok->AI()->AttackStart(me); @@ -1217,7 +1217,7 @@ public: { if (action == ACTION_START_GAUNTLET) { - if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_CROK_SCOURGEBANE))) + if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CROK_SCOURGEBANE))) { FollowAngle = me->GetAngle(crok) + me->GetOrientation(); FollowDist = me->GetDistance2d(crok); @@ -1244,7 +1244,7 @@ public: return; me->GetMotionMaster()->Clear(false); - if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_CROK_SCOURGEBANE))) + if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CROK_SCOURGEBANE))) me->GetMotionMaster()->MoveFollow(crok, FollowDist, FollowAngle, MOTION_SLOT_IDLE); else me->GetMotionMaster()->MoveTargetedHome(); @@ -2327,7 +2327,7 @@ public: { if (InstanceScript* instance = player->GetInstanceScript()) if (instance->GetBossState(DATA_SISTER_SVALNA) != DONE) - if (Creature* crok = ObjectAccessor::GetCreature(*player, instance->GetData64(DATA_CROK_SCOURGEBANE))) + if (Creature* crok = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_CROK_SCOURGEBANE))) { if (!crok->IsAlive()) { @@ -3712,7 +3712,7 @@ public: { if (InstanceScript* instance = player->GetInstanceScript()) if (instance->GetBossState(DATA_SINDRAGOSA_GAUNTLET) == NOT_STARTED && !player->IsGameMaster()) - if (Creature* gauntlet = ObjectAccessor::GetCreature(*player, instance->GetData64(NPC_SINDRAGOSA_GAUNTLET))) + if (Creature* gauntlet = ObjectAccessor::GetCreature(*player, instance->GetGuidData(NPC_SINDRAGOSA_GAUNTLET))) gauntlet->AI()->DoAction(ACTION_START_GAUNTLET); return true; } @@ -3727,7 +3727,7 @@ public: { if (InstanceScript* instance = player->GetInstanceScript()) if (instance->GetData(DATA_PUTRICIDE_TRAP_STATE) == NOT_STARTED && !player->IsGameMaster()) - if (Creature* trap = ObjectAccessor::GetCreature(*player, instance->GetData64(NPC_PUTRICADES_TRAP))) + if (Creature* trap = ObjectAccessor::GetCreature(*player, instance->GetGuidData(NPC_PUTRICADES_TRAP))) trap->AI()->DoAction(ACTION_START_GAUNTLET); return true; } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp index 70286973a1..6323ac1d61 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp @@ -160,63 +160,15 @@ public: // pussywizard: IsBuffAvailable = true; WeeklyQuestId10 = 0; - PutricideEnteranceDoorGUID = 0; - GasReleaseValveGUID = 0; - OozeReleaseValveGUID = 0; PutricideEventProgress = 0; LichKingHeroicAvailable = true; LichKingRandomWhisperTimer = 120 * IN_MILLISECONDS; DarkwhisperElevatorTimer = 3000; - memset(&WeeklyQuestNpcGUID, 0, sizeof(WeeklyQuestNpcGUID)); - ScourgeTransporterFirstGUID = 0; SetBossNumber(MAX_ENCOUNTERS); LoadDoorData(doorData); TeamIdInInstance = TEAM_NEUTRAL; HeroicAttempts = MaxHeroicAttempts; - LadyDeathwhisperGUID = 0; - LadyDeathwisperElevatorGUID = 0; - GunshipGUID = 0; - EnemyGunshipGUID = 0; - GunshipArmoryGUID = 0; - DeathbringerSaurfangGUID = 0; - DeathbringerSaurfangDoorGUID = 0; - DeathbringerSaurfangEventGUID = 0; - DeathbringersCacheGUID = 0; - SaurfangTeleportGUID = 0; - PlagueSigilGUID = 0; - BloodwingSigilGUID = 0; - FrostwingSigilGUID = 0; - memset(PutricidePipeGUIDs, 0, 2 * sizeof(uint64)); - memset(PutricideGateGUIDs, 0, 2 * sizeof(uint64)); - PutricideCollisionGUID = 0; - FestergutGUID = 0; - RotfaceGUID = 0; - ProfessorPutricideGUID = 0; - PutricideTableGUID = 0; - memset(BloodCouncilGUIDs, 0, 3 * sizeof(uint64)); - BloodCouncilControllerGUID = 0; - BloodQueenLanaThelGUID = 0; - CrokScourgebaneGUID = 0; - memset(CrokCaptainGUIDs, 0, 4 * sizeof(uint64)); - SisterSvalnaGUID = 0; - ValithriaDreamwalkerGUID = 0; - ValithriaLichKingGUID = 0; - ValithriaTriggerGUID = 0; - PutricadeTrapGUID = 0; - SindragosaGauntletGUID = 0; - SindragosaGUID = 0; - SpinestalkerGUID = 0; - RimefangGUID = 0; - TheLichKingTeleportGUID = 0; - TheLichKingGUID = 0; - HighlordTirionFordringGUID = 0; - TerenasMenethilGUID = 0; - ArthasPlatformGUID = 0; - ArthasPrecipiceGUID = 0; - FrozenThroneEdgeGUID = 0; - FrozenThroneWindGUID = 0; - FrozenThroneWarningGUID = 0; IsBonedEligible = true; IsOozeDanceEligible = true; IsNauseaEligible = true; @@ -279,7 +231,7 @@ public: } // apply ICC buff to pets/summons - if (GetData(DATA_BUFF_AVAILABLE) && IS_PLAYER_GUID(creature->GetOwnerGUID()) && creature->HasUnitTypeMask(UNIT_MASK_MINION | UNIT_MASK_GUARDIAN | UNIT_MASK_CONTROLABLE_GUARDIAN) && creature->CanHaveThreatList()) + if (GetData(DATA_BUFF_AVAILABLE) && creature->GetOwnerGUID().IsPlayer() && creature->HasUnitTypeMask(UNIT_MASK_MINION | UNIT_MASK_GUARDIAN | UNIT_MASK_CONTROLABLE_GUARDIAN) && creature->CanHaveThreatList()) if (Unit* owner = creature->GetOwner()) if (Player* plr = owner->ToPlayer()) { @@ -512,10 +464,10 @@ public: void OnCreatureRemove(Creature* creature) override { if (creature->GetEntry() == NPC_SINDRAGOSA) - SindragosaGUID = 0; + SindragosaGUID.Clear(); } - uint32 GetCreatureEntry(uint32 /*guidLow*/, CreatureData const* data) override + uint32 GetCreatureEntry(ObjectGuid::LowType /*guidLow*/, CreatureData const* data) override { if (TeamIdInInstance == TEAM_NEUTRAL) { @@ -560,7 +512,7 @@ public: return entry; } - uint32 GetGameObjectEntry(uint32 /*guidLow*/, uint32 entry) override + uint32 GetGameObjectEntry(ObjectGuid::LowType /*guidLow*/, uint32 entry) override { if (TeamIdInInstance == TEAM_NEUTRAL) { @@ -620,14 +572,14 @@ public: if (creature->AI()->GetData(1/*DATA_FROSTWYRM_OWNER*/) == DATA_SPINESTALKER) { - SpinestalkerTrash.erase(creature->GetDBTableGUIDLow()); + SpinestalkerTrash.erase(creature->GetSpawnId()); if (SpinestalkerTrash.empty()) if (Creature* spinestalk = instance->GetCreature(SpinestalkerGUID)) spinestalk->AI()->DoAction(ACTION_START_FROSTWYRM); } else { - RimefangTrash.erase(creature->GetDBTableGUIDLow()); + RimefangTrash.erase(creature->GetSpawnId()); if (RimefangTrash.empty()) if (Creature* spinestalk = instance->GetCreature(RimefangGUID)) spinestalk->AI()->DoAction(ACTION_START_FROSTWYRM); @@ -642,7 +594,7 @@ public: if (GetBossState(DATA_SINDRAGOSA) == DONE) return; - FrostwyrmGUIDs.erase(creature->GetDBTableGUIDLow()); + FrostwyrmGUIDs.erase(creature->GetSpawnId()); if (FrostwyrmGUIDs.empty()) { instance->LoadGrid(SindragosaSpawnPos.GetPositionX(), SindragosaSpawnPos.GetPositionY()); @@ -893,7 +845,7 @@ public: break; case GO_THE_SKYBREAKER_A: case GO_ORGRIMS_HAMMER_H: - GunshipGUID = 0; + GunshipGUID.Clear(); break; default: break; @@ -941,7 +893,7 @@ public: return 0; } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -1014,7 +966,7 @@ public: break; } - return 0; + return ObjectGuid::Empty; } void HandleDropAttempt(bool drop = true) @@ -1681,7 +1633,7 @@ public: uint8 id = urand(0, 15); std::string const& text = sCreatureTextMgr->GetLocalizedChatString(NPC_THE_LICH_KING_LH, 0, 20 + id, 0, LOCALE_enUS); WorldPacket data; - ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, 0, player->GetGUID(), text, CHAT_TAG_NONE, "The Lich King"); + ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, ObjectGuid::Empty, player->GetGUID(), text, CHAT_TAG_NONE, "The Lich King"); player->SendPlaySound(17235 + id, true); player->SendDirectMessage(&data); } @@ -1900,68 +1852,68 @@ public: // pussywizard: bool IsBuffAvailable; uint32 WeeklyQuestId10; // contains id from 10man for any difficulty (for simplicity) - uint64 WeeklyQuestNpcGUID[WeeklyNPCs]; - uint64 PutricideEnteranceDoorGUID; + ObjectGuid WeeklyQuestNpcGUID[WeeklyNPCs]; + ObjectGuid PutricideEnteranceDoorGUID; uint32 PutricideEventProgress; - uint64 GasReleaseValveGUID; - uint64 OozeReleaseValveGUID; + ObjectGuid GasReleaseValveGUID; + ObjectGuid OozeReleaseValveGUID; bool LichKingHeroicAvailable; uint32 LichKingRandomWhisperTimer; uint32 DarkwhisperElevatorTimer; - uint64 ScourgeTransporterFirstGUID; + ObjectGuid ScourgeTransporterFirstGUID; EventMap Events; - uint64 LadyDeathwhisperGUID; - uint64 LadyDeathwisperElevatorGUID; - uint64 GunshipGUID; - uint64 EnemyGunshipGUID; - uint64 GunshipArmoryGUID; - uint64 DeathbringerSaurfangGUID; - uint64 DeathbringerSaurfangDoorGUID; - uint64 DeathbringerSaurfangEventGUID; // Muradin Bronzebeard or High Overlord Saurfang - uint64 DeathbringersCacheGUID; - uint64 SaurfangTeleportGUID; - uint64 PlagueSigilGUID; - uint64 BloodwingSigilGUID; - uint64 FrostwingSigilGUID; - uint64 PutricidePipeGUIDs[2]; - uint64 PutricideGateGUIDs[2]; - uint64 PutricideCollisionGUID; - uint64 FestergutGUID; - uint64 RotfaceGUID; - uint64 ProfessorPutricideGUID; - uint64 PutricideTableGUID; - uint64 BloodCouncilGUIDs[3]; - uint64 BloodCouncilControllerGUID; - uint64 BloodQueenLanaThelGUID; - uint64 CrokScourgebaneGUID; - uint64 CrokCaptainGUIDs[4]; - uint64 SisterSvalnaGUID; - uint64 ValithriaDreamwalkerGUID; - uint64 ValithriaLichKingGUID; - uint64 ValithriaTriggerGUID; - uint64 PutricadeTrapGUID; - uint64 SindragosaGauntletGUID; - uint64 SindragosaGUID; - uint64 SpinestalkerGUID; - uint64 RimefangGUID; - uint64 TheLichKingTeleportGUID; - uint64 TheLichKingGUID; - uint64 HighlordTirionFordringGUID; - uint64 TerenasMenethilGUID; - uint64 ArthasPlatformGUID; - uint64 ArthasPrecipiceGUID; - uint64 FrozenThroneEdgeGUID; - uint64 FrozenThroneWindGUID; - uint64 FrozenThroneWarningGUID; - uint64 FrozenBolvarGUID; - uint64 PillarsChainedGUID; - uint64 PillarsUnchainedGUID; + ObjectGuid LadyDeathwhisperGUID; + ObjectGuid LadyDeathwisperElevatorGUID; + ObjectGuid GunshipGUID; + ObjectGuid EnemyGunshipGUID; + ObjectGuid GunshipArmoryGUID; + ObjectGuid DeathbringerSaurfangGUID; + ObjectGuid DeathbringerSaurfangDoorGUID; + ObjectGuid DeathbringerSaurfangEventGUID; // Muradin Bronzebeard or High Overlord Saurfang + ObjectGuid DeathbringersCacheGUID; + ObjectGuid SaurfangTeleportGUID; + ObjectGuid PlagueSigilGUID; + ObjectGuid BloodwingSigilGUID; + ObjectGuid FrostwingSigilGUID; + ObjectGuid PutricidePipeGUIDs[2]; + ObjectGuid PutricideGateGUIDs[2]; + ObjectGuid PutricideCollisionGUID; + ObjectGuid FestergutGUID; + ObjectGuid RotfaceGUID; + ObjectGuid ProfessorPutricideGUID; + ObjectGuid PutricideTableGUID; + ObjectGuid BloodCouncilGUIDs[3]; + ObjectGuid BloodCouncilControllerGUID; + ObjectGuid BloodQueenLanaThelGUID; + ObjectGuid CrokScourgebaneGUID; + ObjectGuid CrokCaptainGUIDs[4]; + ObjectGuid SisterSvalnaGUID; + ObjectGuid ValithriaDreamwalkerGUID; + ObjectGuid ValithriaLichKingGUID; + ObjectGuid ValithriaTriggerGUID; + ObjectGuid PutricadeTrapGUID; + ObjectGuid SindragosaGauntletGUID; + ObjectGuid SindragosaGUID; + ObjectGuid SpinestalkerGUID; + ObjectGuid RimefangGUID; + ObjectGuid TheLichKingTeleportGUID; + ObjectGuid TheLichKingGUID; + ObjectGuid HighlordTirionFordringGUID; + ObjectGuid TerenasMenethilGUID; + ObjectGuid ArthasPlatformGUID; + ObjectGuid ArthasPrecipiceGUID; + ObjectGuid FrozenThroneEdgeGUID; + ObjectGuid FrozenThroneWindGUID; + ObjectGuid FrozenThroneWarningGUID; + ObjectGuid FrozenBolvarGUID; + ObjectGuid PillarsChainedGUID; + ObjectGuid PillarsUnchainedGUID; TeamId TeamIdInInstance; uint32 ColdflameJetsState; - std::set<uint32> FrostwyrmGUIDs; - std::set<uint32> SpinestalkerTrash; - std::set<uint32> RimefangTrash; + std::set<ObjectGuid::LowType> FrostwyrmGUIDs; + std::set<ObjectGuid::LowType> SpinestalkerTrash; + std::set<ObjectGuid::LowType> RimefangTrash; uint32 BloodQuickeningState; uint32 HeroicAttempts; uint16 BloodQuickeningMinutes; diff --git a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp index e49874263c..f130f820e3 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp @@ -87,7 +87,7 @@ public: SummonCryptGuards(); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_ANUB_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_ANUB_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -151,7 +151,7 @@ public: Talk(SAY_AGGRO); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_ANUB_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_ANUB_GATE))) { go->SetGoState(GO_STATE_READY); } @@ -183,7 +183,7 @@ public: { if (!me->IsInCombat() && sayGreet) { - for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr) + for (SummonList::iterator itr = summons.begin(); itr != summons.end(); ++itr) { if (pInstance) { diff --git a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp index d5a50adc1c..949fa64a02 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp @@ -92,7 +92,7 @@ public: SummonHelpers(); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_FAERLINA_WEB))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_FAERLINA_WEB))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -111,7 +111,7 @@ public: events.SetPhase(1); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_FAERLINA_WEB))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_FAERLINA_WEB))) { go->SetGoState(GO_STATE_READY); } @@ -149,7 +149,7 @@ public: Talk(SAY_DEATH); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_FAERLINA_WEB))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_FAERLINA_WEB))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -160,7 +160,7 @@ public: { if (!me->IsInCombat() && sayGreet) { - for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr) + for (SummonList::iterator itr = summons.begin(); itr != summons.end(); ++itr) { if (pInstance) { diff --git a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp index 013757946f..c1d0bc67df 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp @@ -193,7 +193,7 @@ public: } if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_HORSEMEN_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_HORSEMEN_GATE))) { if (pInstance->GetBossState(BOSS_GOTHIK) == DONE) { @@ -270,7 +270,7 @@ public: player->SummonGameObject(RAID_MODE(GO_HORSEMEN_CHEST_10, GO_HORSEMEN_CHEST_25), 2514.8f, -2944.9f, 245.55f, 5.51f, 0, 0, 0, 0, 0); } } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_HORSEMEN_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_HORSEMEN_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -292,7 +292,7 @@ public: } if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_HORSEMEN_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_HORSEMEN_GATE))) { go->SetGoState(GO_STATE_READY); } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp index 86646b8882..58f50340f9 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp @@ -217,15 +217,15 @@ public: me->NearTeleportTo(2642.139f, -3386.959f, 285.492f, 6.265f); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_ENTER_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_GOTHIK_ENTER_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_INNER_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_GOTHIK_INNER_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_EXIT_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_GOTHIK_EXIT_GATE))) { go->SetGoState(GO_STATE_READY); } @@ -245,11 +245,11 @@ public: events.ScheduleEvent(EVENT_CHECK_PLAYERS, 120000); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_ENTER_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_GOTHIK_ENTER_GATE))) { go->SetGoState(GO_STATE_READY); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_INNER_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_GOTHIK_INNER_GATE))) { go->SetGoState(GO_STATE_READY); } @@ -294,15 +294,15 @@ public: summons.DespawnAll(); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_ENTER_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_GOTHIK_ENTER_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_INNER_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_GOTHIK_INNER_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_EXIT_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_GOTHIK_EXIT_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -447,7 +447,7 @@ public: case EVENT_CHECK_HEALTH: if (me->HealthBelowPct(30) && pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_INNER_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_GOTHIK_INNER_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -482,7 +482,7 @@ public: case EVENT_CHECK_PLAYERS: if (!CheckGroupSplitted()) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_INNER_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_GOTHIK_INNER_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp b/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp index 7e1cca3e9e..c2d6fe5251 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp @@ -79,10 +79,7 @@ public: me->GetCreaturesWithEntryInRange(StichedGiants, 300.0f, NPC_STICHED_GIANT); for (std::list<Creature*>::const_iterator itr = StichedGiants.begin(); itr != StichedGiants.end(); ++itr) { - if ((*itr)->GetGUID()) - { - (*itr)->ToCreature()->AI()->AttackStart(me->GetVictim()); - } + (*itr)->ToCreature()->AI()->AttackStart(me->GetVictim()); } } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp index a51f8a1994..55e86be35e 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp @@ -75,7 +75,7 @@ public: moveRight = true; if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_HEIGAN_ENTER_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_HEIGAN_ENTER_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -107,7 +107,7 @@ public: Talk(SAY_AGGRO); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_HEIGAN_ENTER_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_HEIGAN_ENTER_GATE))) { go->SetGoState(GO_STATE_READY); } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index ccee4ae02a..d2a6d91654 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -210,12 +210,12 @@ public: summons.DespawnAll(); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE); me->SetReactState(REACT_AGGRESSIVE); - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_FLOOR))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_FLOOR))) { go->SetPhaseMask(1, true); go->SetGoState(GO_STATE_READY); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_GATE))) { if(!_justSpawned) // Don't open the door if we just spawned and are still doing the conversation { @@ -223,19 +223,19 @@ public: } } _justSpawned = false; - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_PORTAL_1))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_1))) { go->SetGoState(GO_STATE_READY); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_PORTAL_2))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_2))) { go->SetGoState(GO_STATE_READY); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_PORTAL_3))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_3))) { go->SetGoState(GO_STATE_READY); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_PORTAL_4))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_4))) { go->SetGoState(GO_STATE_READY); } @@ -270,7 +270,7 @@ public: Talk(SAY_DEATH); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -289,7 +289,7 @@ public: Talk(SAY_SUMMON_MINIONS); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE); me->RemoveAllAttackers(); - me->SetTarget(0); + me->SetTarget(); me->SetReactState(REACT_PASSIVE); me->CastSpell(me, SPELL_KELTHUZAD_CHANNEL, false); events.ScheduleEvent(EVENT_SPAWN_POOL, 5000); @@ -300,13 +300,13 @@ public: events.ScheduleEvent(EVENT_ENRAGE, 900000); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_FLOOR))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_FLOOR))) { events.ScheduleEvent(EVENT_FLOOR_CHANGE, 15000); go->SetGoState(GO_STATE_ACTIVE); } } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_GATE))) { go->SetGoState(GO_STATE_READY); } @@ -342,7 +342,7 @@ public: case EVENT_FLOOR_CHANGE: if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_FLOOR))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_FLOOR))) { events.ScheduleEvent(EVENT_FLOOR_CHANGE, 15000); go->SetGoState(GO_STATE_READY); @@ -451,19 +451,19 @@ public: Talk(SAY_REQUEST_AID); events.DelayEvents(5500); events.ScheduleEvent(EVENT_P3_LICH_KING_SAY, 5000); - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_PORTAL_1))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_1))) { go->SetGoState(GO_STATE_ACTIVE); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_PORTAL_2))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_2))) { go->SetGoState(GO_STATE_ACTIVE); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_PORTAL_3))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_3))) { go->SetGoState(GO_STATE_ACTIVE); } - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_PORTAL_4))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_4))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -474,7 +474,7 @@ public: case EVENT_P3_LICH_KING_SAY: if (pInstance) { - if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_LICH_KING_BOSS))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_LICH_KING_BOSS))) { cr->AI()->Talk(SAY_ANSWER_REQUEST); } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp index 36136071da..71d5089ce4 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp @@ -67,7 +67,7 @@ public: if (pInstance) { pInstance->SetData(BOSS_LOATHEB, NOT_STARTED); - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_LOATHEB_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_LOATHEB_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -108,7 +108,7 @@ public: if (pInstance) { pInstance->SetData(BOSS_LOATHEB, IN_PROGRESS); - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_LOATHEB_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_LOATHEB_GATE))) { go->SetGoState(GO_STATE_READY); } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp b/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp index efd11e6d68..e9bea2291e 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp @@ -88,7 +88,7 @@ public: summons.DespawnAll(); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_MAEXXNA_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_MAEXXNA_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -107,7 +107,7 @@ public: events.ScheduleEvent(EVENT_SUMMON_SPIDERLINGS, 30000); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_MAEXXNA_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_MAEXXNA_GATE))) { go->SetGoState(GO_STATE_READY); } @@ -219,12 +219,14 @@ public: struct boss_maexxna_webwrapAI : public NullCreatureAI { - explicit boss_maexxna_webwrapAI(Creature* c) : NullCreatureAI(c), victimGUID(0) {} + explicit boss_maexxna_webwrapAI(Creature* c) : NullCreatureAI(c) {} - uint64 victimGUID; - void SetGUID(uint64 guid, int32 /*param*/) override + ObjectGuid victimGUID; + + void SetGUID(ObjectGuid guid, int32 /*param*/) override { victimGUID = guid; + if (me->m_spells[0] && victimGUID) { if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID)) diff --git a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp index 730777cbb3..1d74478d8b 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp @@ -140,7 +140,7 @@ public: timesInBalcony = 0; if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_NOTH_ENTRY_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_NOTH_ENTRY_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -160,7 +160,7 @@ public: StartGroundPhase(); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_NOTH_ENTRY_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_NOTH_ENTRY_GATE))) { go->SetGoState(GO_STATE_READY); } @@ -184,7 +184,7 @@ public: Talk(SAY_DEATH); if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_NOTH_ENTRY_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_NOTH_ENTRY_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp index 41ff893387..4b1d378691 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp @@ -86,8 +86,8 @@ public: InstanceScript* pInstance; uint8 iceboltCount{}; uint32 spawnTimer{}; - std::list<uint64> blockList; - uint64 currentTarget{}; + GuidList blockList; + ObjectGuid currentTarget; void InitializeAI() override { @@ -118,7 +118,7 @@ public: events.Reset(); iceboltCount = 0; spawnTimer = 0; - currentTarget = 0; + currentTarget.Clear(); blockList.clear(); } @@ -191,12 +191,12 @@ public: bool IsValidExplosionTarget(WorldObject* target) { - for (std::list<uint64>::const_iterator itr = blockList.begin(); itr != blockList.end(); ++itr) + for (ObjectGuid const guid : blockList) { - if (target->GetGUID() == (*itr)) + if (target->GetGUID() == guid) return false; - if (Unit* block = ObjectAccessor::GetUnit(*me, *itr)) + if (Unit* block = ObjectAccessor::GetUnit(*me, guid)) { if (block->IsInBetween(me, target, 2.0f) && block->IsWithinDist(target, 10.0f)) return false; @@ -293,7 +293,7 @@ public: me->SendMeleeAttackStop(me->GetVictim()); me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); me->SetDisableGravity(true); - currentTarget = 0; + currentTarget.Clear(); events.ScheduleEvent(EVENT_FLIGHT_ICEBOLT, 3000); iceboltCount = RAID_MODE(2, 3); return; @@ -316,7 +316,7 @@ public: bool inList = false; if (!blockList.empty()) { - for (std::list<uint64>::const_iterator itr = blockList.begin(); itr != blockList.end(); ++itr) + for (GuidList::const_iterator itr = blockList.begin(); itr != blockList.end(); ++itr) { if ((*i)->getTarget()->GetGUID() == *itr) { @@ -349,7 +349,7 @@ public: return; } case EVENT_FLIGHT_BREATH: - currentTarget = 0; + currentTarget.Clear(); Talk(EMOTE_BREATH); me->CastSpell(me, SPELL_FROST_MISSILE, false); events.ScheduleEvent(EVENT_FLIGHT_SPELL_EXPLOSION, 8500); @@ -361,7 +361,7 @@ public: case EVENT_FLIGHT_START_LAND: if (!blockList.empty()) { - for (std::list<uint64>::const_iterator itr = blockList.begin(); itr != blockList.end(); ++itr) + for (GuidList::const_iterator itr = blockList.begin(); itr != blockList.end(); ++itr) { if (Unit* block = ObjectAccessor::GetUnit(*me, *itr)) { diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp index bc515d93aa..2c4e315987 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp @@ -178,7 +178,7 @@ public: } if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_THADDIUS_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_THADDIUS_GATE))) { if (pInstance->GetBossState(BOSS_GLUTH) == DONE) { @@ -208,7 +208,7 @@ public: { pInstance->DoRemoveAurasDueToSpellOnPlayers(28059); pInstance->DoRemoveAurasDueToSpellOnPlayers(28084); - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_THADDIUS_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_THADDIUS_GATE))) { go->SetGoState(GO_STATE_ACTIVE); } @@ -365,7 +365,6 @@ public: { pInstance = me->GetInstanceScript(); overload = false; - myCoil = 0; } InstanceScript* pInstance; @@ -373,7 +372,7 @@ public: uint32 pullTimer{}; uint32 visualTimer{}; bool overload; - uint64 myCoil; + ObjectGuid myCoil; void Reset() override { @@ -421,11 +420,11 @@ public: } if (pInstance) { - if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_THADDIUS_GATE))) + if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_THADDIUS_GATE))) { go->SetGoState(GO_STATE_READY); } - if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_THADDIUS_BOSS))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_THADDIUS_BOSS))) { cr->AI()->AttackStart(pWho); cr->AddThreat(pWho, 10.0f); @@ -461,7 +460,7 @@ public: Talk(me->GetEntry() == NPC_STALAGG ? EMOTE_STAL_DEATH : EMOTE_FEUG_DEATH); if (pInstance) { - if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_THADDIUS_BOSS))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_THADDIUS_BOSS))) { cr->AI()->DoAction(ACTION_SUMMON_DIED); } @@ -530,7 +529,7 @@ public: events.RepeatEvent(20000); if (pInstance) { - if (Creature* feugen = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_FEUGEN_BOSS))) + if (Creature* feugen = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_FEUGEN_BOSS))) { if (!feugen->IsAlive() || !feugen->GetVictim() || !me->GetVictim()) return; @@ -734,7 +733,7 @@ public: if (!instance || instance->GetData(DATA_HAD_THADDIUS_GREET) || instance->GetBossState(BOSS_THADDIUS) == DONE) return true; - if (Creature* thaddius = ObjectAccessor::GetCreature(*player, instance->GetData64(DATA_THADDIUS_BOSS))) + if (Creature* thaddius = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_THADDIUS_BOSS))) { thaddius->AI()->Talk(SAY_GREET); } diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp index d0e9442d32..3666e9c2f2 100644 --- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp +++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp @@ -55,54 +55,8 @@ public: for (auto& i : HeiganEruption) i.clear(); - // GOs - _patchwerkGateGUID = 0; - _gluthGateGUID = 0; - _nothEntryGateGUID = 0; - _nothExitGateGUID = 0; - _heiganGateGUID = 0; - _heiganGateExitGUID = 0; - _loathebGateGUID = 0; - _anubGateGUID = 0; - _anubNextGateGUID = 0; - _faerlinaWebGUID = 0; - _faerlinaGateGUID = 0; - _maexxnaGateGUID = 0; - _thaddiusGateGUID = 0; - _horsemanGateGUID = 0; - _kelthuzadFloorGUID = 0; - _kelthuzadGateGUID = 0; - _kelthuzadPortal1GUID = 0; - _kelthuzadPortal2GUID = 0; - _kelthuzadPortal3GUID = 0; - _kelthuzadPortal4GUID = 0; - _sapphironGateGUID = 0; - _horsemanPortalGUID = 0; - _loathebPortalGUID = 0; - _maexxnaPortalGUID = 0; - _thaddiusPortalGUID = 0; - _deathknightEyePortalGUID = 0; - _plagueEyePortalGUID = 0; - _spiderEyePortalGUID = 0; - _abomEyePortalGUID = 0; - _deathknightGlowEyePortalGUID = 0; - _plagueGlowEyePortalGUID = 0; - _spiderGlowEyePortalGUID = 0; - _abomGlowEyePortalGUID = 0; - // NPCs PatchwerkRoomTrash.clear(); - _patchwerkGUID = 0; - _thaddiusGUID = 0; - _stalaggGUID = 0; - _feugenGUID = 0; - _zeliekGUID = 0; - _rivendareGUID = 0; - _blaumeuxGUID = 0; - _korthazzGUID = 0; - _sapphironGUID = 0; - _kelthuzadGUID = 0; - _lichkingGUID = 0; // Controls _horsemanKilled = 0; @@ -126,56 +80,56 @@ public: std::set<GameObject*> HeiganEruption[4]; // GOs - uint64 _patchwerkGateGUID; - uint64 _gluthGateGUID; - uint64 _nothEntryGateGUID; - uint64 _nothExitGateGUID; - uint64 _heiganGateGUID; - uint64 _heiganGateExitGUID; - uint64 _loathebGateGUID; - uint64 _anubGateGUID; - uint64 _anubNextGateGUID; - uint64 _faerlinaWebGUID; - uint64 _faerlinaGateGUID; - uint64 _maexxnaGateGUID; - uint64 _thaddiusGateGUID; - uint64 _gothikEnterGateGUID{}; - uint64 _gothikInnerGateGUID{}; - uint64 _gothikExitGateGUID{}; - uint64 _horsemanGateGUID; - uint64 _kelthuzadFloorGUID; - uint64 _kelthuzadGateGUID; - uint64 _kelthuzadPortal1GUID; - uint64 _kelthuzadPortal2GUID; - uint64 _kelthuzadPortal3GUID; - uint64 _kelthuzadPortal4GUID; - uint64 _sapphironGateGUID; - uint64 _horsemanPortalGUID; - uint64 _loathebPortalGUID; - uint64 _maexxnaPortalGUID; - uint64 _thaddiusPortalGUID; - uint64 _deathknightEyePortalGUID; - uint64 _plagueEyePortalGUID; - uint64 _spiderEyePortalGUID; - uint64 _abomEyePortalGUID; - uint64 _deathknightGlowEyePortalGUID; - uint64 _plagueGlowEyePortalGUID; - uint64 _spiderGlowEyePortalGUID; - uint64 _abomGlowEyePortalGUID; + ObjectGuid _patchwerkGateGUID; + ObjectGuid _gluthGateGUID; + ObjectGuid _nothEntryGateGUID; + ObjectGuid _nothExitGateGUID; + ObjectGuid _heiganGateGUID; + ObjectGuid _heiganGateExitGUID; + ObjectGuid _loathebGateGUID; + ObjectGuid _anubGateGUID; + ObjectGuid _anubNextGateGUID; + ObjectGuid _faerlinaWebGUID; + ObjectGuid _faerlinaGateGUID; + ObjectGuid _maexxnaGateGUID; + ObjectGuid _thaddiusGateGUID; + ObjectGuid _gothikEnterGateGUID; + ObjectGuid _gothikInnerGateGUID; + ObjectGuid _gothikExitGateGUID{}; + ObjectGuid _horsemanGateGUID; + ObjectGuid _kelthuzadFloorGUID; + ObjectGuid _kelthuzadGateGUID; + ObjectGuid _kelthuzadPortal1GUID; + ObjectGuid _kelthuzadPortal2GUID; + ObjectGuid _kelthuzadPortal3GUID; + ObjectGuid _kelthuzadPortal4GUID; + ObjectGuid _sapphironGateGUID; + ObjectGuid _horsemanPortalGUID; + ObjectGuid _loathebPortalGUID; + ObjectGuid _maexxnaPortalGUID; + ObjectGuid _thaddiusPortalGUID; + ObjectGuid _deathknightEyePortalGUID; + ObjectGuid _plagueEyePortalGUID; + ObjectGuid _spiderEyePortalGUID; + ObjectGuid _abomEyePortalGUID; + ObjectGuid _deathknightGlowEyePortalGUID; + ObjectGuid _plagueGlowEyePortalGUID; + ObjectGuid _spiderGlowEyePortalGUID; + ObjectGuid _abomGlowEyePortalGUID; // NPCs - std::list<uint64> PatchwerkRoomTrash; - uint64 _patchwerkGUID; - uint64 _thaddiusGUID; - uint64 _stalaggGUID; - uint64 _feugenGUID; - uint64 _zeliekGUID; - uint64 _rivendareGUID; - uint64 _blaumeuxGUID; - uint64 _korthazzGUID; - uint64 _sapphironGUID; - uint64 _kelthuzadGUID; - uint64 _lichkingGUID; + GuidList PatchwerkRoomTrash; + ObjectGuid _patchwerkGUID; + ObjectGuid _thaddiusGUID; + ObjectGuid _stalaggGUID; + ObjectGuid _feugenGUID; + ObjectGuid _zeliekGUID; + ObjectGuid _rivendareGUID; + ObjectGuid _blaumeuxGUID; + ObjectGuid _korthazzGUID; + ObjectGuid _sapphironGUID; + ObjectGuid _kelthuzadGUID; + ObjectGuid _lichkingGUID; // Controls uint8 _horsemanKilled; @@ -1075,7 +1029,7 @@ public: } } - uint64 GetData64(uint32 id) const override + ObjectGuid GetGuidData(uint32 id) const override { switch (id) { @@ -1124,10 +1078,11 @@ public: return _feugenGUID; case DATA_LICH_KING_BOSS: return _lichkingGUID; - default: - return 0; + break; } + + return ObjectGuid::Empty; } std::string GetSaveData() override diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 585649ce50..cfa8da8b09 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -328,7 +328,7 @@ public: if (me->GetVictim() && me->GetVictim()->GetGUID() == victim->GetGUID() && !me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PACIFIED)) { - if (!me->GetUInt64Value(UNIT_FIELD_TARGET)) + if (!me->GetGuidValue(UNIT_FIELD_TARGET)) me->SetTarget(victim->GetGUID()); } else if (me->Attack(victim, true)) @@ -336,7 +336,7 @@ public: if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PACIFIED)) me->GetMotionMaster()->MoveChase(victim); else - me->SetTarget(0); + me->SetTarget(); } } @@ -449,7 +449,7 @@ public: me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); me->SendMeleeAttackStop(me->GetVictim()); - me->SetTarget((uint64)0); + me->SetTarget(); me->GetMotionMaster()->MoveIdle(); me->StopMoving(); @@ -518,10 +518,10 @@ public: pPlayer->SetUnitMovementFlags(MOVEMENTFLAG_NONE); pPlayer->SetDisableGravity(true, true); WorldPacket data(SMSG_SPLINE_MOVE_UNROOT, 8); - data.append(pPlayer->GetPackGUID()); + data << pPlayer->GetPackGUID(); pPlayer->SendMessageToSet(&data, true); - pPlayer->SetUInt64Value(PLAYER_FARSIGHT, vp->GetGUID()); + pPlayer->SetGuidValue(PLAYER_FARSIGHT, vp->GetGUID()); c->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } } @@ -553,7 +553,7 @@ public: Talk(SAY_END_P1); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); me->SendMeleeAttackStop(); - me->SetTarget((uint64)0); + me->SetTarget(); me->GetMotionMaster()->MoveIdle(); me->DisableSpline(); me->GetMotionMaster()->MovePoint(MI_POINT_CENTER_GROUND_PH_2, CenterPos); @@ -655,7 +655,7 @@ public: break; case EVENT_CLEAR_TARGET: me->SendMeleeAttackStop(); - me->SetTarget(0); + me->SetTarget(); break; case EVENT_CHECK_TRASH_DEAD: { @@ -664,7 +664,7 @@ public: else { me->SendMeleeAttackStop(); - me->SetTarget(0); + me->SetTarget(); events.CancelEventGroup(1); summons.DespawnAll(); // start phase 3 @@ -883,7 +883,7 @@ public: plr->MonsterMoveWithSpeed(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), speed); plr->RemoveAura(SPELL_FREEZE_ANIM); plr->SetDisableGravity(false, true); - plr->SetUInt64Value(PLAYER_FARSIGHT, 0);; + plr->SetGuidValue(PLAYER_FARSIGHT, ObjectGuid::Empty); } } @@ -1007,7 +1007,7 @@ public: if (CheckTimer <= diff) { if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_MALYGOS_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_MALYGOS_GUID))) if (me->IsWithinDist3d(c, 12.0f)) { me->CastSpell(c, SPELL_POWER_SPARK_MALYGOS_BUFF, true); @@ -1024,7 +1024,7 @@ public: if (MoveTimer <= diff) { if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_MALYGOS_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_MALYGOS_GUID))) me->GetMotionMaster()->MovePoint(0, *c); MoveTimer = 2000; } @@ -1168,7 +1168,7 @@ public: break; case EVENT_SCION_OF_ETERNITY_ARCANE_BARRAGE: { - std::vector<uint64> guids; + GuidVector guids; Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers(); if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) @@ -1462,11 +1462,10 @@ public: { PrepareSpellScript(spell_eoe_ph3_surge_of_power_SpellScript); - uint64 DrakeGUID[3]; + ObjectGuid DrakeGUID[3]; bool Load() override { - memset(&DrakeGUID, 0, sizeof(DrakeGUID)); if (Unit* caster = GetCaster()) if (Creature* c = caster->ToCreature()) { diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/eye_of_eternity.h b/src/server/scripts/Northrend/Nexus/EyeOfEternity/eye_of_eternity.h index 0c2d2e9a9f..313f256bc2 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/eye_of_eternity.h +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/eye_of_eternity.h @@ -96,11 +96,11 @@ const uint32 MalygosIntroIntervals[] = {18000, 19000, 21000, 18000, 15000}; class EoEDrakeEnterVehicleEvent : public BasicEvent { public: - EoEDrakeEnterVehicleEvent(Creature& owner, uint64 playerGUID) : _owner(owner), _playerGUID(playerGUID) { } + EoEDrakeEnterVehicleEvent(Creature& owner, ObjectGuid playerGUID) : _owner(owner), _playerGUID(playerGUID) { } bool Execute(uint64 /*eventTime*/, uint32 /*updateTime*/) override; private: Creature& _owner; - uint64 _playerGUID; + ObjectGuid _playerGUID; }; template <class AI, class T> diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp index 15bf32c71d..faa86cc6d0 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp @@ -37,20 +37,16 @@ public: uint32 EncounterStatus; std::string str_data; - uint64 NPC_MalygosGUID; - uint64 GO_IrisGUID; - uint64 GO_ExitPortalGUID; - uint64 GO_PlatformGUID; + ObjectGuid NPC_MalygosGUID; + ObjectGuid GO_IrisGUID; + ObjectGuid GO_ExitPortalGUID; + ObjectGuid GO_PlatformGUID; bool bPokeAchiev; void Initialize() override { EncounterStatus = NOT_STARTED; - NPC_MalygosGUID = 0; - GO_IrisGUID = 0; - GO_ExitPortalGUID = 0; - GO_PlatformGUID = 0; bPokeAchiev = false; } @@ -173,14 +169,15 @@ public: } } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch(type) { case DATA_MALYGOS_GUID: return NPC_MalygosGUID; } - return 0; + + return ObjectGuid::Empty; } void ProcessEvent(WorldObject* /*unit*/, uint32 eventId) override diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp index 5b58efb1e1..20336a54cd 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp @@ -152,7 +152,7 @@ public: for(Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) if (Aura* aur = itr->GetSource()->GetAura(SPELL_INTENSE_COLD_TRIGGER)) if (aur->GetStackAmount() > 2) - aGuids.insert(itr->GetSource()->GetGUIDLow()); + aGuids.insert(itr->GetSource()->GetGUID().GetCounter()); events.ScheduleEvent(EVENT_ACHIEVEMENT_CHECK, 500); break; } @@ -191,7 +191,7 @@ public: if (!target) return false; - return target->GetAI()->GetData(player->GetGUIDLow()); + return target->GetAI()->GetData(player->GetGUID().GetCounter()); } }; diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp index 7331fa270b..efce138d48 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp @@ -184,7 +184,7 @@ public: } int32 _damageTimer; - uint64 _gameObjectGUID; + ObjectGuid _gameObjectGUID; void Reset() override { diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_drakos.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_drakos.cpp index e67eac48f3..4e00540973 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/boss_drakos.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_drakos.cpp @@ -92,7 +92,7 @@ public: { pInstance->SetData(DATA_DRAKOS, DONE); for( uint8 i = 0; i < 3; ++i ) - if( uint64 guid = pInstance->GetData64(DATA_DCD_1 + i) ) + if( ObjectGuid guid = pInstance->GetGuidData(DATA_DCD_1 + i) ) if( GameObject* pGo = ObjectAccessor::GetGameObject(*me, guid) ) if( pGo->GetGoState() != GO_STATE_ACTIVE ) { diff --git a/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp index 7723d0bf8c..1466ade9f1 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp @@ -24,14 +24,14 @@ public: instance_oculus_InstanceMapScript(Map* pMap) : InstanceScript(pMap) { Initialize(); } uint32 m_auiEncounter[MAX_ENCOUNTER]; - uint64 DragonCageDoorGUID[3]; - uint64 EregosCacheGUID; + ObjectGuid DragonCageDoorGUID[3]; + ObjectGuid EregosCacheGUID; uint32 CentrifugeCount; - uint64 uiDrakosGUID; - uint64 uiVarosGUID; - uint64 uiUromGUID; - uint64 uiEregosGUID; + ObjectGuid uiDrakosGUID; + ObjectGuid uiVarosGUID; + ObjectGuid uiUromGUID; + ObjectGuid uiEregosGUID; bool bAmberVoid; bool bEmeraldVoid; @@ -39,18 +39,12 @@ public: void Initialize() override { - EregosCacheGUID = 0; - uiDrakosGUID = 0; - uiVarosGUID = 0; - uiUromGUID = 0; - uiEregosGUID = 0; CentrifugeCount = 0; bAmberVoid = false; bEmeraldVoid = false; bRubyVoid = false; memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - memset(&DragonCageDoorGUID, 0, sizeof(DragonCageDoorGUID)); } void OnCreatureCreate(Creature* pCreature) override @@ -200,7 +194,7 @@ public: return 0; } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { switch( identifier ) { @@ -218,7 +212,7 @@ public: return DragonCageDoorGUID[identifier - 100]; } - return 0; + return ObjectGuid::Empty; } std::string GetSaveData() override diff --git a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp index 15cccd34ea..d9a4d34513 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp @@ -62,7 +62,7 @@ enum DrakeGiverTexts class npc_oculus_drakegiver : public CreatureScript { public: - std::unordered_map<uint32, bool>openedMenu; + std::unordered_map<ObjectGuid, bool>openedMenu; npc_oculus_drakegiver() : CreatureScript("npc_oculus_drakegiver") { } @@ -887,7 +887,7 @@ public: { PrepareAuraScript(spell_oculus_rider_auraAuraScript); - uint64 _drakeGUID; + ObjectGuid _drakeGUID; void HandleOnEffectApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp index f33455af28..bf71ab4bec 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp @@ -125,7 +125,7 @@ public: AddWaypoint(13, 1281.2f, -26.8f, 33.5f, 0); AddWaypoint(14, 1262, -26.9f, 33.5f, 0); - Start(true, false, 0, nullptr, false, true); + Start(true, false, ObjectGuid::Empty, nullptr, false, true); } InstanceScript* m_pInstance; @@ -372,14 +372,14 @@ public: npc_stormforged_lieutenantAI(Creature* creature) : ScriptedAI(creature) { } EventMap events; - uint64 BjarngrimGUID; + ObjectGuid BjarngrimGUID; void Reset() override { if (me->IsSummon()) BjarngrimGUID = me->ToTempSummon()->GetSummonerGUID(); else - BjarngrimGUID = 0; + BjarngrimGUID.Clear(); } void EnterCombat(Unit*) override diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp index f00d222118..7e8b4d5a6f 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp @@ -361,7 +361,7 @@ public: { if (me->GetEntry() == NPC_BRITTLE_GOLEM && param == ACTION_SHATTER) { - if (Creature* volkhan = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(TYPE_VOLKHAN))) + if (Creature* volkhan = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(TYPE_VOLKHAN))) volkhan->AI()->DoAction(ACTION_DESTROYED); me->CastSpell(me, me->GetMap()->IsHeroic() ? SPELL_SHATTER_H : SPELL_SHATTER_N, true); @@ -444,7 +444,7 @@ public: { npc_hol_monumentAI(Creature* creature) : ScriptedAI(creature) { - _attackGUID = 0; + _attackGUID.Clear(); _isActive = urand(0, 1); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->CastSpell(me, SPELL_FREEZE_ANIM, true); @@ -452,7 +452,7 @@ public: EventMap events; bool _isActive; - uint64 _attackGUID; + ObjectGuid _attackGUID; void Reset() override { diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/instance_halls_of_lightning.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/instance_halls_of_lightning.cpp index 548b2277db..c74f3b6e6b 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/instance_halls_of_lightning.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/instance_halls_of_lightning.cpp @@ -22,16 +22,16 @@ public: uint32 m_auiEncounter[MAX_ENCOUNTER]; - uint64 m_uiGeneralBjarngrimGUID; - uint64 m_uiIonarGUID; - uint64 m_uiLokenGUID; - uint64 m_uiVolkhanGUID; + ObjectGuid m_uiGeneralBjarngrimGUID; + ObjectGuid m_uiIonarGUID; + ObjectGuid m_uiLokenGUID; + ObjectGuid m_uiVolkhanGUID; - uint64 m_uiBjarngrimDoorGUID; - uint64 m_uiVolkhanDoorGUID; - uint64 m_uiIonarDoorGUID; - uint64 m_uiLokenDoorGUID; - uint64 m_uiLokenGlobeGUID; + ObjectGuid m_uiBjarngrimDoorGUID; + ObjectGuid m_uiVolkhanDoorGUID; + ObjectGuid m_uiIonarDoorGUID; + ObjectGuid m_uiLokenDoorGUID; + ObjectGuid m_uiLokenGlobeGUID; bool volkhanAchievement; bool bjarngrimAchievement; @@ -40,17 +40,6 @@ public: { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - m_uiGeneralBjarngrimGUID = 0; - m_uiVolkhanGUID = 0; - m_uiIonarGUID = 0; - m_uiLokenGUID = 0; - - m_uiBjarngrimDoorGUID = 0; - m_uiVolkhanDoorGUID = 0; - m_uiIonarDoorGUID = 0; - m_uiLokenDoorGUID = 0; - m_uiLokenGlobeGUID = 0; - volkhanAchievement = false; bjarngrimAchievement = false; } @@ -219,7 +208,7 @@ public: return m_auiEncounter[uiType]; } - uint64 GetData64(uint32 uiData) const override + ObjectGuid GetGuidData(uint32 uiData) const override { switch(uiData) { @@ -232,7 +221,8 @@ public: case TYPE_LOKEN: return m_uiLokenGUID; } - return 0; + + return ObjectGuid::Empty; } }; }; diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_sjonnir.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_sjonnir.cpp index 644e24cf0b..8d95cbd13a 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_sjonnir.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_sjonnir.cpp @@ -132,13 +132,13 @@ public: if (pInstance->GetData(BOSS_TRIBUNAL_OF_AGES) == DONE) { me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - if (GameObject* doors = me->GetMap()->GetGameObject(pInstance->GetData64(GO_SJONNIR_DOOR))) + if (GameObject* doors = me->GetMap()->GetGameObject(pInstance->GetGuidData(GO_SJONNIR_DOOR))) doors->SetGoState(GO_STATE_ACTIVE); - if (GameObject* console = me->GetMap()->GetGameObject( pInstance->GetData64(GO_SJONNIR_CONSOLE))) + if (GameObject* console = me->GetMap()->GetGameObject( pInstance->GetGuidData(GO_SJONNIR_CONSOLE))) console->SetGoState(GO_STATE_READY); - if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_BRANN))) + if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_BRANN))) { brann->setDeathState(JUST_DIED); brann->Respawn(); @@ -165,11 +165,11 @@ public: { pInstance->SetData(BOSS_SJONNIR, IN_PROGRESS); - if (GameObject* doors = me->GetMap()->GetGameObject(pInstance->GetData64(GO_SJONNIR_DOOR))) + if (GameObject* doors = me->GetMap()->GetGameObject(pInstance->GetGuidData(GO_SJONNIR_DOOR))) doors->SetGoState(GO_STATE_READY); if (pInstance->GetData(BOSS_TRIBUNAL_OF_AGES) == DONE) - if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_BRANN))) + if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_BRANN))) brann->AI()->DoAction(3); } } @@ -205,7 +205,7 @@ public: events.ScheduleEvent(EVENT_SUMMON, 1500); if (pInstance) - if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_BRANN))) + if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_BRANN))) { brann->MonsterYell("What in the name o' Madoran did THAT do? Oh! Wait: I just about got it...", LANG_UNIVERSAL, 0); brann->PlayDirectSound(14276); @@ -214,7 +214,7 @@ public: if (HealthBelowPct(20)) { - if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_BRANN))) + if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_BRANN))) { brann->MonsterYell("Ha, that did it! Help's a-comin'! Take this, ya glowin' iron brute!", LANG_UNIVERSAL, 0); brann->PlayDirectSound(14277); @@ -261,7 +261,7 @@ public: } case EVENT_SUMMON_SPEACH: { - if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_BRANN))) + if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_BRANN))) { brann->MonsterYell("This is a wee bit trickier that before... Oh, bloody--incomin'!", LANG_UNIVERSAL, 0); brann->PlayDirectSound(14275); @@ -314,10 +314,10 @@ public: if (pInstance) { pInstance->SetData(BOSS_SJONNIR, DONE); - if (GameObject* sd = me->GetMap()->GetGameObject(pInstance->GetData64(GO_SJONNIR_DOOR))) + if (GameObject* sd = me->GetMap()->GetGameObject(pInstance->GetGuidData(GO_SJONNIR_DOOR))) sd->SetGoState(GO_STATE_ACTIVE); - if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_BRANN))) + if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_BRANN))) brann->AI()->DoAction(4); } } @@ -333,7 +333,7 @@ public: void ActivatePipe(uint8 side) { if (pInstance) - if (GameObject* pipe = me->GetMap()->GetGameObject(pInstance->GetData64(side == POS_GEN_RIGHT ? GO_RIGHT_PIPE : GO_LEFT_PIPE))) + if (GameObject* pipe = me->GetMap()->GetGameObject(pInstance->GetGuidData(side == POS_GEN_RIGHT ? GO_RIGHT_PIPE : GO_LEFT_PIPE))) pipe->SendCustomAnim(0); } @@ -423,7 +423,7 @@ public: void JustDied(Unit* /*killer*/) override { if (InstanceScript* pInstance = me->GetInstanceScript()) - if (Creature* sjonnir = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_SJONNIR))) + if (Creature* sjonnir = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_SJONNIR))) sjonnir->AI()->DoAction(ACTION_SLUG_KILLED); } void UpdateAI(uint32 diff) override diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/brann_bronzebeard.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/brann_bronzebeard.cpp index b89af0c198..56657001ac 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/brann_bronzebeard.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/brann_bronzebeard.cpp @@ -224,16 +224,15 @@ public: { brann_bronzebeardAI(Creature* c) : npc_escortAI(c), summons(me) { - AbedneumGUID = MarnakGUID = KaddrakGUID = 0; pInstance = c->GetInstanceScript(); } InstanceScript* pInstance; EventMap events; SummonList summons; - uint64 AbedneumGUID; - uint64 MarnakGUID; - uint64 KaddrakGUID; + ObjectGuid AbedneumGUID; + ObjectGuid MarnakGUID; + ObjectGuid KaddrakGUID; uint8 WaveNum; bool TalkEvent; @@ -255,21 +254,21 @@ public: GameObject* go = nullptr; if (headMask & 0x1) // Kaddrak - if ((go = me->GetMap()->GetGameObject(pInstance->GetData64(GO_KADDRAK)))) + if ((go = me->GetMap()->GetGameObject(pInstance->GetGuidData(GO_KADDRAK)))) activate ? go->SendCustomAnim(0) : go->SetGoState(GO_STATE_READY); if (headMask & 0x2) // Marnak - if ((go = me->GetMap()->GetGameObject(pInstance->GetData64(GO_MARNAK)))) + if ((go = me->GetMap()->GetGameObject(pInstance->GetGuidData(GO_MARNAK)))) activate ? go->SendCustomAnim(0) : go->SetGoState(GO_STATE_READY); if (headMask & 0x4) // Abedneum - if ((go = me->GetMap()->GetGameObject(pInstance->GetData64(GO_ABEDNEUM)))) + if ((go = me->GetMap()->GetGameObject(pInstance->GetGuidData(GO_ABEDNEUM)))) activate ? go->SendCustomAnim(0) : go->SetGoState(GO_STATE_READY); } void ResetEvent() { - if (GameObject* tribunal = ObjectAccessor::GetGameObject(*me, pInstance->GetData64(GO_TRIBUNAL_CONSOLE))) + if (GameObject* tribunal = ObjectAccessor::GetGameObject(*me, pInstance->GetGuidData(GO_TRIBUNAL_CONSOLE))) tribunal->SetGoState(GO_STATE_READY); events.Reset(); @@ -322,7 +321,7 @@ public: switch (action) { case ACTION_START_EVENT: - Start(false, true, 0, 0, true, false); + Start(false, true, ObjectGuid::Empty, 0, true, false); break; case ACTION_START_TRIBUNAL: { @@ -363,13 +362,13 @@ public: Reset(); break; case ACTION_WIPE_START: - Start(false, true, 0, 0, true, false); + Start(false, true, ObjectGuid::Empty, 0, true, false); SetNextWaypoint(20, false); ResetEvent(); me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); break; case ACTION_OPEN_DOOR: - if (GameObject* door = ObjectAccessor::GetGameObject(*me, pInstance->GetData64(GO_SJONNIR_DOOR))) + if (GameObject* door = ObjectAccessor::GetGameObject(*me, pInstance->GetGuidData(GO_SJONNIR_DOOR))) door->SetGoState(GO_STATE_ACTIVE); SetEscortPaused(false); me->RemoveAura(58506); @@ -513,7 +512,7 @@ public: } case EVENT_GO_TO_SJONNIR: { - if (GameObject* door = ObjectAccessor::GetGameObject(*me, pInstance->GetData64(GO_SJONNIR_DOOR))) + if (GameObject* door = ObjectAccessor::GetGameObject(*me, pInstance->GetGuidData(GO_SJONNIR_DOOR))) door->SetGoState(GO_STATE_ACTIVE); SetEscortPaused(false); ResetEvent(); @@ -588,7 +587,7 @@ public: ResetEvent(); if(pInstance) { - if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_BRANN))) + if (Creature* brann = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_BRANN))) { brann->setDeathState(JUST_DIED); brann->Respawn(); @@ -653,7 +652,7 @@ void brann_bronzebeard::brann_bronzebeardAI::WaypointReached(uint32 id) if(pInstance) { pInstance->SetData(BOSS_TRIBUNAL_OF_AGES, IN_PROGRESS); - if (GameObject* tribunal = ObjectAccessor::GetGameObject(*me, pInstance->GetData64(GO_TRIBUNAL_CONSOLE))) + if (GameObject* tribunal = ObjectAccessor::GetGameObject(*me, pInstance->GetGuidData(GO_TRIBUNAL_CONSOLE))) tribunal->SetGoState(GO_STATE_ACTIVE); } break; @@ -664,7 +663,7 @@ void brann_bronzebeard::brann_bronzebeardAI::WaypointReached(uint32 id) { pInstance->SetData(BRANN_BRONZEBEARD, 5); me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER); - if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetData64(NPC_SJONNIR))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_SJONNIR))) cr->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetOrientation(3.132660f); DoCast(me, 58506, false); @@ -677,7 +676,7 @@ void brann_bronzebeard::brann_bronzebeardAI::WaypointReached(uint32 id) SetEscortPaused(true); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_USE_STANDING); if (pInstance) - if (GameObject* console = ObjectAccessor::GetGameObject(*me, pInstance->GetData64(GO_SJONNIR_CONSOLE))) + if (GameObject* console = ObjectAccessor::GetGameObject(*me, pInstance->GetGuidData(GO_SJONNIR_CONSOLE))) console->SetGoState(GO_STATE_ACTIVE); break; diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp index 5f9f2679bb..5eb0cddc5b 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp @@ -22,19 +22,19 @@ public: uint32 Encounter[MAX_ENCOUNTER]; - uint64 goKaddrakGUID; - uint64 goMarnakGUID; - uint64 goAbedneumGUID; - uint64 goTribunalConsoleGUID; - uint64 goSkyRoomFloorGUID; - uint64 goSjonnirConsoleGUID; - uint64 goSjonnirDoorGUID; - uint64 goLeftPipeGUID; - uint64 goRightPipeGUID; - uint64 goTribunalDoorGUID; - - uint64 SjonnirGUID; - uint64 BrannGUID; + ObjectGuid goKaddrakGUID; + ObjectGuid goMarnakGUID; + ObjectGuid goAbedneumGUID; + ObjectGuid goTribunalConsoleGUID; + ObjectGuid goSkyRoomFloorGUID; + ObjectGuid goSjonnirConsoleGUID; + ObjectGuid goSjonnirDoorGUID; + ObjectGuid goLeftPipeGUID; + ObjectGuid goRightPipeGUID; + ObjectGuid goTribunalDoorGUID; + + ObjectGuid SjonnirGUID; + ObjectGuid BrannGUID; bool brannAchievement; bool sjonnirAchievement; @@ -45,20 +45,6 @@ public: { memset(&Encounter, 0, sizeof(Encounter)); - goKaddrakGUID = 0; - goMarnakGUID = 0; - goAbedneumGUID = 0; - goTribunalConsoleGUID = 0; - goSkyRoomFloorGUID = 0; - goSjonnirConsoleGUID = 0; - goSjonnirDoorGUID = 0; - goLeftPipeGUID = 0; - goRightPipeGUID = 0; - goTribunalDoorGUID = 0; - - SjonnirGUID = 0; - BrannGUID = 0; - brannAchievement = false; sjonnirAchievement = false; isMaidenOfGriefDead = false; @@ -132,9 +118,9 @@ public: } } - uint64 GetData64(uint32 id) const override + ObjectGuid GetGuidData(uint32 id) const override { - switch(id) + switch (id) { case GO_TRIBUNAL_CONSOLE: return goTribunalConsoleGUID; @@ -160,12 +146,13 @@ public: case NPC_BRANN: return BrannGUID; } - return 0; + + return ObjectGuid::Empty; } uint32 GetData(uint32 id) const override { - switch(id) + switch (id) { case BOSS_KRYSTALLUS: case BOSS_MAIDEN_OF_GRIEF: @@ -174,18 +161,20 @@ public: case BRANN_BRONZEBEARD: return Encounter[id]; } + return 0; } bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/, uint32 /*miscvalue1*/) override { - switch(criteria_id) + switch (criteria_id) { case 7590: // Brann Spankin' New (2154) return brannAchievement; case 7593: // Abuse the Ooze (2155) return sjonnirAchievement; } + return false; } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp index 0f56bca30c..99eb532981 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp @@ -637,7 +637,7 @@ public: case EVENT_INTRO_FINISH: events.Reset(); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); - if (Creature* brann = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(NPC_BRANN_BRONZBEARD_ALG))) + if (Creature* brann = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(NPC_BRANN_BRONZBEARD_ALG))) brann->AI()->DoAction(ACTION_FINISH_INTRO); break; case EVENT_START_COMBAT: @@ -875,7 +875,7 @@ public: me->GetMotionMaster()->MovePoint(_currentPoint, BrannIntroWaypoint[_currentPoint]); break; case EVENT_SUMMON_ALGALON: - if (me->GetInstanceScript() && !me->GetInstanceScript()->GetData64(TYPE_ALGALON)) + if (me->GetInstanceScript() && !me->GetInstanceScript()->GetGuidData(TYPE_ALGALON)) if (Creature* algalon = me->GetMap()->SummonCreature(NPC_ALGALON, AlgalonSummonPos)) algalon->AI()->DoAction(ACTION_START_INTRO); break; @@ -1119,10 +1119,10 @@ public: if (InstanceScript* instance = go->GetInstanceScript()) { instance->SetData(DATA_ALGALON_SUMMON_STATE, 1); - if (GameObject* sigil = ObjectAccessor::GetGameObject(*go, instance->GetData64(GO_DOODAD_UL_SIGILDOOR_01))) + if (GameObject* sigil = ObjectAccessor::GetGameObject(*go, instance->GetGuidData(GO_DOODAD_UL_SIGILDOOR_01))) sigil->SetGoState(GO_STATE_ACTIVE); - if (GameObject* sigil = ObjectAccessor::GetGameObject(*go, instance->GetData64(GO_DOODAD_UL_SIGILDOOR_02))) + if (GameObject* sigil = ObjectAccessor::GetGameObject(*go, instance->GetGuidData(GO_DOODAD_UL_SIGILDOOR_02))) sigil->SetGoState(GO_STATE_ACTIVE); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp index 3e49691a22..530cf6d205 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp @@ -132,7 +132,7 @@ bool IsEncounterComplete(InstanceScript* pInstance, Creature* me) for (uint8 i = 0; i < 3; ++i) { - uint64 guid = pInstance->GetData64(DATA_STEELBREAKER + i); + ObjectGuid guid = pInstance->GetGuidData(DATA_STEELBREAKER + i); if (!guid) return false; @@ -155,7 +155,7 @@ void RespawnAssemblyOfIron(InstanceScript* pInstance, Creature* me) for (uint8 i = 0; i < 3; ++i) { - uint64 guid = pInstance->GetData64(DATA_STEELBREAKER + i); + ObjectGuid guid = pInstance->GetGuidData(DATA_STEELBREAKER + i); if (!guid) return; @@ -166,14 +166,14 @@ void RespawnAssemblyOfIron(InstanceScript* pInstance, Creature* me) return; } -void RestoreAssemblyHealth(uint64 guid1, uint64 guid2, Creature* me) +void RestoreAssemblyHealth(ObjectGuid guid1, ObjectGuid guid2, Creature* me) { - if(Creature* cr = ObjectAccessor::GetCreature(*me, guid1)) - if(cr->IsAlive()) + if (Creature* cr = ObjectAccessor::GetCreature(*me, guid1)) + if (cr->IsAlive()) cr->SetHealth(cr->GetMaxHealth()); - if(Creature* cr2 = ObjectAccessor::GetCreature(*me, guid2)) - if(cr2->IsAlive()) + if (Creature* cr2 = ObjectAccessor::GetCreature(*me, guid2)) + if (cr2->IsAlive()) cr2->SetHealth(cr2->GetMaxHealth()); } @@ -229,7 +229,7 @@ public: if (!pInstance) return; - if (Creature* boss = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_STEELBREAKER + urand(0, 2)))) + if (Creature* boss = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_STEELBREAKER + urand(0, 2)))) { switch (boss->GetEntry()) { @@ -246,7 +246,7 @@ public: } for (uint8 i = 0; i < 3; ++i) - if (Creature* boss = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_STEELBREAKER + i))) + if (Creature* boss = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_STEELBREAKER + i))) if (!boss->IsInCombat()) boss->AI()->AttackStart(who); } @@ -286,7 +286,7 @@ public: } else { - RestoreAssemblyHealth(pInstance->GetData64(DATA_BRUNDIR), pInstance->GetData64(DATA_MOLGEIM), me); + RestoreAssemblyHealth(pInstance->GetGuidData(DATA_BRUNDIR), pInstance->GetGuidData(DATA_MOLGEIM), me); me->CastSpell(me, SPELL_SUPERCHARGE, true); Talk(SAY_STEELBREAKER_DEATH); } @@ -423,7 +423,7 @@ public: return; for (uint8 i = 0; i < 3; ++i) - if (Creature* boss = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_STEELBREAKER + i))) + if (Creature* boss = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_STEELBREAKER + i))) if (!boss->IsInCombat()) boss->AI()->AttackStart(who); } @@ -464,7 +464,7 @@ public: } else { - RestoreAssemblyHealth(pInstance->GetData64(DATA_STEELBREAKER), pInstance->GetData64(DATA_BRUNDIR), me); + RestoreAssemblyHealth(pInstance->GetGuidData(DATA_STEELBREAKER), pInstance->GetGuidData(DATA_BRUNDIR), me); me->CastSpell(me, SPELL_SUPERCHARGE, true); Talk(SAY_MOLGEIM_DEATH); } @@ -642,7 +642,7 @@ public: return; for (uint8 i = 0; i < 3; ++i) - if (Creature* boss = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_STEELBREAKER + i))) + if (Creature* boss = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_STEELBREAKER + i))) if (!boss->IsInCombat()) boss->AI()->AttackStart(who); } @@ -684,7 +684,7 @@ public: } else { - RestoreAssemblyHealth(pInstance->GetData64(DATA_STEELBREAKER), pInstance->GetData64(DATA_MOLGEIM), me); + RestoreAssemblyHealth(pInstance->GetGuidData(DATA_STEELBREAKER), pInstance->GetGuidData(DATA_MOLGEIM), me); me->CastSpell(me, SPELL_SUPERCHARGE, true); Talk(SAY_BRUNDIR_DEATH); } @@ -788,7 +788,7 @@ public: me->CombatStop(); me->StopMoving(); me->SetReactState(REACT_PASSIVE); - me->SetUInt64Value(UNIT_FIELD_TARGET, 0); + me->SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); me->SendMonsterMove(_flyTarget->GetPositionX(), _flyTarget->GetPositionY(), _flyTarget->GetPositionZ() + 15, 1500, SPLINEFLAG_FLYING); @@ -869,7 +869,7 @@ public: void HandleInstaKill(SpellEffIndex /*effIndex*/) { if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* Steelbreaker = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(DATA_STEELBREAKER))) + if (Creature* Steelbreaker = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_STEELBREAKER))) Steelbreaker->AI()->DoAction(ACTION_ADD_CHARGE); } @@ -898,7 +898,7 @@ public: { PreventDefaultAction(); if (aurEff->GetTickNumber() % 2 == 0) - GetTarget()->CastSpell(GetTarget(), SPELL_RUNE_OF_SUMMONING_SUMMON, true, nullptr, aurEff, GetTarget()->IsSummon() ? GetTarget()->ToTempSummon()->GetSummonerGUID() : 0); + GetTarget()->CastSpell(GetTarget(), SPELL_RUNE_OF_SUMMONING_SUMMON, true, nullptr, aurEff, GetTarget()->IsSummon() ? GetTarget()->ToTempSummon()->GetSummonerGUID() : ObjectGuid::Empty); } void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -949,7 +949,7 @@ public: return false; if (InstanceScript* instance = target->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetData64(DATA_BRUNDIR))) + if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetGuidData(DATA_BRUNDIR))) return cr->AI()->GetData(DATA_BRUNDIR); return false; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp index 830bca90ea..182d176397 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp @@ -291,7 +291,7 @@ public: void EnterCombat(Unit*) override { if (me->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_AURIAYA))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_AURIAYA))) cr->SetInCombatWithZone(); } @@ -367,7 +367,7 @@ public: { // inform about our death, start timer if (me->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_AURIAYA))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_AURIAYA))) cr->AI()->DoAction(_feralEssenceStack ? ACTION_FERAL_DEATH_WITH_STACK : ACTION_FERAL_DEATH); if (_feralEssenceStack) @@ -464,7 +464,7 @@ public: { if (target) if (InstanceScript* instance = target->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetData64(TYPE_AURIAYA))) + if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetGuidData(TYPE_AURIAYA))) return cr->AI()->GetData(DATA_CRAZY_CAT); return false; @@ -480,7 +480,7 @@ public: { if (target) if (InstanceScript* instance = target->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetData64(TYPE_AURIAYA))) + if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetGuidData(TYPE_AURIAYA))) return cr->AI()->GetData(DATA_NINE_LIVES); return false; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index 0e091ffca2..9ead51cf97 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -534,24 +534,24 @@ void boss_flame_leviathan::boss_flame_leviathanAI::TurnGates(bool _start, bool _ { // first one is ALWAYS turned on, unless leviathan is beaten GameObject* go = nullptr; - if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(DATA_LIGHTNING_WALL2)))) + if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(DATA_LIGHTNING_WALL2)))) go->SetGoState(GO_STATE_READY); if (m_pInstance->GetData(TYPE_LEVIATHAN) == NOT_STARTED) - if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(GO_LEVIATHAN_DOORS)))) + if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(GO_LEVIATHAN_DOORS)))) go->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); } else { GameObject* go = nullptr; if (_death) - if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(DATA_LIGHTNING_WALL1)))) + if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(DATA_LIGHTNING_WALL1)))) go->SetGoState(GO_STATE_ACTIVE); - if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(DATA_LIGHTNING_WALL2)))) + if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(DATA_LIGHTNING_WALL2)))) go->SetGoState(GO_STATE_ACTIVE); - if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(GO_LEVIATHAN_DOORS)))) + if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(GO_LEVIATHAN_DOORS)))) { if (m_pInstance->GetData(TYPE_LEVIATHAN) == SPECIAL || m_pInstance->GetData(TYPE_LEVIATHAN) == DONE) go->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); @@ -569,16 +569,16 @@ void boss_flame_leviathan::boss_flame_leviathanAI::TurnHealStations(bool _apply) GameObject* go = nullptr; if (_apply) { - if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(DATA_REPAIR_STATION1)))) + if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(DATA_REPAIR_STATION1)))) go->SetLootState(GO_READY); - if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(DATA_REPAIR_STATION2)))) + if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(DATA_REPAIR_STATION2)))) go->SetLootState(GO_READY); } else { - if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(DATA_REPAIR_STATION1)))) + if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(DATA_REPAIR_STATION1)))) go->SetLootState(GO_ACTIVATED); - if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(DATA_REPAIR_STATION2)))) + if ((go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(DATA_REPAIR_STATION2)))) go->SetLootState(GO_ACTIVATED); } } @@ -800,7 +800,7 @@ public: if (Unit* device = vehicle->GetPassenger(SEAT_DEVICE)) device->SetUInt32Value(UNIT_FIELD_FLAGS, 0); // unselectable - if (Creature* leviathan = ObjectAccessor::GetCreature(*me, _instance->GetData64(TYPE_LEVIATHAN))) + if (Creature* leviathan = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(TYPE_LEVIATHAN))) leviathan->AI()->DoAction(ACTION_DESTROYED_TURRET); } @@ -1066,7 +1066,7 @@ public: { summons.DespawnAll(); _spellTimer = 0; - Start(false, false, 0, nullptr, false, true); + Start(false, false, ObjectGuid::Empty, nullptr, false, true); if (Aura* aur = me->AddAura(SPELL_FREYA_DUMMY_YELLOW, me)) { aur->SetMaxDuration(-1); @@ -1633,7 +1633,7 @@ public: //! Vehicle must be in use by player bool playerFound = false; for (SeatMap::const_iterator itr = vehicle->Seats.begin(); itr != vehicle->Seats.end() && !playerFound; ++itr) - if (IS_PLAYER_GUID(itr->second.Passenger.Guid)) + if (itr->second.Passenger.Guid.IsPlayer()) playerFound = true; return !playerFound; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp index fc828b783d..141e48efbf 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp @@ -260,7 +260,6 @@ public: if (!me->IsAlive()) if (m_pInstance) m_pInstance->SetData(TYPE_FREYA, DONE); - memset(_elderGUID, 0, sizeof(_elderGUID)); } InstanceScript* m_pInstance; @@ -275,7 +274,7 @@ public: bool _backToNature; uint8 _deforestation; - uint64 _elderGUID[3]; + ObjectGuid _elderGUID[3]; void Reset() override { @@ -292,7 +291,8 @@ public: if (Creature* elder = ObjectAccessor::GetCreature(*me, _elderGUID[i])) elder->AI()->EnterEvadeMode(); - _elderGUID[i] = 0; + + _elderGUID[i].Clear(); } _lumberjacked = 0; @@ -503,7 +503,7 @@ public: // HARD MODE CHECKS Creature* elder = nullptr; - elder = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(NPC_ELDER_STONEBARK)); + elder = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(NPC_ELDER_STONEBARK)); if (elder && elder->IsAlive()) { elder->CastSpell(elder, SPELL_DRAINED_OF_POWER, true); @@ -514,7 +514,7 @@ public: _elderGUID[0] = elder->GetGUID(); } - elder = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(NPC_ELDER_IRONBRANCH)); + elder = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(NPC_ELDER_IRONBRANCH)); if (elder && elder->IsAlive()) { elder->CastSpell(elder, SPELL_DRAINED_OF_POWER, true); @@ -525,7 +525,7 @@ public: _elderGUID[1] = elder->GetGUID(); } - elder = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(NPC_ELDER_BRIGHTLEAF)); + elder = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(NPC_ELDER_BRIGHTLEAF)); if (elder && elder->IsAlive()) { elder->CastSpell(elder, SPELL_DRAINED_OF_POWER, true); @@ -713,7 +713,7 @@ public: // Lumberjacked if (me->GetInstanceScript()) - if (Creature* freya = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_FREYA))) + if (Creature* freya = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_FREYA))) freya->AI()->DoAction(ACTION_LUMBERJACKED); } @@ -819,7 +819,7 @@ public: // Lumberjacked if (me->GetInstanceScript()) - if (Creature* freya = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_FREYA))) + if (Creature* freya = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_FREYA))) freya->AI()->DoAction(ACTION_LUMBERJACKED); } @@ -940,7 +940,7 @@ public: // Lumberjacked if (me->GetInstanceScript()) - if (Creature* freya = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_FREYA))) + if (Creature* freya = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_FREYA))) freya->AI()->DoAction(ACTION_LUMBERJACKED); } @@ -1108,13 +1108,13 @@ public: { boss_freya_summonsAI(Creature* pCreature) : ScriptedAI(pCreature) { - _freyaGUID = me->GetInstanceScript() ? me->GetInstanceScript()->GetData64(TYPE_FREYA) : 0; + _freyaGUID = me->GetInstanceScript() ? me->GetInstanceScript()->GetGuidData(TYPE_FREYA) : ObjectGuid::Empty; _isTrio = me->GetEntry() == NPC_ANCIENT_WATER_SPIRIT || me->GetEntry() == NPC_STORM_LASHER || me->GetEntry() == NPC_SNAPLASHER; _hasDied = false; } EventMap events; - uint64 _freyaGUID; + ObjectGuid _freyaGUID; uint8 _stackCount; bool _hasDied; bool _isTrio; @@ -1251,10 +1251,10 @@ public: { boss_freya_nature_bombAI(Creature* pCreature) : NullCreatureAI(pCreature) { - _goGUID = 0; + _goGUID.Clear(); } - uint64 _goGUID; + ObjectGuid _goGUID; uint32 _explodeTimer; void Reset() override diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp index fcbf61940e..d9e25eb192 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp @@ -232,7 +232,7 @@ public: { me->setAttackTimer(BASE_ATTACK, 2000); Player* target = players.at(urand(0, players.size() - 1)); - me->SetUInt64Value(UNIT_FIELD_TARGET, target->GetGUID()); + me->SetGuidValue(UNIT_FIELD_TARGET, target->GetGUID()); me->CastSpell(target, SPELL_VEZAX_SHADOW_CRASH, false); events.ScheduleEvent(EVENT_RESTORE_TARGET, 750); } @@ -240,7 +240,7 @@ public: break; case EVENT_RESTORE_TARGET: if (me->GetVictim()) - me->SetUInt64Value(UNIT_FIELD_TARGET, me->GetVictim()->GetGUID()); + me->SetGuidValue(UNIT_FIELD_TARGET, me->GetVictim()->GetGUID()); break; case EVENT_SPELL_SEARING_FLAMES: if(!me->HasAura(SPELL_SARONITE_BARRIER)) @@ -291,8 +291,8 @@ public: events.RepeatEvent(30000); else { - for( std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr ) - if( Creature* sv = ObjectAccessor::GetCreature(*me, *itr) ) + for (ObjectGuid guid : summons) + if (Creature* sv = ObjectAccessor::GetCreature(*me, guid)) { sv->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); sv->GetMotionMaster()->MoveIdle(); @@ -413,7 +413,7 @@ public: // killed saronite vapors, hard mode unavailable if( pInstance ) - if( Creature* vezax = ObjectAccessor::GetCreature(*me, pInstance->GetData64(TYPE_VEZAX)) ) + if( Creature* vezax = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(TYPE_VEZAX)) ) vezax->AI()->DoAction(1); } }; @@ -435,7 +435,7 @@ public: { pInstance = pCreature->GetInstanceScript(); if( pInstance ) - if( Creature* vezax = ObjectAccessor::GetCreature(*me, pInstance->GetData64(TYPE_VEZAX)) ) + if( Creature* vezax = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(TYPE_VEZAX)) ) vezax->AI()->JustSummoned(me); timer = 0; me->SetInCombatWithZone(); @@ -449,7 +449,7 @@ public: me->DespawnOrUnsummon(3000); if( pInstance ) - if( Creature* vezax = ObjectAccessor::GetCreature(*me, pInstance->GetData64(TYPE_VEZAX)) ) + if( Creature* vezax = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(TYPE_VEZAX)) ) vezax->AI()->DoAction(2); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp index 8a4ea6c289..897b4a37fc 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp @@ -209,7 +209,7 @@ public: InstanceScript* pInstance; EventMap events; SummonList summons; - uint64 Helpers[8]{ }; + ObjectGuid Helpers[8]; bool berserk{ false }; bool bAchievCheese{ true }; bool bAchievGettingCold{ true }; @@ -472,7 +472,7 @@ public: Creature* GetHelper(uint8 index) { - return (Helpers[index] ? ObjectAccessor::GetCreature(*me, Helpers[index]) : nullptr); + return Helpers[index] ? ObjectAccessor::GetCreature(*me, Helpers[index]) : nullptr; } void SpawnHelpers() @@ -647,7 +647,7 @@ public: { if (pInstance && doneBy) if (pInstance->GetData(TYPE_HODIR) == NOT_STARTED) - if (Creature* hodir = ObjectAccessor::GetCreature(*me, pInstance->GetData64(TYPE_HODIR))) + if (Creature* hodir = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(TYPE_HODIR))) hodir->AI()->AttackStart(doneBy); } @@ -705,7 +705,7 @@ public: { if( GameObject* fire = me->FindNearestGameObject(194300, 1.0f) ) { - fire->SetOwnerGUID(0); + fire->SetOwnerGUID(ObjectGuid::Empty); fire->Delete(); } me->DespawnOrUnsummon(); // this will remove DynObjects @@ -783,7 +783,7 @@ public: { if( !me->HasAura(SPELL_FLASH_FREEZE_TRAPPED_NPC) ) if( pInstance ) - if( uint64 g = pInstance->GetData64(TYPE_HODIR) ) + if( ObjectGuid g = pInstance->GetGuidData(TYPE_HODIR) ) if( Creature* hodir = ObjectAccessor::GetCreature(*me, g) ) { AttackStart(hodir); @@ -816,7 +816,7 @@ public: void JustDied(Unit* /*killer*/) override { if (pInstance) - if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetData64(TYPE_HODIR))) + if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetGuidData(TYPE_HODIR))) hodir->AI()->SetData(4, 1); } }; @@ -879,7 +879,7 @@ public: { if( !me->HasAura(SPELL_FLASH_FREEZE_TRAPPED_NPC) ) if( pInstance ) - if( uint64 g = pInstance->GetData64(TYPE_HODIR) ) + if( ObjectGuid g = pInstance->GetGuidData(TYPE_HODIR) ) if( Creature* hodir = ObjectAccessor::GetCreature(*me, g) ) { AttackStart(hodir); @@ -913,7 +913,7 @@ public: void JustDied(Unit* /*killer*/) override { if (pInstance) - if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetData64(TYPE_HODIR))) + if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetGuidData(TYPE_HODIR))) hodir->AI()->SetData(4, 1); } }; @@ -983,7 +983,7 @@ public: { if( !me->HasAura(SPELL_FLASH_FREEZE_TRAPPED_NPC) ) if( pInstance ) - if( uint64 g = pInstance->GetData64(TYPE_HODIR) ) + if( ObjectGuid g = pInstance->GetGuidData(TYPE_HODIR) ) if( Creature* hodir = ObjectAccessor::GetCreature(*me, g) ) { AttackStart(hodir); @@ -1013,7 +1013,7 @@ public: void JustDied(Unit* /*killer*/) override { if (pInstance) - if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetData64(TYPE_HODIR))) + if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetGuidData(TYPE_HODIR))) hodir->AI()->SetData(4, 1); } }; @@ -1077,7 +1077,7 @@ public: { if( !me->HasAura(SPELL_FLASH_FREEZE_TRAPPED_NPC) ) if( pInstance ) - if( uint64 g = pInstance->GetData64(TYPE_HODIR) ) + if( ObjectGuid g = pInstance->GetGuidData(TYPE_HODIR) ) if( Creature* hodir = ObjectAccessor::GetCreature(*me, g) ) { AttackStart(hodir); @@ -1128,7 +1128,7 @@ public: void JustDied(Unit* /*killer*/) override { if (pInstance) - if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetData64(TYPE_HODIR))) + if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetGuidData(TYPE_HODIR))) hodir->AI()->SetData(4, 1); } }; @@ -1236,7 +1236,7 @@ public: { if (GetStackAmount() == 2) // increasing from 2 to 3 (not checking >= to improve performance) if (InstanceScript* pInstance = target->GetInstanceScript()) - if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetData64(TYPE_HODIR))) + if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetGuidData(TYPE_HODIR))) hodir->AI()->SetData(2, 1); ModStackAmount(1); counter = 0; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp index feaabcb277..a1451c2af3 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp @@ -115,7 +115,7 @@ public: me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetReactState(REACT_AGGRESSIVE); if (InstanceScript* instance = me->GetInstanceScript()) - if (Creature* ignis = ObjectAccessor::GetCreature(*me, instance->GetData64(TYPE_IGNIS))) + if (Creature* ignis = ObjectAccessor::GetCreature(*me, instance->GetGuidData(TYPE_IGNIS))) { ignis->CastSpell(ignis, SPELL_STRENGTH_OF_THE_CREATOR, true); AttackStart(ignis->GetVictim()); @@ -147,7 +147,7 @@ public: Unit::Kill(attacker, me); if (InstanceScript* instance = me->GetInstanceScript()) - if (Creature* ignis = ObjectAccessor::GetCreature(*me, instance->GetData64(TYPE_IGNIS))) + if (Creature* ignis = ObjectAccessor::GetCreature(*me, instance->GetGuidData(TYPE_IGNIS))) ignis->AI()->SetData(1337, 0); } } @@ -155,7 +155,7 @@ public: void JustDied(Unit* /*killer*/) override { if (InstanceScript* instance = me->GetInstanceScript()) - if (Creature* ignis = ObjectAccessor::GetCreature(*me, instance->GetData64(TYPE_IGNIS))) + if (Creature* ignis = ObjectAccessor::GetCreature(*me, instance->GetGuidData(TYPE_IGNIS))) ignis->RemoveAuraFromStack(SPELL_STRENGTH_OF_THE_CREATOR); } @@ -385,7 +385,7 @@ public: std::list<Creature*> icl; me->GetCreaturesWithEntryInRange(icl, 300.0f, NPC_IRON_CONSTRUCT); - std::vector<uint64> playerGUIDs; + GuidVector playerGUIDs; Map::PlayerList const& pl = me->GetMap()->GetPlayers(); Player* temp = nullptr; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index ad9bdb1066..6916703725 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp @@ -137,8 +137,7 @@ public: struct boss_kologarnAI : public ScriptedAI { - boss_kologarnAI(Creature* pCreature) : ScriptedAI(pCreature), vehicle(me->GetVehicleKit()), - _left(0), _right(0), summons(me), breathReady(false) + boss_kologarnAI(Creature* pCreature) : ScriptedAI(pCreature), vehicle(me->GetVehicleKit()), summons(me), breathReady(false) { m_pInstance = me->GetInstanceScript(); eyebeamTarget = nullptr; @@ -149,7 +148,7 @@ public: InstanceScript* m_pInstance; Vehicle* vehicle; - uint64 _left, _right; + ObjectGuid _left, _right; EventMap events; SummonList summons; @@ -323,7 +322,7 @@ public: // left arm if (who->GetGUID() == _left) { - _left = 0; + _left.Clear(); if (me->IsInCombat()) { Talk(SAY_LEFT_ARM_GONE); @@ -332,7 +331,7 @@ public: } else { - _right = 0; + _right.Clear(); if (me->IsInCombat()) { Talk(SAY_RIGHT_ARM_GONE); @@ -524,7 +523,7 @@ public: { if (!_combatStarted) if (InstanceScript* instance = me->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*me, instance->GetData64(TYPE_KOLOGARN))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, instance->GetGuidData(TYPE_KOLOGARN))) { _combatStarted = true; if (!cr->IsInCombat() && who) @@ -561,7 +560,7 @@ public: cr->CastSpell(cr, SPELL_RUBBLE_FALL, true); if (me->GetInstanceScript()) - if (Creature* kologarn = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_KOLOGARN))) + if (Creature* kologarn = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_KOLOGARN))) for (uint8 i = 0; i < 5; ++i) if (Creature* cr2 = kologarn->SummonCreature(NPC_RUBBLE_SUMMON, cr->GetPositionX() + irand(-5, 5), cr->GetPositionY() + irand(-5, 5), cr->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000)) { @@ -572,7 +571,7 @@ public: } if (me->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_KOLOGARN))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_KOLOGARN))) cr->AI()->DoAction(DATA_KOLOGARN_RUBBLE_ACHIEV); me->ExitVehicle(); @@ -605,7 +604,7 @@ public: if (damage > 0 && !_damaged && me->GetInstanceScript()) { _damaged = true; - if (Creature* cr = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_KOLOGARN))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_KOLOGARN))) cr->AI()->DoAction(DATA_KOLOGARN_LOOKS_ACHIEV); } } @@ -615,7 +614,7 @@ public: if (justSpawned) { me->DespawnOrUnsummon(10000); - if (Creature* cr = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(TYPE_KOLOGARN))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(TYPE_KOLOGARN))) { me->CastSpell(cr, me->GetEntry() == NPC_EYE_LEFT ? SPELL_FOCUSED_EYEBEAM_LEFT : SPELL_FOCUSED_EYEBEAM_RIGHT, true); } @@ -818,7 +817,7 @@ public: { if (target) if (InstanceScript* instance = target->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetData64(TYPE_KOLOGARN))) + if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetGuidData(TYPE_KOLOGARN))) return cr->AI()->GetData(DATA_KOLOGARN_LOOKS_ACHIEV); return false; @@ -834,7 +833,7 @@ public: { if (target) if (InstanceScript* instance = target->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetData64(TYPE_KOLOGARN))) + if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetGuidData(TYPE_KOLOGARN))) return cr->AI()->GetData(DATA_KOLOGARN_RUBBLE_ACHIEV); return false; @@ -850,7 +849,7 @@ public: { if (target) if (InstanceScript* instance = target->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetData64(TYPE_KOLOGARN))) + if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetGuidData(TYPE_KOLOGARN))) return cr->AI()->GetData(DATA_KOLOGARN_ARMS_ACHIEV); return false; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index 03de90070f..78b26ca828 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -267,10 +267,10 @@ enum ComputerTalks TALK_COMPUTER_ZERO = 12, }; -#define GetMimiron() ObjectAccessor::GetCreature(*me, pInstance->GetData64(TYPE_MIMIRON)) -#define GetLMK2() ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_MIMIRON_LEVIATHAN_MKII)) -#define GetVX001() ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_MIMIRON_VX001)) -#define GetACU() ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_MIMIRON_ACU)) +#define GetMimiron() ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(TYPE_MIMIRON)) +#define GetLMK2() ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_MIMIRON_LEVIATHAN_MKII)) +#define GetVX001() ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_MIMIRON_VX001)) +#define GetACU() ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_MIMIRON_ACU)) class boss_mimiron : public CreatureScript { @@ -779,7 +779,7 @@ public: if( pInstance ) for( uint16 i = 0; i < 3; ++i ) - if( uint64 guid = pInstance->GetData64(DATA_GO_MIMIRON_DOOR_1 + i) ) + if( ObjectGuid guid = pInstance->GetGuidData(DATA_GO_MIMIRON_DOOR_1 + i) ) if( GameObject* door = ObjectAccessor::GetGameObject(*me, guid) ) if( door->GetGoState() != GO_STATE_ACTIVE ) { @@ -862,7 +862,7 @@ public: { if( pInstance ) for( uint16 i = 0; i < 3; ++i ) - if( uint64 guid = pInstance->GetData64(DATA_GO_MIMIRON_DOOR_1 + i) ) + if( ObjectGuid guid = pInstance->GetGuidData(DATA_GO_MIMIRON_DOOR_1 + i) ) if( GameObject* door = ObjectAccessor::GetGameObject(*me, guid) ) if( door->GetGoState() != GO_STATE_ACTIVE ) { @@ -893,7 +893,7 @@ public: { if( pInstance ) for( uint16 i = 0; i < 3; ++i ) - if( uint64 guid = pInstance->GetData64(DATA_GO_MIMIRON_DOOR_1 + i) ) + if( ObjectGuid guid = pInstance->GetGuidData(DATA_GO_MIMIRON_DOOR_1 + i) ) if( GameObject* door = ObjectAccessor::GetGameObject(*me, guid) ) if( door->GetGoState() != GO_STATE_READY ) { @@ -2257,7 +2257,7 @@ public: if(instance->GetData(TYPE_MIMIRON) != NOT_STARTED) return false; - if (Creature* c = ObjectAccessor::GetCreature(*go, instance->GetData64(TYPE_MIMIRON))) + if (Creature* c = ObjectAccessor::GetCreature(*go, instance->GetGuidData(TYPE_MIMIRON))) { c->AI()->SetData(0, 7); c->AI()->AttackStart(player); @@ -2292,7 +2292,7 @@ public: } } - std::list<uint64> FlameList; + GuidList FlameList; EventMap events; uint32 CreateTime; @@ -2314,15 +2314,15 @@ public: } } - void RemoveFlame(uint64 guid) + void RemoveFlame(ObjectGuid guid) { FlameList.remove(guid); } void RemoveAll() { - for( std::list<uint64>::iterator itr = FlameList.begin(); itr != FlameList.end(); ++itr ) - if (Creature* c = ObjectAccessor::GetCreature(*me, (*itr))) + for (ObjectGuid guid : FlameList) + if (Creature* c = ObjectAccessor::GetCreature(*me, guid)) c->DespawnOrUnsummon(); FlameList.clear(); me->DespawnOrUnsummon(); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp index b6596e2384..3d4f7c06ce 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp @@ -127,8 +127,8 @@ public: InstanceScript* pInstance; EventMap events; SummonList summons; - uint64 ExpeditionEngineerGUIDs[3]; - uint64 CommanderGUID; + ObjectGuid ExpeditionEngineerGUIDs[3]; + ObjectGuid CommanderGUID; float cords[4][2]; bool bGroundPhase; bool startPath; @@ -138,8 +138,11 @@ public: { events.Reset(); summons.DespawnAll(); - memset(&ExpeditionEngineerGUIDs, 0, sizeof(ExpeditionEngineerGUIDs)); - CommanderGUID = 0; + + for (uint8 i = 0; i < 3; ++i) + ExpeditionEngineerGUIDs[i].Clear(); + + CommanderGUID.Clear(); bGroundPhase = false; flyTimes = 0; @@ -206,11 +209,11 @@ public: case SPELL_LAUNCH_CHAIN: { uint32 spell = 0; - if( caster->GetGUID() == pInstance->GetData64(DATA_HARPOON_FIRE_STATE_1) ) + if( caster->GetGUID() == pInstance->GetGuidData(DATA_HARPOON_FIRE_STATE_1) ) spell = SPELL_CHAIN_1; - else if( caster->GetGUID() == pInstance->GetData64(DATA_HARPOON_FIRE_STATE_2) ) + else if( caster->GetGUID() == pInstance->GetGuidData(DATA_HARPOON_FIRE_STATE_2) ) spell = SPELL_CHAIN_2; - else if( caster->GetGUID() == pInstance->GetData64(DATA_HARPOON_FIRE_STATE_3) ) + else if( caster->GetGUID() == pInstance->GetGuidData(DATA_HARPOON_FIRE_STATE_3) ) spell = SPELL_CHAIN_3; else spell = SPELL_CHAIN_4; @@ -243,7 +246,7 @@ public: events.CancelEvent(EVENT_SPELL_FIREBALL); events.CancelEvent(EVENT_SPELL_DEVOURING_FLAME); events.CancelEvent(EVENT_SUMMON_MOLE_MACHINES); - me->SetTarget(0); + me->SetTarget(); me->SendMeleeAttackStop(me->GetVictim()); me->GetMotionMaster()->MoveLand(0, CORDS_GROUND, 25.0f); } @@ -444,7 +447,7 @@ public: me->SetInCombatWithZone(); // just in case if (pInstance) for( int i = 0; i < 4; ++i ) - if( uint64 guid = pInstance->GetData64(DATA_HARPOON_FIRE_STATE_1 + i) ) + if( ObjectGuid guid = pInstance->GetGuidData(DATA_HARPOON_FIRE_STATE_1 + i) ) if( Creature* hfs = ObjectAccessor::GetCreature(*me, guid) ) { me->SummonCreature(34188, hfs->GetPositionX(), hfs->GetPositionY(), hfs->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 22000); @@ -594,7 +597,7 @@ public: if (instance->GetData(TYPE_RAZORSCALE) == DONE) return true; - Creature* razorscale = ObjectAccessor::GetCreature(*creature, instance->GetData64(TYPE_RAZORSCALE)); + Creature* razorscale = ObjectAccessor::GetCreature(*creature, instance->GetGuidData(TYPE_RAZORSCALE)); if (!razorscale || razorscale->IsInCombat()) return true; @@ -614,12 +617,12 @@ public: if (!instance || instance->GetData(TYPE_RAZORSCALE) == DONE) return true; - Creature* razorscale = ObjectAccessor::GetCreature(*creature, instance->GetData64(TYPE_RAZORSCALE)); + Creature* razorscale = ObjectAccessor::GetCreature(*creature, instance->GetGuidData(TYPE_RAZORSCALE)); if (razorscale && !razorscale->IsInCombat()) { // reset npcs NPC_HARPOON_FIRE_STATE for (uint8 i = 0; i < 4; ++i) - if (Creature* hfs = ObjectAccessor::GetCreature(*creature, instance->GetData64(DATA_HARPOON_FIRE_STATE_1 + i))) + if (Creature* hfs = ObjectAccessor::GetCreature(*creature, instance->GetGuidData(DATA_HARPOON_FIRE_STATE_1 + i))) hfs->AI()->SetData(1, 0); if (razorscale->AI()) @@ -696,11 +699,11 @@ public: { if (pInstance) { - if( me->GetGUID() == pInstance->GetData64(DATA_HARPOON_FIRE_STATE_1) ) + if( me->GetGUID() == pInstance->GetGuidData(DATA_HARPOON_FIRE_STATE_1) ) return GO_HARPOON_GUN_1; - else if( me->GetGUID() == pInstance->GetData64(DATA_HARPOON_FIRE_STATE_2) ) + else if( me->GetGUID() == pInstance->GetGuidData(DATA_HARPOON_FIRE_STATE_2) ) return GO_HARPOON_GUN_2; - else if( me->GetGUID() == pInstance->GetData64(DATA_HARPOON_FIRE_STATE_3) ) + else if( me->GetGUID() == pInstance->GetGuidData(DATA_HARPOON_FIRE_STATE_3) ) return GO_HARPOON_GUN_3; else return GO_HARPOON_GUN_4; @@ -745,7 +748,7 @@ public: case 3: // shoot if (pInstance) { - Creature* razorscale = ObjectAccessor::GetCreature(*me, pInstance->GetData64(TYPE_RAZORSCALE)); + Creature* razorscale = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(TYPE_RAZORSCALE)); if (!razorscale) return; if (!razorscale->HasAura(value)) @@ -787,13 +790,13 @@ public: InstanceScript* pInstance; bool working; uint16 timer; - uint64 fixingGUID; + ObjectGuid fixingGUID; void Reset() override { working = false; timer = 0; - fixingGUID = 0; + fixingGUID.Clear(); } void SetData(uint32 id, uint32 /*value*/) override @@ -803,7 +806,7 @@ public: case 1: // start/resume repairing working = true; timer = 0; - fixingGUID = 0; + fixingGUID.Clear(); break; case 2: // stop repairing Reset(); @@ -834,14 +837,14 @@ public: c->AI()->SetData(2, 0); if (c->AI()->GetData(2)) - fixingGUID = 0; + fixingGUID.Clear(); } } if (!fixingGUID) { Creature* razorscale = nullptr; - if( uint64 rsGUID = pInstance->GetData64(TYPE_RAZORSCALE) ) + if( ObjectGuid rsGUID = pInstance->GetGuidData(TYPE_RAZORSCALE) ) razorscale = ObjectAccessor::GetCreature(*me, rsGUID); if( !razorscale || !razorscale->IsInCombat() ) @@ -852,7 +855,7 @@ public: } for( int i = 0; i < 4; ++i ) - if( uint64 fs_GUID = pInstance->GetData64(DATA_HARPOON_FIRE_STATE_1 + i) ) + if( ObjectGuid fs_GUID = pInstance->GetGuidData(DATA_HARPOON_FIRE_STATE_1 + i) ) if( Creature* fs = ObjectAccessor::GetCreature(*me, fs_GUID) ) if (!fs->AI()->GetData(2)) { @@ -890,7 +893,7 @@ public: return true; Creature* rs = nullptr; - if( uint64 rsGUID = pInstance->GetData64(TYPE_RAZORSCALE) ) + if( ObjectGuid rsGUID = pInstance->GetGuidData(TYPE_RAZORSCALE) ) rs = ObjectAccessor::GetCreature(*go, rsGUID); if( !rs || !rs->IsInCombat() ) @@ -922,7 +925,7 @@ public: break; } - if( uint64 g = pInstance->GetData64(npc) ) + if( ObjectGuid g = pInstance->GetGuidData(npc) ) if( Creature* hfs = ObjectAccessor::GetCreature(*go, g) ) hfs->AI()->SetData(3, spell); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp index 396f4aae50..ca42eb81cd 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp @@ -355,7 +355,7 @@ public: GameObject* GetThorimObject(uint32 entry) { if (m_pInstance) - return ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(entry)); + return ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(entry)); return nullptr; } @@ -845,7 +845,7 @@ public: else if (param == ACTION_SIF_START_DOMINION) { if (me->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_THORIM))) + if (Creature* cr = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_THORIM))) me->CastSpell(cr, SPELL_TOUCH_OF_DOMINION, false); events.ScheduleEvent(EVENT_SIF_FINISH_DOMINION, 150000); @@ -938,7 +938,7 @@ public: { InitWaypoint(); Reset(); - Start(false, true, 0); + Start(false, true); } uint32 Timer; @@ -1024,7 +1024,7 @@ public: { InitWaypoint(); Reset(); - Start(false, true, 0); + Start(false, true); SetDespawnAtEnd(false); } @@ -1130,10 +1130,10 @@ public: void DamageTaken(Unit* who, uint32&, DamageEffectType, SpellSchoolMask) override { - if (!_playerAttack && who && (who->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(who->GetOwnerGUID()))) + if (!_playerAttack && who && (who->GetTypeId() == TYPEID_PLAYER || who->GetOwnerGUID().IsPlayer())) { if (me->GetInstanceScript()) - if (Creature* thorim = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_THORIM))) + if (Creature* thorim = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_THORIM))) { if (!thorim->IsInCombat()) { @@ -1154,7 +1154,7 @@ public: void JustDied(Unit*) override { if (me->GetInstanceScript()) - if (Creature* thorim = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_THORIM))) + if (Creature* thorim = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_THORIM))) thorim->AI()->DoAction(ACTION_START_TRASH_DIED); } @@ -1379,7 +1379,7 @@ public: bool _leftHand; bool _checkTarget; float _nextTriggerPos; - uint64 _triggerLeftGUID[2], _triggerRightGUID[2]; + ObjectGuid _triggerLeftGUID[2], _triggerRightGUID[2]; void Reset() override { @@ -1404,7 +1404,7 @@ public: void JustDied(Unit*) override { if (me->GetInstanceScript()) - if (GameObject* go = ObjectAccessor::GetGameObject(*me, me->GetInstanceScript()->GetData64(DATA_THORIM_FIRST_DOORS))) + if (GameObject* go = ObjectAccessor::GetGameObject(*me, me->GetInstanceScript()->GetGuidData(DATA_THORIM_FIRST_DOORS))) go->SetGoState(GO_STATE_ACTIVE); } @@ -1533,10 +1533,10 @@ public: { if (InstanceScript* pInstance = me->GetInstanceScript()) { - if (GameObject* go = ObjectAccessor::GetGameObject(*me, pInstance->GetData64(DATA_THORIM_SECOND_DOORS))) + if (GameObject* go = ObjectAccessor::GetGameObject(*me, pInstance->GetGuidData(DATA_THORIM_SECOND_DOORS))) go->SetGoState(GO_STATE_ACTIVE); - if (Creature* thorim = ObjectAccessor::GetCreature(*me, pInstance->GetData64(TYPE_THORIM))) + if (Creature* thorim = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(TYPE_THORIM))) thorim->AI()->DoAction(ACTION_ALLOW_HIT); } } @@ -1805,7 +1805,7 @@ public: bool OnCheck(Player* player, Unit*) override { if (InstanceScript* instance = player->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*player, instance->GetData64(TYPE_THORIM))) + if (Creature* cr = ObjectAccessor::GetCreature(*player, instance->GetGuidData(TYPE_THORIM))) return cr->AI()->GetData(DATA_HIT_BY_LIGHTNING); return false; @@ -1820,7 +1820,7 @@ public: bool OnCheck(Player* player, Unit*) override { if (InstanceScript* instance = player->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*player, instance->GetData64(TYPE_THORIM))) + if (Creature* cr = ObjectAccessor::GetCreature(*player, instance->GetGuidData(TYPE_THORIM))) return cr->AI()->GetData(DATA_LOSE_YOUR_ILLUSION); return false; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp index 5b3170dc97..015f781928 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp @@ -160,7 +160,7 @@ public: { m_pInstance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEVEMENT_MUST_DECONSTRUCT_FASTER); m_pInstance->SetData(TYPE_XT002, NOT_STARTED); - if (GameObject* pGo = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(GO_XT002_DOORS))) + if (GameObject* pGo = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(GO_XT002_DOORS))) pGo->SetGoState(GO_STATE_ACTIVE); } } @@ -197,7 +197,7 @@ public: { m_pInstance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEVEMENT_MUST_DECONSTRUCT_FASTER); m_pInstance->SetData(TYPE_XT002, IN_PROGRESS); - if (GameObject* pGo = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(GO_XT002_DOORS))) + if (GameObject* pGo = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(GO_XT002_DOORS))) pGo->SetGoState(GO_STATE_READY); } @@ -231,7 +231,7 @@ public: if (m_pInstance) { m_pInstance->SetData(TYPE_XT002, DONE); - if (GameObject* pGo = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(GO_XT002_DOORS))) + if (GameObject* pGo = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(GO_XT002_DOORS))) pGo->SetGoState(GO_STATE_ACTIVE); } @@ -458,7 +458,7 @@ public: } else if (param == ACTION_HIDE_HEART) { - if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_XT002))) + if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_XT002))) if (pXT002->AI()) { pXT002->AI()->DoAction(_damageDone); @@ -524,7 +524,7 @@ public: { me->SetVisible(false); if (me->GetInstanceScript()) - if (Creature* XT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_XT002))) + if (Creature* XT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_XT002))) if (XT002->AI()) XT002->AI()->DoAction(ACTION_HEART_BROKEN); } @@ -566,7 +566,7 @@ public: me->SetWalk(true); if (me->GetInstanceScript()) - if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_XT002))) + if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_XT002))) { if (pXT002->GetPositionZ() > 411.0f) // he is on stairs... idiot cryness protection me->GetMotionMaster()->MovePoint(0, 884.028931f, -14.593809f, 409.786987f); @@ -597,7 +597,7 @@ public: // we reached the target :) if (type == FOLLOW_MOTION_TYPE && me->GetInstanceScript()) - if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_XT002))) + if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_XT002))) { if (pXT002->IsAlive()) { @@ -617,7 +617,7 @@ public: if (!_locked) { if (me->GetInstanceScript()) - if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_XT002))) + if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_XT002))) { me->GetMotionMaster()->MoveFollow(pXT002, 0.0f, 0.0f); _locked = true; @@ -737,7 +737,7 @@ public: me->SetUnitMovementFlags(MOVEMENTFLAG_WALKING); if (me->GetInstanceScript()) - if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_XT002))) + if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_XT002))) { if (pXT002->GetPositionZ() > 411.0f) // he is on stairs... idiot cryness protection me->GetMotionMaster()->MovePoint(0, 884.028931f, -14.593809f, 409.786987f); @@ -754,8 +754,8 @@ public: _boomed = true; // Prevent recursive calls WorldPacket data(SMSG_SPELLINSTAKILLLOG, 8 + 8 + 4); - data << uint64(me->GetGUID()); - data << uint64(me->GetGUID()); + data << me->GetGUID(); + data << me->GetGUID(); data << uint32(SPELL_BOOM); me->SendMessageToSet(&data, false); @@ -804,7 +804,7 @@ public: if (!_locked) { if (me->GetInstanceScript()) - if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_XT002))) + if (Creature* pXT002 = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_XT002))) { me->GetMotionMaster()->MoveFollow(pXT002, 0.0f, 0.0f); _locked = true; @@ -1047,7 +1047,7 @@ public: { if (target) if (InstanceScript* instance = target->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetData64(TYPE_XT002))) + if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetGuidData(TYPE_XT002))) return cr->AI()->GetData(DATA_XT002_NERF_ENGINEERING); return false; @@ -1063,7 +1063,7 @@ public: { if (target) if (InstanceScript* instance = target->GetInstanceScript()) - if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetData64(TYPE_XT002))) + if (Creature* cr = ObjectAccessor::GetCreature(*target, instance->GetGuidData(TYPE_XT002))) return cr->AI()->GetData(DATA_XT002_GRAVITY_ACHIEV); return false; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp index 9c2e106918..7684f2b0de 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp @@ -341,7 +341,7 @@ public: SummonList summons; uint32 _initFight; - uint64 _keepersGUID[4]; + ObjectGuid _keepersGUID[4]; uint8 _summonedGuardiansCount; uint32 _p2TalkTimer; bool _secondPhase; @@ -427,7 +427,10 @@ public: SpawnClouds(); _initFight = 1; - memset(_keepersGUID, 0, sizeof(_keepersGUID)); + + for (uint8 i = 0; i < 4; ++i) + _keepersGUID[i].Clear(); + _summonedGuardiansCount = 0; _p2TalkTimer = 0; _secondPhase = false; @@ -440,7 +443,7 @@ public: m_pInstance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, CRITERIA_NOT_GETTING_OLDER); m_pInstance->DoRemoveAurasDueToSpellOnPlayers(SPELL_SANITY); m_pInstance->SetData(TYPE_YOGGSARON, NOT_STARTED); - if (GameObject* go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(GO_YOGG_SARON_DOORS))) + if (GameObject* go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(GO_YOGG_SARON_DOORS))) go->SetGoState(GO_STATE_ACTIVE); } } @@ -766,7 +769,7 @@ public: me->SummonCreature(NPC_VOICE_OF_YOGG_SARON, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); if (m_pInstance) - if (GameObject* go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(GO_YOGG_SARON_DOORS))) + if (GameObject* go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(GO_YOGG_SARON_DOORS))) go->SetGoState(GO_STATE_READY); events.ScheduleEvent(EVENT_SARA_P1_SPELLS, 0, 1, EVENT_PHASE_ONE); @@ -883,7 +886,7 @@ public: { InitWaypoint(); Reset(); - Start(false, true, 0, 0, false, true); + Start(false, true, ObjectGuid::Empty, nullptr, false, true); } uint32 _checkTimer; @@ -895,7 +898,7 @@ public: _isSummoning = false; if (me->GetInstanceScript()) - if (Creature* sara = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(NPC_SARA))) + if (Creature* sara = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(NPC_SARA))) sara->AI()->JustSummoned(cr); } @@ -1069,9 +1072,9 @@ public: if (m_pInstance) { m_pInstance->SetData(TYPE_YOGGSARON, DONE); - if (Creature* sara = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(NPC_SARA))) + if (Creature* sara = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(NPC_SARA))) sara->AI()->DoAction(ACTION_YOGG_SARON_DEATH); - if (GameObject* go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetData64(GO_YOGG_SARON_DOORS))) + if (GameObject* go = ObjectAccessor::GetGameObject(*me, m_pInstance->GetGuidData(GO_YOGG_SARON_DOORS))) go->SetGoState(GO_STATE_ACTIVE); } @@ -1345,7 +1348,7 @@ public: { // Stun if (me->GetInstanceScript()) - if(Creature* sara = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(NPC_SARA))) + if(Creature* sara = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(NPC_SARA))) sara->AI()->DoAction(MINUTE * IN_MILLISECONDS - std::min((uint32)MINUTE * IN_MILLISECONDS, _induceTimer)); _induceTimer = 0; @@ -1412,7 +1415,7 @@ public: me->CastSpell(me, SPELL_BRAIN_HURT_VISUAL, true); if (me->GetInstanceScript()) - if(Creature* sara = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(NPC_SARA))) + if(Creature* sara = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(NPC_SARA))) sara->AI()->DoAction(ACTION_BRAIN_DAMAGED); } } @@ -1601,11 +1604,11 @@ public: { SetCombatMovement(false); _checkTimer = 1; - _playerGUID = 0; + _playerGUID.Clear(); } uint32 _checkTimer; - uint64 _playerGUID; + ObjectGuid _playerGUID; Unit* SelectConstrictTarget() { @@ -1877,17 +1880,17 @@ public: bool _running; int32 _checkTimer; uint8 _step; - uint64 _championGUID; - uint64 _yoggGUID; + ObjectGuid _championGUID; + ObjectGuid _yoggGUID; void Reset() override { _running = true; _checkTimer = 0; _step = 0; - _championGUID = 0; + _championGUID.Clear(); if (me->GetInstanceScript()) - _yoggGUID = me->GetInstanceScript()->GetData64(TYPE_YOGGSARON); + _yoggGUID = me->GetInstanceScript()->GetGuidData(TYPE_YOGGSARON); } void NextStep(const uint32 time) @@ -1896,7 +1899,7 @@ public: _checkTimer = time; } - void Say(std::string text, uint64 guid, bool yell, uint32 soundId) + void Say(std::string text, ObjectGuid guid, bool yell, uint32 soundId) { Creature* creature = guid ? ObjectAccessor::GetCreature(*me, guid) : me; if (!creature) @@ -1946,7 +1949,7 @@ public: case 1: if (Creature* cr = me->FindNearestCreature(NPC_IMMOLATED_CHAMPION, 50)) _championGUID = cr->GetGUID(); - Say("Your resilience is admirable.", 0, false, LK_1); + Say("Your resilience is admirable.", ObjectGuid::Empty, false, LK_1); NextStep(7000); break; case 2: @@ -1958,7 +1961,7 @@ public: NextStep(6500); break; case 4: - Say("I will break you as I broke him.", 0, false, LK_2); + Say("I will break you as I broke him.", ObjectGuid::Empty, false, LK_2); NextStep(7500); break; case 5: @@ -1991,17 +1994,17 @@ public: bool _running; int32 _checkTimer; uint8 _step; - uint64 _garonaGUID; - uint64 _yoggGUID; + ObjectGuid _garonaGUID; + ObjectGuid _yoggGUID; void Reset() override { _running = true; _checkTimer = 0; _step = 0; - _garonaGUID = 0; + _garonaGUID.Clear(); if (me->GetInstanceScript()) - _yoggGUID = me->GetInstanceScript()->GetData64(TYPE_YOGGSARON); + _yoggGUID = me->GetInstanceScript()->GetGuidData(TYPE_YOGGSARON); } void NextStep(const uint32 time) @@ -2010,7 +2013,7 @@ public: _checkTimer = time; } - void Say(std::string text, uint64 guid, bool yell, uint32 soundId) + void Say(std::string text, ObjectGuid guid, bool yell, uint32 soundId) { Creature* creature = guid ? ObjectAccessor::GetCreature(*me, guid) : me; if (!creature) @@ -2080,7 +2083,7 @@ public: NextStep(2500); break; case 6: - Say("We will hold until the reinforcements come. As long as men with stout hearts are manning the walls and throne Stormwind will hold.", 0, false, LL_1); + Say("We will hold until the reinforcements come. As long as men with stout hearts are manning the walls and throne Stormwind will hold.", ObjectGuid::Empty, false, LL_1); NextStep(10000); break; case 7: @@ -2113,7 +2116,7 @@ public: bool _running; int32 _checkTimer; uint8 _step; - uint64 _yoggGUID; + ObjectGuid _yoggGUID; void Reset() override { @@ -2121,7 +2124,7 @@ public: _checkTimer = 0; _step = 0; if (me->GetInstanceScript()) - _yoggGUID = me->GetInstanceScript()->GetData64(TYPE_YOGGSARON); + _yoggGUID = me->GetInstanceScript()->GetGuidData(TYPE_YOGGSARON); } void NextStep(const uint32 time) @@ -2130,9 +2133,9 @@ public: _checkTimer = time; } - void Say(std::string text, uint64 guid, bool yell, uint32 soundId) + void Say(std::string text, ObjectGuid guid, bool yell, uint32 soundId) { - Creature* creature = guid ? ObjectAccessor::GetCreature(*me, guid) : me; + Creature* creature = !guid ? ObjectAccessor::GetCreature(*me, guid) : me; if (!creature) return; @@ -2178,7 +2181,7 @@ public: NextStep(5000); break; case 1: - Say("It is done... All have been given that which must be given. I now seal the Dragon Soul forever...", 0, false, NEL_1); + Say("It is done... All have been given that which must be given. I now seal the Dragon Soul forever...", ObjectGuid::Empty, false, NEL_1); NextStep(10000); break; case 2: @@ -2187,7 +2190,7 @@ public: NextStep(4000); break; case 3: - Say("For it to be as it must, yes.", 0, false, NEL_2); + Say("For it to be as it must, yes.", ObjectGuid::Empty, false, NEL_2); NextStep(4000); break; case 4: @@ -2223,7 +2226,7 @@ public: } EventMap events; - std::vector<uint64> _targets; + GuidVector _targets; uint32 _current; void Reset() override @@ -2237,7 +2240,7 @@ public: { // Drive Me Crazy achievement failed if (me->GetInstanceScript()) - if (Creature* yogg = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(TYPE_YOGGSARON))) + if (Creature* yogg = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(TYPE_YOGGSARON))) yogg->AI()->DoAction(ACTION_FAILED_DRIVE_ME_CRAZY); events.ScheduleEvent(40, 8000); @@ -2252,7 +2255,7 @@ public: { case 40: { - uint64 _guid = _targets.at(_current); + ObjectGuid _guid = _targets.at(_current); ++_current; if (Player* player = ObjectAccessor::GetPlayer(*me, _guid)) @@ -2365,7 +2368,7 @@ public: } protected: - uint64 _targetGUID; + ObjectGuid _targetGUID; }; AuraScript* GetAuraScript() const override @@ -2969,7 +2972,7 @@ public: bool OnCheck(Player* player, Unit* /*target*/ /*Yogg-Saron*/) override { if (player->GetInstanceScript()) - if (Creature* sara = ObjectAccessor::GetCreature(*player, player->GetInstanceScript()->GetData64(NPC_SARA))) + if (Creature* sara = ObjectAccessor::GetCreature(*player, player->GetInstanceScript()->GetGuidData(NPC_SARA))) return sara->GetAI()->GetData(DATA_GET_KEEPERS_COUNT) <= _keepersCount; return false; @@ -2990,7 +2993,7 @@ public: bool OnCheck(Player* player, Unit* /*target*/ /*Yogg-Saron*/) override { if (player->GetInstanceScript()) - if (Creature* sara = ObjectAccessor::GetCreature(*player, player->GetInstanceScript()->GetData64(NPC_BRAIN_OF_YOGG_SARON))) + if (Creature* sara = ObjectAccessor::GetCreature(*player, player->GetInstanceScript()->GetGuidData(NPC_BRAIN_OF_YOGG_SARON))) return sara->GetAI()->GetData(DATA_GET_CURRENT_ILLUSION) == _requiredIllusion; return false; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp index 1adb913a5f..07932190c3 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp @@ -37,164 +37,111 @@ public: int m_difficulty; // Bosses - uint64 m_uiLeviathanGUID; - uint64 m_uiIgnisGUID; - uint64 m_uiRazorscaleGUID; - uint64 m_uiXT002GUID; - uint64 m_auiAssemblyGUIDs[3]; - uint64 m_uiKologarnGUID; - uint64 m_uiAuriayaGUID; - uint64 m_uiMimironGUID; - uint64 m_uiHodirGUID; - uint64 m_uiThorimGUID; - uint64 m_uiFreyaGUID; - uint64 m_uiVezaxGUID; - uint64 m_uiYoggSaronGUID; - uint64 m_uiAlgalonGUID; + ObjectGuid m_uiLeviathanGUID; + ObjectGuid m_uiIgnisGUID; + ObjectGuid m_uiRazorscaleGUID; + ObjectGuid m_uiXT002GUID; + ObjectGuid m_auiAssemblyGUIDs[3]; + ObjectGuid m_uiKologarnGUID; + ObjectGuid m_uiAuriayaGUID; + ObjectGuid m_uiMimironGUID; + ObjectGuid m_uiHodirGUID; + ObjectGuid m_uiThorimGUID; + ObjectGuid m_uiFreyaGUID; + ObjectGuid m_uiVezaxGUID; + ObjectGuid m_uiYoggSaronGUID; + ObjectGuid m_uiAlgalonGUID; // Flame Leviathan - uint64 m_leviathanDoorsGUID; - uint64 m_leviathanVisualTowers[4][2]; - uint64 m_RepairSGUID[2]; - uint64 m_lightningWalls[2]; + ObjectGuid m_leviathanDoorsGUID; + ObjectGuid m_leviathanVisualTowers[4][2]; + ObjectGuid m_RepairSGUID[2]; + ObjectGuid m_lightningWalls[2]; bool m_leviathanTowers[4]; - std::list<uint64> _leviathanVehicles; + GuidList _leviathanVehicles; uint32 m_unbrokenAchievement; uint32 m_mageBarrier; // Razorscale - uint64 m_RazorscaleHarpoonFireStateGUID[4]; + ObjectGuid m_RazorscaleHarpoonFireStateGUID[4]; // XT-002 - uint64 m_xt002DoorsGUID; + ObjectGuid m_xt002DoorsGUID; // Kologarn - uint64 KologarnDoorGUID; + ObjectGuid KologarnDoorGUID; // Assembly of Iron - uint64 m_assemblyDoorsGUID; - uint64 m_archivumDoorsGUID; + ObjectGuid m_assemblyDoorsGUID; + ObjectGuid m_archivumDoorsGUID; // Thorim - uint64 m_thorimGameobjectsGUID[5]; + ObjectGuid m_thorimGameobjectsGUID[5]; // Hodir's chests bool hmHodir; - uint64 m_hodirNormalChest; - uint64 m_hodirHardmodeChest; + ObjectGuid m_hodirNormalChest; + ObjectGuid m_hodirHardmodeChest; Position normalChestPosition = { 1967.152588f, -204.188461f, 432.686951f, 5.50957f }; Position hardChestPosition = { 2035.94600f, -202.084885f, 432.686859f, 3.164077f }; // Mimiron - uint64 m_MimironDoor[3]; - uint64 m_MimironLeviathanMKIIguid; - uint64 m_MimironVX001guid; - uint64 m_MimironACUguid; + ObjectGuid m_MimironDoor[3]; + ObjectGuid m_MimironLeviathanMKIIguid; + ObjectGuid m_MimironVX001guid; + ObjectGuid m_MimironACUguid; // Freya - uint64 m_FreyaElder[3]; + ObjectGuid m_FreyaElder[3]; uint32 m_conspeedatoryAttempt; // Yogg-Saron - uint64 m_saraGUID; - uint64 m_yoggsaronBrainGUID; - uint64 m_yoggsaronDoorsGUID; + ObjectGuid m_saraGUID; + ObjectGuid m_yoggsaronBrainGUID; + ObjectGuid m_yoggsaronDoorsGUID; // Algalon - uint64 m_algalonSigilDoorGUID[3]; - uint64 m_algalonFloorGUID[2]; - uint64 m_algalonUniverseGUID; - uint64 m_algalonTrapdoorGUID; - uint64 m_brannBronzebeardAlgGUID; - uint64 m_brannBronzebeardBaseCamp; + ObjectGuid m_algalonSigilDoorGUID[3]; + ObjectGuid m_algalonFloorGUID[2]; + ObjectGuid m_algalonUniverseGUID; + ObjectGuid m_algalonTrapdoorGUID; + ObjectGuid m_brannBronzebeardAlgGUID; + ObjectGuid m_brannBronzebeardBaseCamp; uint32 m_algalonTimer; // Shared EventMap _events; bool m_mimironTramUsed; - uint64 m_mimironTramGUID; - uint64 m_keepersgateGUID; - uint64 m_keepersGossipGUID[4]; + ObjectGuid m_mimironTramGUID; + ObjectGuid m_keepersgateGUID; + ObjectGuid m_keepersGossipGUID[4]; void Initialize() override { // Bosses memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); C_of_Ulduar_MASK = 0; - memset(&m_auiAssemblyGUIDs, 0, sizeof(m_auiAssemblyGUIDs)); - m_uiLeviathanGUID = 0; - m_uiIgnisGUID = 0; - m_uiRazorscaleGUID = 0; - m_uiXT002GUID = 0; - m_uiKologarnGUID = 0; - m_uiAuriayaGUID = 0; - m_uiMimironGUID = 0; - m_uiHodirGUID = 0; - m_uiThorimGUID = 0; - m_uiFreyaGUID = 0; - m_uiVezaxGUID = 0; - m_uiYoggSaronGUID = 0; - m_uiAlgalonGUID = 0; // Flame Leviathan - memset(&m_leviathanTowers, 1, sizeof(m_leviathanTowers)); - memset(&m_leviathanVisualTowers, 0, sizeof(m_leviathanVisualTowers)); - memset(&m_RepairSGUID, 0, sizeof(m_RepairSGUID)); - memset(&m_lightningWalls, 0, sizeof(m_lightningWalls)); - m_leviathanDoorsGUID = 0; + for (uint8 i = 0; i < 4; ++i) + m_leviathanTowers[i] = false; + _leviathanVehicles.clear(); m_unbrokenAchievement = 1; m_mageBarrier = 0; - m_brannBronzebeardBaseCamp = 0; - - // Razorscale - memset(&m_RazorscaleHarpoonFireStateGUID, 0, sizeof(m_RazorscaleHarpoonFireStateGUID)); - - // XT-002 - m_xt002DoorsGUID = 0; - - // Kologarn Door - // Assembly of Iron - m_assemblyDoorsGUID = 0; - m_archivumDoorsGUID = 0; - - // Thorim - memset(&m_thorimGameobjectsGUID, 0, sizeof(m_thorimGameobjectsGUID)); // Hodir - m_hodirNormalChest = 0; - m_hodirHardmodeChest = 0; hmHodir = true; // If players fail the Hardmode then becomes false - // Mimiron - memset(&m_MimironDoor, 0, sizeof(m_MimironDoor)); - m_MimironLeviathanMKIIguid = 0; - m_MimironVX001guid = 0; - m_MimironACUguid = 0; - // Freya - memset(&m_FreyaElder, 0, sizeof(m_FreyaElder)); m_conspeedatoryAttempt = 0; - // Yogg-Saron - m_saraGUID = 0; - m_yoggsaronBrainGUID = 0; - m_yoggsaronDoorsGUID = 0; - // Algalon - memset(&m_algalonSigilDoorGUID, 0, sizeof(m_algalonSigilDoorGUID)); - memset(&m_algalonFloorGUID, 0, sizeof(m_algalonFloorGUID)); - m_algalonUniverseGUID = 0; - m_algalonTrapdoorGUID = 0; - m_brannBronzebeardAlgGUID = 0; m_algalonTimer = 0; // Shared _events.Reset(); - memset(&m_keepersGossipGUID, 0, sizeof(m_keepersGossipGUID)); m_mimironTramUsed = false; - m_mimironTramGUID = 0; - m_keepersgateGUID = 0; } void FillInitialWorldStates(WorldPacket& packet) override @@ -457,7 +404,7 @@ public: { case NPC_BRANN_BRONZBEARD_ALG: if (m_brannBronzebeardAlgGUID == creature->GetGUID()) - m_brannBronzebeardAlgGUID = 0; + m_brannBronzebeardAlgGUID.Clear(); break; } } @@ -468,7 +415,7 @@ public: go->SetGoState(state); } - void ShowKeeperGossip(uint8 type, Creature* cr, uint64 guid = 0) + void ShowKeeperGossip(uint8 type, Creature* cr, ObjectGuid guid = ObjectGuid::Empty) { if (!cr) { @@ -739,7 +686,7 @@ public: { hmHodir = false; go->Delete(); - m_hodirHardmodeChest = 0; + m_hodirHardmodeChest.Clear(); } break; case TYPE_WATCHERS: @@ -788,27 +735,27 @@ public: return; case TYPE_ALGALON: m_auiEncounter[type] = data; - if (GameObject* go = instance->GetGameObject(GetData64(GO_DOODAD_UL_SIGILDOOR_03))) + if (GameObject* go = instance->GetGameObject(GetGuidData(GO_DOODAD_UL_SIGILDOOR_03))) { go->SetGoState(data != IN_PROGRESS ? GO_STATE_ACTIVE : GO_STATE_READY); go->EnableCollision(false); } - if (GameObject* go = instance->GetGameObject(GetData64(GO_DOODAD_UL_UNIVERSEFLOOR_01))) + if (GameObject* go = instance->GetGameObject(GetGuidData(GO_DOODAD_UL_UNIVERSEFLOOR_01))) { go->SetGoState(data != IN_PROGRESS ? GO_STATE_ACTIVE : GO_STATE_READY); go->EnableCollision(false); } - if (GameObject* go = instance->GetGameObject(GetData64(GO_DOODAD_UL_UNIVERSEFLOOR_02))) + if (GameObject* go = instance->GetGameObject(GetGuidData(GO_DOODAD_UL_UNIVERSEFLOOR_02))) { go->SetGoState(data == IN_PROGRESS ? GO_STATE_ACTIVE : GO_STATE_READY); go->EnableCollision(false); } - if (GameObject* go = instance->GetGameObject(GetData64(GO_DOODAD_UL_UNIVERSEGLOBE01))) + if (GameObject* go = instance->GetGameObject(GetGuidData(GO_DOODAD_UL_UNIVERSEGLOBE01))) { go->SetGoState(data == IN_PROGRESS ? GO_STATE_ACTIVE : GO_STATE_READY); go->EnableCollision(false); } - if (GameObject* go = instance->GetGameObject(GetData64(GO_DOODAD_UL_ULDUAR_TRAPDOOR_03))) + if (GameObject* go = instance->GetGameObject(GetGuidData(GO_DOODAD_UL_ULDUAR_TRAPDOOR_03))) { go->SetGoState(data == IN_PROGRESS ? GO_STATE_ACTIVE : GO_STATE_READY); go->EnableCollision(false); @@ -848,7 +795,7 @@ public: if (type == TYPE_FREYA && data == DONE) { std::list<GameObject*> goList; - if (Creature* freya = instance->GetCreature(GetData64(TYPE_FREYA))) + if (Creature* freya = instance->GetCreature(GetGuidData(TYPE_FREYA))) { freya->GetGameObjectListWithEntryInGrid(goList, 191019 /*Adder's Tongue*/, 333.0f); freya->GetGameObjectListWithEntryInGrid(goList, 190176 /*Frost Lotus*/, 333.0f); @@ -873,9 +820,9 @@ public: } } - uint64 GetData64(uint32 data) const override + ObjectGuid GetGuidData(uint32 data) const override { - switch(data) + switch (data) { // Bosses case TYPE_LEVIATHAN: @@ -998,7 +945,7 @@ public: return m_brannBronzebeardAlgGUID; } - return 0; + return ObjectGuid::Empty; } uint32 GetData(uint32 type) const override @@ -1272,8 +1219,8 @@ void instance_ulduar::instance_ulduar_InstanceMapScript::SpawnLeviathanEncounter { if (!_leviathanVehicles.empty()) { - for (std::list<uint64>::iterator itr = _leviathanVehicles.begin(); itr != _leviathanVehicles.end(); ++itr) - if (Creature* cr = instance->GetCreature(*itr)) + for (ObjectGuid guid : _leviathanVehicles) + if (Creature* cr = instance->GetCreature(guid)) if (Vehicle* veh = cr->GetVehicleKit()) veh->Dismiss(); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.cpp index af0c76c59b..dd29c875aa 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.cpp @@ -148,11 +148,11 @@ public: { npc_ulduar_storm_tempered_keeperAI(Creature* creature) : ScriptedAI(creature) { - otherGUID = 0; + otherGUID.Clear(); } EventMap events; - uint64 otherGUID; + ObjectGuid otherGUID; void Reset() override { diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp index 62ac9079f3..bed76caf3d 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp @@ -106,13 +106,13 @@ public: InstanceScript* pInstance; EventMap events; SummonList summons; - uint64 ValkyrGUID; - uint64 ThrowGUID; + ObjectGuid ValkyrGUID; + ObjectGuid ThrowGUID; void Reset() override { - ValkyrGUID = 0; - ThrowGUID = 0; + ValkyrGUID.Clear(); + ThrowGUID.Clear(); events.Reset(); summons.DespawnAll(); me->SetDisplayId(DISPLAYID_DEFAULT); @@ -367,7 +367,7 @@ public: c->DespawnOrUnsummon(); summons.DespawnAll(); } - ThrowGUID = 0; + ThrowGUID.Clear(); SetEquipmentSlots(true); break; } diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp index d4967c611f..4ed2d49152 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp @@ -55,7 +55,7 @@ public: struct npc_frost_tombAI : public NullCreatureAI { - npc_frost_tombAI(Creature* c) : NullCreatureAI(c), PrisonerGUID(0) + npc_frost_tombAI(Creature* c) : NullCreatureAI(c) { if (TempSummon* t = c->ToTempSummon()) if (Unit* s = t->GetSummoner()) @@ -70,7 +70,7 @@ public: c->CastSpell(s, SPELL_FROST_TOMB_AURA, true); } } - uint64 PrisonerGUID; + ObjectGuid PrisonerGUID; void JustDied(Unit* killer) override { diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp index 9dfc94ac5a..3246186c02 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp @@ -120,7 +120,7 @@ public: if (pInstance) { pInstance->SetData(DATA_DALRONN_AND_SKARVALD, IN_PROGRESS); - if (Creature* dalronn = pInstance->instance->GetCreature(pInstance->GetData64(DATA_DALRONN))) + if (Creature* dalronn = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_DALRONN))) { if (!dalronn->IsInCombat() && who) { @@ -146,7 +146,7 @@ public: if (pInstance) { - if (Creature* dalronn = pInstance->instance->GetCreature(pInstance->GetData64(DATA_DALRONN))) + if (Creature* dalronn = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_DALRONN))) { if (dalronn->isDead()) { @@ -288,7 +288,7 @@ public: if (pInstance) { pInstance->SetData(DATA_DALRONN_AND_SKARVALD, IN_PROGRESS); - if (Creature* skarvald = pInstance->instance->GetCreature(pInstance->GetData64(DATA_SKARVALD))) + if (Creature* skarvald = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_SKARVALD))) { if (!skarvald->IsInCombat() && who) { @@ -320,7 +320,7 @@ public: if (pInstance) { - if (Creature* skarvald = pInstance->instance->GetCreature(pInstance->GetData64(DATA_SKARVALD))) + if (Creature* skarvald = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_SKARVALD))) { if (skarvald->isDead()) { diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp index cf3d7ccae8..bbc79a5792 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp @@ -25,19 +25,19 @@ public: uint32 ForgeEventMask; std::string str_data; - uint64 GO_ForgeBellowGUID[3]; - uint64 GO_ForgeFireGUID[3]; - uint64 GO_ForgeAnvilGUID[3]; - uint64 GO_PortcullisGUID[2]; - - uint64 NPC_KelesethGUID; - uint64 NPC_DalronnGUID; - uint64 NPC_SkarvaldGUID; - uint64 NPC_DalronnGhostGUID; - uint64 NPC_SkarvaldGhostGUID; - uint64 NPC_IngvarGUID; - uint64 NPC_DarkRangerMarrahGUID; - uint64 NPC_SpecialDrakeGUID; + ObjectGuid GO_ForgeBellowGUID[3]; + ObjectGuid GO_ForgeFireGUID[3]; + ObjectGuid GO_ForgeAnvilGUID[3]; + ObjectGuid GO_PortcullisGUID[2]; + + ObjectGuid NPC_KelesethGUID; + ObjectGuid NPC_DalronnGUID; + ObjectGuid NPC_SkarvaldGUID; + ObjectGuid NPC_DalronnGhostGUID; + ObjectGuid NPC_SkarvaldGhostGUID; + ObjectGuid NPC_IngvarGUID; + ObjectGuid NPC_DarkRangerMarrahGUID; + ObjectGuid NPC_SpecialDrakeGUID; bool bRocksAchiev; void Initialize() override @@ -45,19 +45,6 @@ public: memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); ForgeEventMask = 0; - memset(&GO_ForgeBellowGUID, 0, sizeof(GO_ForgeBellowGUID)); - memset(&GO_ForgeFireGUID, 0, sizeof(GO_ForgeFireGUID)); - memset(&GO_ForgeAnvilGUID, 0, sizeof(GO_ForgeAnvilGUID)); - memset(&GO_PortcullisGUID, 0, sizeof(GO_PortcullisGUID)); - - NPC_KelesethGUID = 0; - NPC_DalronnGUID = 0; - NPC_SkarvaldGUID = 0; - NPC_DalronnGhostGUID = 0; - NPC_SkarvaldGhostGUID = 0; - NPC_IngvarGUID = 0; - NPC_DarkRangerMarrahGUID = 0; - NPC_SpecialDrakeGUID = 0; bRocksAchiev = true; } @@ -123,47 +110,47 @@ public: { case GO_BELLOW_1: GO_ForgeBellowGUID[0] = go->GetGUID(); - if (ForgeEventMask & 1) HandleGameObject(0, true, go); + if (ForgeEventMask & 1) HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_BELLOW_2: GO_ForgeBellowGUID[1] = go->GetGUID(); - if (ForgeEventMask & 2) HandleGameObject(0, true, go); + if (ForgeEventMask & 2) HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_BELLOW_3: GO_ForgeBellowGUID[2] = go->GetGUID(); - if (ForgeEventMask & 4) HandleGameObject(0, true, go); + if (ForgeEventMask & 4) HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_FORGEFIRE_1: GO_ForgeFireGUID[0] = go->GetGUID(); - if (ForgeEventMask & 1) HandleGameObject(0, true, go); + if (ForgeEventMask & 1) HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_FORGEFIRE_2: GO_ForgeFireGUID[1] = go->GetGUID(); - if (ForgeEventMask & 2) HandleGameObject(0, true, go); + if (ForgeEventMask & 2) HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_FORGEFIRE_3: GO_ForgeFireGUID[2] = go->GetGUID(); - if (ForgeEventMask & 4) HandleGameObject(0, true, go); + if (ForgeEventMask & 4) HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_GLOWING_ANVIL_1: GO_ForgeAnvilGUID[0] = go->GetGUID(); - if (ForgeEventMask & 1) HandleGameObject(0, true, go); + if (ForgeEventMask & 1) HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_GLOWING_ANVIL_2: GO_ForgeAnvilGUID[1] = go->GetGUID(); - if (ForgeEventMask & 2) HandleGameObject(0, true, go); + if (ForgeEventMask & 2) HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_GLOWING_ANVIL_3: GO_ForgeAnvilGUID[2] = go->GetGUID(); - if (ForgeEventMask & 4) HandleGameObject(0, true, go); + if (ForgeEventMask & 4) HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_GIANT_PORTCULLIS_1: GO_PortcullisGUID[0] = go->GetGUID(); - if (m_auiEncounter[2] == DONE) HandleGameObject(0, true, go); + if (m_auiEncounter[2] == DONE) HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_GIANT_PORTCULLIS_2: GO_PortcullisGUID[1] = go->GetGUID(); - if (m_auiEncounter[2] == DONE) HandleGameObject(0, true, go); + if (m_auiEncounter[2] == DONE) HandleGameObject(ObjectGuid::Empty, true, go); break; } } @@ -197,10 +184,10 @@ public: c->AI()->DoAction(-1); c->DespawnOrUnsummon(); } - NPC_DalronnGhostGUID = 0; + NPC_DalronnGhostGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_SkarvaldGhostGUID) ) c->DespawnOrUnsummon(); - NPC_SkarvaldGhostGUID = 0; + NPC_SkarvaldGhostGUID.Clear(); } if (data == DONE) { @@ -209,10 +196,10 @@ public: c->AI()->DoAction(-1); c->DespawnOrUnsummon(); } - NPC_DalronnGhostGUID = 0; + NPC_DalronnGhostGUID.Clear(); if( Creature* c = instance->GetCreature(NPC_SkarvaldGhostGUID) ) c->DespawnOrUnsummon(); - NPC_SkarvaldGhostGUID = 0; + NPC_SkarvaldGhostGUID.Clear(); } m_auiEncounter[1] = data; @@ -284,9 +271,9 @@ public: } } - uint64 GetData64(uint32 id) const override + ObjectGuid GetGuidData(uint32 id) const override { - switch(id) + switch (id) { case DATA_KELESETH: return NPC_KelesethGUID; @@ -297,12 +284,13 @@ public: case DATA_INGVAR: return NPC_IngvarGUID; } - return 0; + + return ObjectGuid::Empty; } uint32 GetData(uint32 id) const override { - switch(id) + switch (id) { case DATA_KELESETH: case DATA_DALRONN_AND_SKARVALD: @@ -313,6 +301,7 @@ public: case DATA_FORGE_3: return ForgeEventMask & (uint32)(1 << (id - 100)); } + return 0; } diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp index 7a5100003d..d4bf735b47 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp @@ -114,7 +114,7 @@ public: InstanceScript* m_pInstance; EventMap events; SummonList summons; - uint64 OrbGUID; + ObjectGuid OrbGUID; uint8 Counter; uint8 RandomUnfreeze[4]; @@ -140,7 +140,7 @@ public: events.Reset(); summons.DoAction(ACTION_DESPAWN_ADDS); summons.DespawnAll(); - OrbGUID = 0; + OrbGUID.Clear(); Counter = 0; me->CastSpell(me, SPELL_FREEZE, true); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); @@ -151,7 +151,7 @@ public: m_pInstance->SetData(DATA_GORTOK_PALEHOOF, NOT_STARTED); // Reset statue - if (GameObject* statisGenerator = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(STATIS_GENERATOR))) + if (GameObject* statisGenerator = m_pInstance->instance->GetGameObject(m_pInstance->GetGuidData(STATIS_GENERATOR))) { statisGenerator->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); statisGenerator->SetGoState(GO_STATE_READY); @@ -160,7 +160,7 @@ public: // Reset mini bosses for(uint8 i = 0; i < 4; ++i) { - if(Creature* Animal = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(DATA_NPC_FRENZIED_WORGEN + i))) + if(Creature* Animal = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(DATA_NPC_FRENZIED_WORGEN + i))) { Animal->SetPosition(Animal->GetHomePosition()); Animal->StopMovingOnCurrentPos(); @@ -228,7 +228,7 @@ public: { if (Creature* orb = ObjectAccessor::GetCreature(*me, OrbGUID)) { - if (Creature* miniBoss = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(DATA_NPC_FRENZIED_WORGEN + RandomUnfreeze[Counter]))) + if (Creature* miniBoss = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(DATA_NPC_FRENZIED_WORGEN + RandomUnfreeze[Counter]))) { Counter++; miniBoss->AI()->DoAction(ACTION_UNFREEZE); @@ -244,7 +244,7 @@ public: { if (Creature* orb = ObjectAccessor::GetCreature(*me, OrbGUID)) { - if (Creature* miniBoss = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(DATA_NPC_FRENZIED_WORGEN + RandomUnfreeze[Counter - 1]))) + if (Creature* miniBoss = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(DATA_NPC_FRENZIED_WORGEN + RandomUnfreeze[Counter - 1]))) { miniBoss->AI()->DoAction(ACTION_UNFREEZE2); orb->RemoveAurasDueToSpell(SPELL_AWAKEN_SUBBOSS); @@ -443,7 +443,7 @@ public: { if (m_pInstance) { - if (Creature* palehoof = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(DATA_GORTOK_PALEHOOF))) + if (Creature* palehoof = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(DATA_GORTOK_PALEHOOF))) palehoof->AI()->DoAction(ACTION_MINIBOSS_DIED); } } @@ -553,7 +553,7 @@ public: { if (m_pInstance) { - if (Creature* palehoof = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(DATA_GORTOK_PALEHOOF))) + if (Creature* palehoof = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(DATA_GORTOK_PALEHOOF))) palehoof->AI()->DoAction(ACTION_MINIBOSS_DIED); } } @@ -661,7 +661,7 @@ public: { if (m_pInstance) { - if (Creature* palehoof = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(DATA_GORTOK_PALEHOOF))) + if (Creature* palehoof = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(DATA_GORTOK_PALEHOOF))) palehoof->AI()->DoAction(ACTION_MINIBOSS_DIED); } } @@ -769,7 +769,7 @@ public: { if (m_pInstance) { - if (Creature* palehoof = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(DATA_GORTOK_PALEHOOF))) + if (Creature* palehoof = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(DATA_GORTOK_PALEHOOF))) palehoof->AI()->DoAction(ACTION_MINIBOSS_DIED); } } @@ -785,7 +785,7 @@ public: { InstanceScript* pInstance = go->GetInstanceScript(); - Creature* pPalehoof = ObjectAccessor::GetCreature(*go, pInstance ? pInstance->GetData64(DATA_GORTOK_PALEHOOF) : 0); + Creature* pPalehoof = ObjectAccessor::GetCreature(*go, pInstance ? pInstance->GetGuidData(DATA_GORTOK_PALEHOOF) : ObjectGuid::Empty); if (pPalehoof && pPalehoof->IsAlive()) { // maybe these are hacks :( diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp index 6cb12a0b59..c395810a0b 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp @@ -113,7 +113,7 @@ public: InstanceScript* m_pInstance; EventMap events; SummonList summons; - uint64 GraufGUID; + ObjectGuid GraufGUID; bool SecondPhase, EventStarted; void Reset() override @@ -239,7 +239,7 @@ public: if (m_pInstance) { m_pInstance->SetData(DATA_SKADI_THE_RUTHLESS, DONE); - m_pInstance->HandleGameObject(m_pInstance->GetData64(SKADI_DOOR), true); + m_pInstance->HandleGameObject(m_pInstance->GetGuidData(SKADI_DOOR), true); } } @@ -495,7 +495,7 @@ public: uint8 count = m_pInstance->GetData(SKADI_HITS) + 1; m_pInstance->SetData(SKADI_HITS, count); - if (Creature* grauf = ObjectAccessor::GetCreature(*pPlayer, m_pInstance->GetData64(DATA_GRAUF))) + if (Creature* grauf = ObjectAccessor::GetCreature(*pPlayer, m_pInstance->GetGuidData(DATA_GRAUF))) { if (count >= 3) { diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index ddd1848b9c..765677aa06 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -101,10 +101,10 @@ public: { instance = creature->GetInstanceScript(); Started = false; - ArthasGUID = 0; + ArthasGUID.Clear(); } - uint64 ArthasGUID; + ObjectGuid ArthasGUID; bool Started; InstanceScript* instance; EventMap events; @@ -152,7 +152,7 @@ public: if (instance) { instance->SetData(DATA_SVALA_SORROWGRAVE, IN_PROGRESS); - if (GameObject* mirror = ObjectAccessor::GetGameObject(*me, instance->GetData64(GO_SVALA_MIRROR))) + if (GameObject* mirror = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_SVALA_MIRROR))) mirror->SetGoState(GO_STATE_READY); } } @@ -227,7 +227,7 @@ public: case 30: { WorldPacket data(SMSG_SPLINE_MOVE_SET_HOVER, 9); - data.append(me->GetPackGUID()); + data << me->GetPackGUID(); me->SendMessageToSet(&data, false); break; } @@ -263,7 +263,7 @@ public: case EVENT_SVALA_TALK7: me->SetFacingTo(M_PI / 2.0f); Talk(TALK_INTRO_S3); - if (GameObject* mirror = ObjectAccessor::GetGameObject(*me, instance->GetData64(GO_SVALA_MIRROR))) + if (GameObject* mirror = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_SVALA_MIRROR))) mirror->SetGoState(GO_STATE_ACTIVE); events2.ScheduleEvent(EVENT_SVALA_TALK8, 13000); break; diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_utgarde_pinnacle.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_utgarde_pinnacle.cpp index 8509ccd4f4..5539aa0dc5 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_utgarde_pinnacle.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_utgarde_pinnacle.cpp @@ -20,20 +20,20 @@ public: { instance_utgarde_pinnacle_InstanceMapScript(Map* pMap) : InstanceScript(pMap) {Initialize();}; - uint64 SvalaSorrowgrave; - uint64 GortokPalehoof; - uint64 SkadiRuthless; - uint64 KingYmiron; - uint64 FrenziedWorgen; - uint64 RavenousFurbolg; - uint64 MassiveJormungar; - uint64 FerociousRhino; - uint64 Grauf; + ObjectGuid SvalaSorrowgrave; + ObjectGuid GortokPalehoof; + ObjectGuid SkadiRuthless; + ObjectGuid KingYmiron; + ObjectGuid FrenziedWorgen; + ObjectGuid RavenousFurbolg; + ObjectGuid MassiveJormungar; + ObjectGuid FerociousRhino; + ObjectGuid Grauf; - uint64 SvalaMirrorGUID; - uint64 SkadiRuthlessDoor; - uint64 YmironDoor; - uint64 StatisGenerator; + ObjectGuid SvalaMirrorGUID; + ObjectGuid SkadiRuthlessDoor; + ObjectGuid YmironDoor; + ObjectGuid StatisGenerator; uint32 FightStatus; uint32 Encounters[MAX_ENCOUNTERS]; uint8 SkadiHits; @@ -45,22 +45,8 @@ public: void Initialize() override { - SvalaSorrowgrave = 0; - GortokPalehoof = 0; - SkadiRuthless = 0; - KingYmiron = 0; - FrenziedWorgen = 0; - RavenousFurbolg = 0; - MassiveJormungar = 0; - FerociousRhino = 0; - Grauf = 0; - - SvalaMirrorGUID = 0; - StatisGenerator = 0; SkadiHits = 0; SkadiInRange = 0; - SkadiRuthlessDoor = 0; - YmironDoor = 0; FightStatus = 0; svalaAchievement = false; @@ -120,12 +106,12 @@ public: case GO_SKADI_THE_RUTHLESS_DOOR: SkadiRuthlessDoor = pGo->GetGUID(); if (Encounters[DATA_SKADI_THE_RUTHLESS] == DONE) - HandleGameObject(0, true, pGo); + HandleGameObject(ObjectGuid::Empty, true, pGo); break; case GO_KING_YMIRON_DOOR: YmironDoor = pGo->GetGUID(); if (Encounters[DATA_KING_YMIRON] == DONE) - HandleGameObject(0, true, pGo); + HandleGameObject(ObjectGuid::Empty, true, pGo); break; case GO_GORK_PALEHOOF_SPHERE: StatisGenerator = pGo->GetGUID(); @@ -254,9 +240,9 @@ public: return 0; } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { - switch(identifier) + switch (identifier) { case DATA_SVALA_SORROWGRAVE: return SvalaSorrowgrave; @@ -286,7 +272,7 @@ public: return SvalaMirrorGUID; } - return 0; + return ObjectGuid::Empty; } }; }; diff --git a/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp index fe7c78817c..273cd51770 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp @@ -215,7 +215,7 @@ public: void JustSummoned(Creature* cr) override { if (InstanceScript* pInstance = me->GetInstanceScript()) - if (Creature* toravon = ObjectAccessor::GetCreature(*me, pInstance->GetData64(EVENT_TORAVON))) + if (Creature* toravon = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(EVENT_TORAVON))) if (toravon->AI()) toravon->AI()->JustSummoned(cr); } diff --git a/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp index 5ecc5611dd..7fb50f5595 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp @@ -33,7 +33,6 @@ public: void Initialize() override { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - memset(&bossGUIDs, 0, sizeof(bossGUIDs)); ArchavonDeath = 0; EmalonDeath = 0; @@ -147,11 +146,12 @@ public: } } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { if (identifier < MAX_ENCOUNTER) return bossGUIDs[identifier]; - return 0; + + return ObjectGuid::Empty; } uint32 GetData(uint32 identifier) const override @@ -266,7 +266,7 @@ public: bool stoned; uint32 m_auiEncounter[MAX_ENCOUNTER]; - uint64 bossGUIDs[MAX_ENCOUNTER]; + ObjectGuid bossGUIDs[MAX_ENCOUNTER]; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp b/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp index e5412deb87..5c8a1978ea 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp @@ -85,10 +85,10 @@ public: if (IsHeroic()) events.RescheduleEvent(EVENT_SPELL_STORMSTRIKE, 3000); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_EREKEM_GUARD_1_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_EREKEM_GUARD_1_GUID))) if (!c->IsInCombat()) c->AI()->AttackStart(who); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_EREKEM_GUARD_2_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_EREKEM_GUARD_2_GUID))) if (!c->IsInCombat()) c->AI()->AttackStart(who); } @@ -116,14 +116,14 @@ public: events.RepeatEvent(urand(16000, 22000)); break; case EVENT_SPELL_CHAIN_HEAL: - if (uint64 TargetGUID = GetChainHealTargetGUID()) + if (ObjectGuid TargetGUID = GetChainHealTargetGUID()) if (pInstance) { if (Creature* target = pInstance->instance->GetCreature(TargetGUID)) me->CastSpell(target, SPELL_CHAIN_HEAL, false); - Creature* pGuard1 = pInstance->instance->GetCreature(pInstance->GetData64(DATA_EREKEM_GUARD_1_GUID)); - Creature* pGuard2 = pInstance->instance->GetCreature(pInstance->GetData64(DATA_EREKEM_GUARD_2_GUID)); + Creature* pGuard1 = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_EREKEM_GUARD_1_GUID)); + Creature* pGuard2 = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_EREKEM_GUARD_2_GUID)); if ((pGuard1 && !pGuard1->IsAlive()) || (pGuard2 && !pGuard2->IsAlive())) { events.RepeatEvent(urand(3000, 6000)); @@ -147,8 +147,8 @@ public: break; case EVENT_SPELL_STORMSTRIKE: { - Creature* pGuard1 = pInstance->instance->GetCreature(pInstance->GetData64(DATA_EREKEM_GUARD_1_GUID)); - Creature* pGuard2 = pInstance->instance->GetCreature(pInstance->GetData64(DATA_EREKEM_GUARD_2_GUID)); + Creature* pGuard1 = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_EREKEM_GUARD_1_GUID)); + Creature* pGuard2 = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_EREKEM_GUARD_2_GUID)); if (pGuard1 && !pGuard1->IsAlive() && pGuard2 && !pGuard2->IsAlive()) // both dead me->CastSpell(me->GetVictim(), SPELL_STORMSTRIKE, false); events.RepeatEvent(3000); @@ -184,18 +184,18 @@ public: pInstance->SetData(DATA_FAILED, 1); } - uint64 GetChainHealTargetGUID() + ObjectGuid GetChainHealTargetGUID() { if (HealthBelowPct(85)) return me->GetGUID(); if (pInstance) { - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_EREKEM_GUARD_1_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_EREKEM_GUARD_1_GUID))) if (c->IsAlive() && !c->HealthAbovePct(75)) return c->GetGUID(); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_EREKEM_GUARD_2_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_EREKEM_GUARD_2_GUID))) if (c->IsAlive() && !c->HealthAbovePct(75)) return c->GetGUID(); } @@ -252,7 +252,7 @@ public: events.RescheduleEvent(EVENT_SPELL_HOWLING_SCREECH, urand(8000, 13000)); events.RescheduleEvent(EVENT_SPELL_STRIKE, urand(4000, 8000)); - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_EREKEM_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_EREKEM_GUID))) if (!c->IsInCombat()) c->AI()->AttackStart(who); } diff --git a/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp b/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp index d5b484c23b..e626c55b30 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp @@ -209,8 +209,8 @@ public: bool bIsWaterElementsAlive = false; if (!globules.empty()) { - for (std::list<uint64>::const_iterator itr = globules.begin(); itr != globules.end(); ++itr) - if (Creature* pTemp = ObjectAccessor::GetCreature(*me, *itr)) + for (ObjectGuid const guid : globules) + if (Creature* pTemp = ObjectAccessor::GetCreature(*me, guid)) if (pTemp->IsAlive()) { bIsWaterElementsAlive = true; @@ -247,7 +247,7 @@ public: me->CastSpell(pSummoned, SPELL_CREATE_GLOBULE_VISUAL, true); // triggered should ignore los globules.Summon(pSummoned); if (pInstance) - pInstance->SetData64(DATA_ADD_TRASH_MOB, pSummoned->GetGUID()); + pInstance->SetGuidData(DATA_ADD_TRASH_MOB, pSummoned->GetGUID()); } } @@ -257,7 +257,7 @@ public: { globules.Despawn(pSummoned); if (pInstance) - pInstance->SetData64(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); + pInstance->SetGuidData(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); } } @@ -323,7 +323,7 @@ public: if (uiRangeCheck_Timer < uiDiff) { if (pInstance) - if (Creature* pIchoron = pInstance->instance->GetCreature(pInstance->GetData64(DATA_ICHORON_GUID))) + if (Creature* pIchoron = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_ICHORON_GUID))) if (me->IsWithinDist(pIchoron, 2.0f, false)) { if (pIchoron->AI()) @@ -339,7 +339,7 @@ public: { me->CastSpell(me, SPELL_SPLASH, true); if (pInstance) - if (Creature* pIchoron = pInstance->instance->GetCreature(pInstance->GetData64(DATA_ICHORON_GUID))) + if (Creature* pIchoron = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_ICHORON_GUID))) if (pIchoron->AI()) pIchoron->AI()->DoAction(ACTION_WATER_ELEMENT_KILLED); me->DespawnOrUnsummon(2500); diff --git a/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp b/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp index af41d81640..d087b58920 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp @@ -124,8 +124,8 @@ public: { bool found = false; if (pInstance) - for (std::list<uint64>::iterator itr = spheres.begin(); itr != spheres.end(); ++itr) - if (Creature* c = pInstance->instance->GetCreature(*itr)) + for (ObjectGuid guid : spheres) + if (Creature* c = pInstance->instance->GetCreature(guid)) if (me->GetDistance(c) < 3.0f) { c->CastSpell(me, SPELL_ARCANE_POWER, false); @@ -155,7 +155,7 @@ public: pSummoned->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); spheres.Summon(pSummoned); if (pInstance) - pInstance->SetData64(DATA_ADD_TRASH_MOB, pSummoned->GetGUID()); + pInstance->SetGuidData(DATA_ADD_TRASH_MOB, pSummoned->GetGUID()); } } @@ -165,7 +165,7 @@ public: { spheres.Despawn(pSummoned); if (pInstance) - pInstance->SetData64(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); + pInstance->SetGuidData(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); } } diff --git a/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp b/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp index 8130b04ca6..4807c6899a 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp @@ -139,7 +139,7 @@ public: summons.Summon(pSummoned); pSummoned->SetPhaseMask(16, true); if (pInstance) - pInstance->SetData64(DATA_ADD_TRASH_MOB, pSummoned->GetGUID()); + pInstance->SetGuidData(DATA_ADD_TRASH_MOB, pSummoned->GetGUID()); } } @@ -151,7 +151,7 @@ public: if (pSummoned->IsAIEnabled) pSummoned->AI()->DoAction(-1337); if (pInstance) - pInstance->SetData64(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); + pInstance->SetGuidData(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); } } @@ -183,19 +183,19 @@ public: npc_vh_void_sentryAI(Creature* c) : NullCreatureAI(c) { pInstance = c->GetInstanceScript(); - SummonedGUID = 0; + SummonedGUID.Clear(); checkTimer = 5000; //me->CastSpell(me, SPELL_SUMMON_VOID_SENTRY_BALL, true); if (Creature* pSummoned = me->SummonCreature(NPC_VOID_SENTRY_BALL, *me, TEMPSUMMON_TIMED_DESPAWN, 300000)) { pSummoned->SetPhaseMask(1, true); SummonedGUID = pSummoned->GetGUID(); - pInstance->SetData64(DATA_ADD_TRASH_MOB, pSummoned->GetGUID()); + pInstance->SetGuidData(DATA_ADD_TRASH_MOB, pSummoned->GetGUID()); } } InstanceScript* pInstance; - uint64 SummonedGUID; + ObjectGuid SummonedGUID; uint16 checkTimer; void DoAction(int32 a) override @@ -219,7 +219,7 @@ public: void SummonedCreatureDespawn(Creature* pSummoned) override { if (pSummoned) - pInstance->SetData64(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); + pInstance->SetGuidData(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); } void UpdateAI(uint32 diff) override diff --git a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp index 5a11cdcc44..04ba13417a 100644 --- a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp +++ b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp @@ -42,32 +42,32 @@ public: bool bAchiev; bool bDefensesUsed; - std::vector<uint64> GO_ActivationCrystalGUID; - uint64 GO_MainGateGUID; - - uint64 GO_MoraggCellGUID; - uint64 GO_ErekemCellGUID; - uint64 GO_ErekemRightGuardCellGUID; - uint64 GO_ErekemLeftGuardCellGUID; - uint64 GO_IchoronCellGUID; - uint64 GO_LavanthorCellGUID; - uint64 GO_XevozzCellGUID; - uint64 GO_ZuramatCellGUID; - - std::set<uint64> trashMobs; - uint64 NPC_SinclariGUID; - uint64 NPC_GuardGUID[4]; - uint64 NPC_PortalGUID; - uint64 NPC_DoorSealGUID; - - uint64 NPC_MoraggGUID; - uint64 NPC_ErekemGUID; - uint64 NPC_ErekemGuardGUID[2]; - uint64 NPC_IchoronGUID; - uint64 NPC_LavanthorGUID; - uint64 NPC_XevozzGUID; - uint64 NPC_ZuramatGUID; - uint64 NPC_CyanigosaGUID; + GuidVector GO_ActivationCrystalGUID; + ObjectGuid GO_MainGateGUID; + + ObjectGuid GO_MoraggCellGUID; + ObjectGuid GO_ErekemCellGUID; + ObjectGuid GO_ErekemRightGuardCellGUID; + ObjectGuid GO_ErekemLeftGuardCellGUID; + ObjectGuid GO_IchoronCellGUID; + ObjectGuid GO_LavanthorCellGUID; + ObjectGuid GO_XevozzCellGUID; + ObjectGuid GO_ZuramatCellGUID; + + GuidSet trashMobs; + ObjectGuid NPC_SinclariGUID; + ObjectGuid NPC_GuardGUID[4]; + ObjectGuid NPC_PortalGUID; + ObjectGuid NPC_DoorSealGUID; + + ObjectGuid NPC_MoraggGUID; + ObjectGuid NPC_ErekemGUID; + ObjectGuid NPC_ErekemGuardGUID[2]; + ObjectGuid NPC_IchoronGUID; + ObjectGuid NPC_LavanthorGUID; + ObjectGuid NPC_XevozzGUID; + ObjectGuid NPC_ZuramatGUID; + ObjectGuid NPC_CyanigosaGUID; void Initialize() override { @@ -84,30 +84,6 @@ public: bDefensesUsed = false; GO_ActivationCrystalGUID.clear(); - GO_MainGateGUID = 0; - - GO_MoraggCellGUID = 0; - GO_ErekemCellGUID = 0; - GO_ErekemRightGuardCellGUID = 0; - GO_ErekemLeftGuardCellGUID = 0; - GO_IchoronCellGUID = 0; - GO_LavanthorCellGUID = 0; - GO_XevozzCellGUID = 0; - GO_ZuramatCellGUID = 0; - - NPC_SinclariGUID = 0; - memset(&NPC_GuardGUID, 0, sizeof(NPC_GuardGUID)); - NPC_PortalGUID = 0; - NPC_DoorSealGUID = 0; - - NPC_MoraggGUID = 0; - NPC_ErekemGUID = 0; - NPC_ErekemGuardGUID[0] = NPC_ErekemGuardGUID[1] = 0; - NPC_IchoronGUID = 0; - NPC_LavanthorGUID = 0; - NPC_XevozzGUID = 0; - NPC_ZuramatGUID = 0; - NPC_CyanigosaGUID = 0; } bool IsEncounterInProgress() const override @@ -124,7 +100,7 @@ public: break; case NPC_VIOLET_HOLD_GUARD: for (uint8 i = 0; i < 4; ++i) - if (NPC_GuardGUID[i] == 0) + if (!NPC_GuardGUID[i]) { NPC_GuardGUID[i] = creature->GetGUID(); break; @@ -156,7 +132,7 @@ public: NPC_ErekemGUID = creature->GetGUID(); break; case NPC_EREKEM_GUARD: - if (NPC_ErekemGuardGUID[0] == 0) + if (!NPC_ErekemGuardGUID[0]) NPC_ErekemGuardGUID[0] = creature->GetGUID(); else NPC_ErekemGuardGUID[1] = creature->GetGUID(); @@ -175,7 +151,7 @@ public: switch(go->GetEntry()) { case GO_ACTIVATION_CRYSTAL: - HandleGameObject(0, false, go); // make go not used yet + HandleGameObject(ObjectGuid::Empty, false, go); // make go not used yet go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); // not useable at the beginning GO_ActivationCrystalGUID.push_back(go->GetGUID()); break; @@ -280,7 +256,7 @@ public: } } - void SetData64(uint32 type, uint64 data) override + void SetGuidData(uint32 type, ObjectGuid data) override { switch(type) { @@ -313,9 +289,9 @@ public: return 0; } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { - switch(identifier) + switch (identifier) { case DATA_TELEPORTATION_PORTAL_GUID: return NPC_PortalGUID; @@ -331,7 +307,7 @@ public: return NPC_IchoronGUID; } - return 0; + return ObjectGuid::Empty; } void StartBossEncounter(uint8 uiBoss) @@ -458,10 +434,10 @@ public: DoUpdateWorldState(WORLD_STATE_VH_PRISON_STATE, (uint32)GateHealth); DoUpdateWorldState(WORLD_STATE_VH_WAVE_COUNT, (uint32)WaveCount); - for (std::vector<uint64>::iterator itr = GO_ActivationCrystalGUID.begin(); itr != GO_ActivationCrystalGUID.end(); ++itr) - if (GameObject* go = instance->GetGameObject(*itr)) + for (ObjectGuid guid : GO_ActivationCrystalGUID) + if (GameObject* go = instance->GetGameObject(guid)) { - HandleGameObject(0, false, go); // not used yet + HandleGameObject(ObjectGuid::Empty, false, go); // not used yet go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); // make it useable } events.RescheduleEvent(EVENT_SUMMON_PORTAL, 4000); @@ -552,10 +528,10 @@ public: CLEANED = true; // reset defense crystals - for (std::vector<uint64>::iterator itr = GO_ActivationCrystalGUID.begin(); itr != GO_ActivationCrystalGUID.end(); ++itr) - if (GameObject* go = instance->GetGameObject(*itr)) + for (ObjectGuid guid : GO_ActivationCrystalGUID) + if (GameObject* go = instance->GetGameObject(guid)) { - HandleGameObject(0, false, go); // not used yet + HandleGameObject(ObjectGuid::Empty, false, go); // not used yet go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); // not useable at the beginning } @@ -576,12 +552,13 @@ public: // remove portal if any if (Creature* c = instance->GetCreature(NPC_PortalGUID)) c->DespawnOrUnsummon(); - NPC_PortalGUID = 0; + NPC_PortalGUID.Clear(); // remove trash - for (std::set<uint64>::iterator itr = trashMobs.begin(); itr != trashMobs.end(); ++itr) - if (Creature* c = instance->GetCreature(*itr)) + for (ObjectGuid guid : trashMobs) + if (Creature* c = instance->GetCreature(guid)) c->DespawnOrUnsummon(); + trashMobs.clear(); // clear door seal damaging auras: diff --git a/src/server/scripts/Northrend/VioletHold/violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/violet_hold.cpp index a1c8723e24..a0d2711b16 100644 --- a/src/server/scripts/Northrend/VioletHold/violet_hold.cpp +++ b/src/server/scripts/Northrend/VioletHold/violet_hold.cpp @@ -220,7 +220,7 @@ public: if (pSummoned) { listOfMobs.Summon(pSummoned); - pInstance->SetData64(DATA_ADD_TRASH_MOB, pSummoned->GetGUID()); + pInstance->SetGuidData(DATA_ADD_TRASH_MOB, pSummoned->GetGUID()); } } @@ -229,7 +229,7 @@ public: if (pSummoned) { listOfMobs.Despawn(pSummoned); - pInstance->SetData64(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); + pInstance->SetGuidData(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); } } }; @@ -258,7 +258,7 @@ struct violet_hold_trashAI : public npc_escortAI void ClearDoorSealAura() { if (pInstance) - if (Creature* c = pInstance->instance->GetCreature(pInstance->GetData64(DATA_DOOR_SEAL_GUID))) + if (Creature* c = pInstance->instance->GetCreature(pInstance->GetGuidData(DATA_DOOR_SEAL_GUID))) c->RemoveAura(SPELL_DESTROY_DOOR_SEAL, me->GetGUID()); } @@ -352,7 +352,7 @@ struct violet_hold_trashAI : public npc_escortAI void JustDied(Unit* /*unit*/) override { if (pInstance) - if (Creature* portal = ObjectAccessor::GetCreature((*me), pInstance->GetData64(DATA_TELEPORTATION_PORTAL_GUID))) + if (Creature* portal = ObjectAccessor::GetCreature((*me), pInstance->GetGuidData(DATA_TELEPORTATION_PORTAL_GUID))) CAST_AI(npc_vh_teleportation_portal::npc_vh_teleportation_portalAI, portal->AI())->SummonedMobDied(me); } @@ -1167,7 +1167,7 @@ public: bool OnGossipHello(Player* player, GameObject* go) override { - if (GameObject* gate = go->GetMap()->GetGameObject(MAKE_NEW_GUID(61606, 193019, HIGHGUID_GAMEOBJECT))) + if (GameObject* gate = go->GetMap()->GetGameObject(ObjectGuid::Create<HighGuid::GameObject>(193019, 61606))) if (gate->getLootState() == GO_READY) gate->UseDoorOrButton(0, false, player); diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp index 1fae5b07b9..68b4f7acab 100644 --- a/src/server/scripts/Northrend/zone_borean_tundra.cpp +++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp @@ -112,13 +112,13 @@ public: uint32 phaseTimer; uint8 phase; - uint64 casterGuid; + ObjectGuid casterGuid; void Reset() override { phaseTimer = 30000; phase = 0; - casterGuid = 0; + casterGuid.Clear(); } void SpellHit(Unit* caster, const SpellInfo* spell) override @@ -387,7 +387,7 @@ public: if (uiRand < 40) { player->CastSpell(me, SPELL_FREED_WARSONG_PEON, true); - player->KilledMonsterCredit(NPC_WARSONG_PEON, 0); + player->KilledMonsterCredit(NPC_WARSONG_PEON); } else if (uiRand < 80) { @@ -590,7 +590,7 @@ public: me->DespawnOrUnsummon(45000); if (Player* player = pCaster->ToPlayer()) - player->KilledMonsterCredit(NPC_CAPTURED_BERLY_SORCERER, 0); + player->KilledMonsterCredit(NPC_CAPTURED_BERLY_SORCERER); bEnslaved = true; } @@ -697,7 +697,7 @@ public: } } - void GotStinged(uint64 casterGUID) + void GotStinged(ObjectGuid casterGUID) { if (Player* caster = ObjectAccessor::GetPlayer(*me, casterGUID)) { @@ -724,7 +724,7 @@ public: break; case 7: Talk(SAY_IMPRISIONED_BERYL_7); - caster->KilledMonsterCredit(NPC_IMPRISONED_BERYL_SORCERER, 0); + caster->KilledMonsterCredit(NPC_IMPRISONED_BERYL_SORCERER); break; } } @@ -1109,7 +1109,7 @@ public: uint32 uiEventTimer; uint8 uiEventPhase; - uint64 uiPlayerGUID; + ObjectGuid uiPlayerGUID; void Reset() override { @@ -1122,7 +1122,7 @@ public: uiEventTimer = 0; uiEventPhase = 0; - uiPlayerGUID = 0; + uiPlayerGUID.Clear(); DoCast(SPELL_SHROUD_OF_THE_DEATH_CULTIST); @@ -1139,7 +1139,7 @@ public: uiEventPhase = 1; } - void SetGUID(uint64 uiGuid, int32 /*iId*/) override + void SetGUID(ObjectGuid uiGuid, int32 /*iId*/) override { uiPlayerGUID = uiGuid; } @@ -1322,10 +1322,10 @@ public: void Reset() override { _events.Reset(); - _playerGUID = 0; + _playerGUID.Clear(); } - void SetGUID(uint64 guid, int32 /*action*/) override + void SetGUID(ObjectGuid guid, int32 /*action*/) override { if (_playerGUID) return; @@ -1355,7 +1355,7 @@ public: case EVENT_TALK: if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID)) Talk(SAY_BLOODMAGE_LAURITH, player); - _playerGUID = 0; + _playerGUID.Clear(); _events.ScheduleEvent(EVENT_RESET_ORIENTATION, 5000); break; case EVENT_RESET_ORIENTATION: @@ -1367,7 +1367,7 @@ public: private: EventMap _events; - uint64 _playerGUID; + ObjectGuid _playerGUID; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Northrend/zone_crystalsong_forest.cpp b/src/server/scripts/Northrend/zone_crystalsong_forest.cpp index a028882073..4e1c64d30b 100644 --- a/src/server/scripts/Northrend/zone_crystalsong_forest.cpp +++ b/src/server/scripts/Northrend/zone_crystalsong_forest.cpp @@ -165,11 +165,11 @@ public: SetCombatMovement(false); } - uint64 targetGUID; + ObjectGuid targetGUID; void Reset() override { - targetGUID = 0; + targetGUID.Clear(); } void UpdateAI(uint32 /*diff*/) override diff --git a/src/server/scripts/Northrend/zone_dalaran.cpp b/src/server/scripts/Northrend/zone_dalaran.cpp index b2b6ad803f..540b8012f8 100644 --- a/src/server/scripts/Northrend/zone_dalaran.cpp +++ b/src/server/scripts/Northrend/zone_dalaran.cpp @@ -136,7 +136,7 @@ public: void Reset() override { _events.Reset(); - _aquanosGUID = 0; + _aquanosGUID.Clear(); } void SetData(uint32 type, uint32 /*data*/) override @@ -221,7 +221,7 @@ public: private: EventMap _events; - uint64 _aquanosGUID; + ObjectGuid _aquanosGUID; uint8 _lCount; uint32 _lSource; @@ -313,7 +313,7 @@ public: npc_archmage_landalockAI(Creature* creature) : ScriptedAI(creature) { _switchImageTimer = MINUTE * IN_MILLISECONDS; - _summonGUID = 0; + _summonGUID.Clear(); } uint32 GetImageEntry(uint32 QuestId) @@ -372,7 +372,7 @@ public: continue; uint32 newEntry = GetImageEntry(questId); - if (GUID_ENPART(_summonGUID) != newEntry) + if (_summonGUID.GetEntry() != newEntry) { if (Creature* image = ObjectAccessor::GetCreature(*me, _summonGUID)) image->DespawnOrUnsummon(); @@ -387,7 +387,7 @@ public: } private: uint32 _switchImageTimer; - uint64 _summonGUID; + ObjectGuid _summonGUID; }; }; diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp index 60f9dde3cd..a0e6d482d2 100644 --- a/src/server/scripts/Northrend/zone_dragonblight.cpp +++ b/src/server/scripts/Northrend/zone_dragonblight.cpp @@ -64,8 +64,8 @@ public: bool secondpart; int32 timer; uint8 step; - uint64 pGUID; - uint64 oachanoaGUID; + ObjectGuid pGUID; + ObjectGuid oachanoaGUID; void Reset() override { @@ -73,8 +73,8 @@ public: secondpart = false; timer = 0; step = 0; - pGUID = 0; - oachanoaGUID = 0; + pGUID.Clear(); + oachanoaGUID.Clear(); } void NextStep(const uint32 time) @@ -234,7 +234,7 @@ public: } } - void Start(uint64 g) + void Start(ObjectGuid g) { running = true; pGUID = g; @@ -301,8 +301,8 @@ public: { npc_hourglass_of_eternityAI(Creature* c) : ScriptedAI(c) {} - uint64 summonerGUID; - uint64 futureGUID; + ObjectGuid summonerGUID; + ObjectGuid futureGUID; EventMap events; uint8 count[3]; uint8 phase; @@ -571,7 +571,7 @@ public: if (TempSummon* summon = me->ToTempSummon()) if (Unit* owner = summon->GetSummoner()) if (Player* player = owner->ToPlayer()) - player->KilledMonsterCredit(me->GetEntry(), 0); + player->KilledMonsterCredit(me->GetEntry()); } } }; @@ -753,7 +753,7 @@ public: EventMap events; SummonList summons; - uint64 playerGUID; + ObjectGuid playerGUID; void CleanAll(bool fromReset = true) { @@ -784,7 +784,7 @@ public: events.ScheduleEvent(999, 0); events.ScheduleEvent(1, 3000); summons.DespawnAll(); - playerGUID = 0; + playerGUID.Clear(); CleanAll(); @@ -800,10 +800,11 @@ public: me->GetMotionMaster()->Clear(); } - void SetGUID(uint64 guid, int32 /*id*/) override + void SetGUID(ObjectGuid guid, int32 /*id*/) override { if (playerGUID || events.GetNextEventTime(998) || events.GetNextEventTime(2)) return; + me->setActive(true); playerGUID = guid; events.ScheduleEvent(2, 900000); @@ -837,7 +838,7 @@ public: c->CastSpell(c, SPELL_SAC_HOLY_ZONE_AURA, true); if (GameObject* go = me->FindNearestGameObject(GO_SAC_LIGHTS_VENGEANCE_3, 150.0f)) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); - playerGUID = 0; + playerGUID.Clear(); events.RescheduleEvent(2, 60000); } } @@ -1504,8 +1505,13 @@ public: void Reset() override { talkWing = 0; - memset(audienceList, 0, sizeof(audienceList)); - memset(imageList, 0, sizeof(imageList)); + + for (uint8 i = 0; i < 10; ++i) + audienceList[i].Clear(); + + for (uint8 i = 0; i < 5; ++i) + imageList[i].Clear(); + _events.ScheduleEvent(EVENT_GET_TARGETS, 5000); _events.ScheduleEvent(EVENT_START_RANDOM, 20000); } @@ -1730,9 +1736,9 @@ public: } private: EventMap _events; - uint64 audienceList[10]; - uint64 imageList[5]; - uint8 talkWing; + ObjectGuid audienceList[10]; + ObjectGuid imageList[5]; + uint8 talkWing; }; CreatureAI* GetAI(Creature* creature) const override @@ -1862,13 +1868,13 @@ public: { npc_torturer_lecraftAI(Creature* creature) : ScriptedAI(creature) { - _playerGUID = 0; + _playerGUID.Clear(); } void Reset() override { _textCounter = 1; - _playerGUID = 0; + _playerGUID.Clear(); } void EnterCombat(Unit* who) override @@ -1896,7 +1902,7 @@ public: Talk(_textCounter, player); if (_textCounter == 5) - player->KilledMonsterCredit(NPC_TORTURER_LECRAFT, 0); + player->KilledMonsterCredit(NPC_TORTURER_LECRAFT); ++_textCounter; @@ -1933,7 +1939,7 @@ public: private: EventMap _events; uint8 _textCounter; - uint64 _playerGUID; + ObjectGuid _playerGUID; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Northrend/zone_grizzly_hills.cpp b/src/server/scripts/Northrend/zone_grizzly_hills.cpp index 3e0012e9dc..f0736f8862 100644 --- a/src/server/scripts/Northrend/zone_grizzly_hills.cpp +++ b/src/server/scripts/Northrend/zone_grizzly_hills.cpp @@ -173,7 +173,7 @@ public: case 19: if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) { - if (Mrfloppy->HasAura(SPELL_MRFLOPPY, 0)) + if (Mrfloppy->HasAura(SPELL_MRFLOPPY)) { if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) Mrfloppy->EnterVehicle(RWORG); @@ -236,13 +236,13 @@ public: void Reset() override { - _mrfloppyGUID = 0; - _RavenousworgGUID = 0; + _mrfloppyGUID.Clear(); + _RavenousworgGUID.Clear(); } private: - uint64 _RavenousworgGUID; - uint64 _mrfloppyGUID; + ObjectGuid _RavenousworgGUID; + ObjectGuid _mrfloppyGUID; }; bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) override @@ -571,7 +571,7 @@ public: void Reset() override { _despawnTimer = 5000; - _playerGUID = 0; + _playerGUID.Clear(); } void MovementInform(uint32, uint32 id) override @@ -605,7 +605,7 @@ public: DoMeleeAttackIfReady(); } private: - uint64 _playerGUID; + ObjectGuid _playerGUID; uint32 _despawnTimer; }; @@ -649,7 +649,7 @@ public: void Reset() override { - _playerGUID = 0; + _playerGUID.Clear(); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC); me->SetReactState(REACT_AGGRESSIVE); @@ -711,7 +711,7 @@ public: private: EventMap _events; - uint64 _playerGUID; + ObjectGuid _playerGUID; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Northrend/zone_howling_fjord.cpp b/src/server/scripts/Northrend/zone_howling_fjord.cpp index 1ef8a39d4d..22e8289138 100644 --- a/src/server/scripts/Northrend/zone_howling_fjord.cpp +++ b/src/server/scripts/Northrend/zone_howling_fjord.cpp @@ -274,8 +274,7 @@ public: void Reset() override { - uint64 summonerGUID = 0; - + ObjectGuid summonerGUID; if (me->IsSummon()) if (Unit* summoner = me->ToTempSummon()->GetSummoner()) if (summoner->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/scripts/Northrend/zone_icecrown.cpp b/src/server/scripts/Northrend/zone_icecrown.cpp index 3829aef5d4..f2b543ca21 100644 --- a/src/server/scripts/Northrend/zone_icecrown.cpp +++ b/src/server/scripts/Northrend/zone_icecrown.cpp @@ -105,20 +105,19 @@ public: { npc_battle_at_valhalasAI(Creature* creature) : ScriptedAI(creature), summons(me) { - playerGUID2 = 0; } EventMap events; SummonList summons; - uint64 playerGUID; - uint64 playerGUID2; + ObjectGuid playerGUID; + ObjectGuid playerGUID2; uint32 currentQuest; void Reset() override { events.Reset(); summons.DespawnAll(); - playerGUID = 0; + playerGUID.Clear(); currentQuest = 0; me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); } @@ -161,7 +160,7 @@ public: } } - void StartBattle(uint64 guid, uint32 questId) + void StartBattle(ObjectGuid guid, uint32 questId) { events.ScheduleEvent(EVENT_VALHALAS_FIRST, 6000); events.ScheduleEvent(EVENT_VALHALAS_CHECK_PLAYER, 30000); @@ -172,8 +171,8 @@ public: void CheckSummons() { bool allow = true; - for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr) - if (Creature* cr = ObjectAccessor::GetCreature(*me, *itr)) + for (ObjectGuid guid : summons) + if (Creature* cr = ObjectAccessor::GetCreature(*me, guid)) if (cr->IsAlive()) allow = false; @@ -448,13 +447,13 @@ public: npc_lord_areteAI(Creature* creature) : ScriptedAI(creature) {} EventMap events; - uint64 _landgrenGUID; - uint64 _landgrenSoulGUID; + ObjectGuid _landgrenGUID; + ObjectGuid _landgrenSoulGUID; void InitializeAI() override { - _landgrenGUID = 0; - _landgrenSoulGUID = 0; + _landgrenGUID.Clear(); + _landgrenSoulGUID.Clear(); events.Reset(); events.RescheduleEvent(EVENT_START, 1000); @@ -1731,10 +1730,10 @@ public: SummonList Summons; - uint64 guidDalfors; - uint64 guidPriest[3]; - uint64 guidMason[3]; - uint64 guidHalof; + ObjectGuid guidDalfors; + ObjectGuid guidPriest[3]; + ObjectGuid guidMason[3]; + ObjectGuid guidHalof; void Reset() override { diff --git a/src/server/scripts/Northrend/zone_sholazar_basin.cpp b/src/server/scripts/Northrend/zone_sholazar_basin.cpp index 79c978c320..969d0ecf81 100644 --- a/src/server/scripts/Northrend/zone_sholazar_basin.cpp +++ b/src/server/scripts/Northrend/zone_sholazar_basin.cpp @@ -54,7 +54,7 @@ public: cr->SetDisplayId(cr->GetDisplayId() == NPC_SOWAW_WATER_MODEL ? NPC_SOWAW_WIND_MODEL : NPC_SOWAW_WATER_MODEL); if (Player* player = cr->GetCharmerOrOwnerPlayerOrPlayerItself()) { - player->KilledMonsterCredit(cr->GetDisplayId() == NPC_SOWAW_WATER_MODEL ? 29008 : 29009, 0); + player->KilledMonsterCredit(cr->GetDisplayId() == NPC_SOWAW_WATER_MODEL ? 29008 : 29009); CreatureTemplate const* ct = sObjectMgr->GetCreatureTemplate(cr->GetDisplayId() == NPC_SOWAW_WIND_MODEL ? NPC_SOWAW_WIND_ELEMENTAL : NPC_SOWAW_WATER_ELEMENTAL); for (uint8 i = 0; i < MAX_CREATURE_SPELLS; ++i) cr->m_spells[i] = ct->spells[i]; @@ -176,9 +176,9 @@ public: if (action == ACTION_BIND_MINIONS) me->CastSpell(me, SPELL_ARTRUIS_BINDING, true); - for (std::list<uint64>::const_iterator itr = summons.begin(); itr != summons.end(); ++itr) + for (ObjectGuid const guid : summons) { - Creature* minion = ObjectAccessor::GetCreature(*me, *itr); + Creature* minion = ObjectAccessor::GetCreature(*me, guid); if (minion && minion->IsAlive()) { if (action == ACTION_BIND_MINIONS) @@ -296,8 +296,8 @@ public: { bool running; bool success; - uint64 playerGUID; - uint64 thunderbrewGUID; + ObjectGuid playerGUID; + ObjectGuid thunderbrewGUID; int32 tensecstimer; int32 timer; uint8 stepcount; @@ -311,8 +311,8 @@ public: { running = false; success = false; - playerGUID = 0; - thunderbrewGUID = 0; + playerGUID.Clear(); + thunderbrewGUID.Clear(); tensecstimer = 0; timer = 0; stepcount = 0; @@ -342,7 +342,7 @@ public: Say(MCM_TEXT_START); } - void CheckAction(uint8 a, uint64 guid) + void CheckAction(uint8 a, ObjectGuid guid) { if (guid != playerGUID) return; @@ -881,8 +881,8 @@ public: sayStep = 0; timer = 0; phase = 0; - playerGUID = 0; - orphanGUID = 0; + playerGUID.Clear(); + orphanGUID.Clear(); } void MoveInLineOfSight(Unit* who) override @@ -1013,7 +1013,7 @@ public: if (itr->second.CreatureOrGOCount[i] != 0) continue; - player->KilledMonsterCredit(me->GetEntry(), 0); + player->KilledMonsterCredit(me->GetEntry()); player->MonsterSay(SAY_OFFER, LANG_UNIVERSAL, me); sayStep = 1; break; @@ -1025,8 +1025,8 @@ public: uint8 sayStep; uint32 timer; int8 phase; - uint64 playerGUID; - uint64 orphanGUID; + ObjectGuid playerGUID; + ObjectGuid orphanGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -1308,7 +1308,7 @@ public: apple->CastSpell(apple, SPELL_APPLE_FALL); wilhelm->AI()->Talk(SAY_WILHELM_HIT); if (Player* player = shooter->ToPlayer()) - player->KilledMonsterCredit(NPC_APPLE, 0); + player->KilledMonsterCredit(NPC_APPLE); //apple->DespawnOrUnsummon(); zomg! break; diff --git a/src/server/scripts/Northrend/zone_storm_peaks.cpp b/src/server/scripts/Northrend/zone_storm_peaks.cpp index c7b6ff756a..b4aef8456d 100644 --- a/src/server/scripts/Northrend/zone_storm_peaks.cpp +++ b/src/server/scripts/Northrend/zone_storm_peaks.cpp @@ -79,7 +79,7 @@ public: case 19: me->MonsterTextEmote("The frosthound has located the thief's hiding place. Confront him!", 0, true); if (Unit* summoner = me->ToTempSummon()->GetSummoner()) - summoner->ToPlayer()->KilledMonsterCredit(29677, 0); + summoner->ToPlayer()->KilledMonsterCredit(29677); break; } } @@ -145,7 +145,7 @@ public: { me->RemoveAllAurasExceptType(SPELL_AURA_MECHANIC_IMMUNITY); Talk(1); - caster->ToPlayer()->KilledMonsterCredit(me->GetEntry(), 0); + caster->ToPlayer()->KilledMonsterCredit(me->GetEntry()); me->DespawnOrUnsummon(8000); me->GetMotionMaster()->MoveJump(8721.94f, -1955, 963, 70.0f, 30.0f); } @@ -233,7 +233,7 @@ public: void RollPath() { me->SetEntry(NPC_TIME_LOST_PROTO_DRAKE); - Start(true, true, 0, 0, false, true, true); + Start(true, true, ObjectGuid::Empty, 0, false, true, true); SetNextWaypoint(urand(0, 250), true); me->UpdateEntry(roll_chance_i(25) ? NPC_TIME_LOST_PROTO_DRAKE : NPC_VYRAGOSA, 0, false); } @@ -329,7 +329,7 @@ public: { npc_wild_wyrmAI(Creature* creature) : ScriptedAI(creature) {} - uint64 playerGUID; + ObjectGuid playerGUID; uint32 checkTimer; uint32 announceAttackTimer; uint32 attackTimer; @@ -352,7 +352,7 @@ public: switching = false; startPath = false; checkTimer = 0; - playerGUID = 0; + playerGUID.Clear(); attackTimer = 0; announceAttackTimer = 0; me->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD); @@ -430,7 +430,7 @@ public: { if (Player* player = GetValidPlayer()) { - player->KilledMonsterCredit(30415, 0); + player->KilledMonsterCredit(30415); player->RemoveAurasDueToSpell(SPELL_JAWS_OF_DEATH); } me->SetStandState(UNIT_STAND_STATE_DEAD); diff --git a/src/server/scripts/Northrend/zone_zuldrak.cpp b/src/server/scripts/Northrend/zone_zuldrak.cpp index 998c61bf86..5ce8399b22 100644 --- a/src/server/scripts/Northrend/zone_zuldrak.cpp +++ b/src/server/scripts/Northrend/zone_zuldrak.cpp @@ -40,27 +40,27 @@ public: { npc_finklesteinAI(Creature* creature) : ScriptedAI(creature) {} - std::map<uint64, uint32> questList; + std::map<ObjectGuid, uint32> questList; - void ClearPlayerOnTask(uint64 guid) + void ClearPlayerOnTask(ObjectGuid guid) { - std::map<uint64, uint32>::iterator itr = questList.find(guid); + std::map<ObjectGuid, uint32>::iterator itr = questList.find(guid); if (itr != questList.end()) questList.erase(itr); } - bool IsPlayerOnTask(uint64 guid) + bool IsPlayerOnTask(ObjectGuid guid) { - std::map<uint64, uint32>::const_iterator itr = questList.find(guid); + std::map<ObjectGuid, uint32>::const_iterator itr = questList.find(guid); return itr != questList.end(); } - void RightClickCauldron(uint64 guid) + void RightClickCauldron(ObjectGuid guid) { if (questList.empty()) return; - std::map<uint64, uint32>::iterator itr = questList.find(guid); + std::map<ObjectGuid, uint32>::iterator itr = questList.find(guid); if (itr == questList.end()) return; @@ -88,7 +88,7 @@ public: return; } else - player->KilledMonsterCredit(28248, 0); + player->KilledMonsterCredit(28248); } else { @@ -100,7 +100,7 @@ public: } // Generate a Task and announce it to the player - void StartNextTask(uint64 playerGUID, uint32 counter) + void StartNextTask(ObjectGuid playerGUID, uint32 counter) { if (counter > 6) return; @@ -241,11 +241,11 @@ public: struct npc_feedin_da_goolzAI : public NullCreatureAI { - npc_feedin_da_goolzAI(Creature* creature) : NullCreatureAI(creature) { findTimer = 1; checkTimer = 0; ghoulFed = 0; } + npc_feedin_da_goolzAI(Creature* creature) : NullCreatureAI(creature) { findTimer = 1; checkTimer = 0; } uint32 findTimer; uint32 checkTimer; - uint64 ghoulFed; + ObjectGuid ghoulFed; void UpdateAI(uint32 diff) override { @@ -295,7 +295,7 @@ public: if (Unit* owner = me->ToTempSummon()->GetSummoner()) if (Player* player = owner->ToPlayer()) - player->KilledMonsterCredit(me->GetEntry(), 0); + player->KilledMonsterCredit(me->GetEntry()); me->DespawnOrUnsummon(1); } @@ -376,8 +376,8 @@ public: EventMap events; SummonList summons; - uint64 playerGUID; - uint64 lichGUID; + ObjectGuid playerGUID; + ObjectGuid lichGUID; void EnterEvadeMode() override { @@ -394,8 +394,8 @@ public: { events.Reset(); summons.DespawnAll(); - playerGUID = 0; - lichGUID = 0; + playerGUID.Clear(); + lichGUID.Clear(); me->setFaction(974); me->SetVisible(false); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -563,7 +563,7 @@ public: events.ScheduleEvent(EVENT_BETRAYAL_14, 7000); break; case EVENT_BETRAYAL_14: - playerGUID = 0; + playerGUID.Clear(); EnterEvadeMode(); break; } @@ -620,7 +620,7 @@ public: { npc_drakuru_shacklesAI(Creature* creature) : NullCreatureAI(creature) { - _rageclawGUID = 0; + _rageclawGUID.Clear(); timer = 0; } @@ -660,7 +660,7 @@ public: { // pointer check not needed DoCast(rageclaw, SPELL_FREE_RAGECLAW, true); - _rageclawGUID = 0; + _rageclawGUID.Clear(); me->DespawnOrUnsummon(1); } @@ -683,7 +683,7 @@ public: } private: - uint64 _rageclawGUID; + ObjectGuid _rageclawGUID; uint32 timer; }; diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp index 0bfec52721..1a4490d518 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp @@ -9,6 +9,7 @@ #include "GameObject.h" #include "GossipDef.h" #include "Language.h" +#include "MapManager.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "OutdoorPvPEP.h" @@ -70,22 +71,20 @@ void OPvPCapturePointEP_EWT::ChangeState() break; } - GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID); - GameObject* flag2 = HashMapHolder<GameObject>::Find(m_Objects[EP_EWT_FLAGS]); - if (flag) - { - flag->SetGoArtKit(artkit); - } - if (flag2) - { - flag2->SetGoArtKit(artkit); - } + Map* map = sMapMgr->FindMap(0, 0); + auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_capturePointSpawnId); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); + + bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_Objects[EP_EWT_FLAGS]); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); UpdateTowerState(); // complete quest objective if (m_TowerState == EP_TS_A || m_TowerState == EP_TS_H) - SendObjectiveComplete(EP_EWT_CM, 0); + SendObjectiveComplete(EP_EWT_CM); } void OPvPCapturePointEP_EWT::SendChangePhase() @@ -218,22 +217,20 @@ void OPvPCapturePointEP_NPT::ChangeState() break; } - GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID); - GameObject* flag2 = HashMapHolder<GameObject>::Find(m_Objects[EP_NPT_FLAGS]); - if (flag) - { - flag->SetGoArtKit(artkit); - } - if (flag2) - { - flag2->SetGoArtKit(artkit); - } + Map* map = sMapMgr->FindMap(0, 0); + auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_capturePointSpawnId); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); + + bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_Objects[EP_NPT_FLAGS]); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); UpdateTowerState(); // complete quest objective if (m_TowerState == EP_TS_A || m_TowerState == EP_TS_H) - SendObjectiveComplete(EP_NPT_CM, 0); + SendObjectiveComplete(EP_NPT_CM); } void OPvPCapturePointEP_NPT::SendChangePhase() @@ -291,9 +288,11 @@ void OPvPCapturePointEP_NPT::SummonGO(TeamId teamId) m_SummonedGOSideId = teamId; DelObject(EP_NPT_BUFF); AddObject(EP_NPT_BUFF, EP_NPT_LordaeronShrine.entry, EP_NPT_LordaeronShrine.map, EP_NPT_LordaeronShrine.x, EP_NPT_LordaeronShrine.y, EP_NPT_LordaeronShrine.z, EP_NPT_LordaeronShrine.o, EP_NPT_LordaeronShrine.rot0, EP_NPT_LordaeronShrine.rot1, EP_NPT_LordaeronShrine.rot2, EP_NPT_LordaeronShrine.rot3); - GameObject* go = HashMapHolder<GameObject>::Find(m_Objects[EP_NPT_BUFF]); - if (go) - go->SetUInt32Value(GAMEOBJECT_FACTION, (teamId == TEAM_ALLIANCE ? 84 : 83)); + Map* map = sMapMgr->FindMap(0, 0); + auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_Objects[EP_NPT_BUFF]); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + if (GameObject* go = itr->second) + go->SetUInt32Value(GAMEOBJECT_FACTION, (teamId == TEAM_ALLIANCE ? 84 : 83)); } } @@ -350,22 +349,20 @@ void OPvPCapturePointEP_CGT::ChangeState() break; } - GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID); - GameObject* flag2 = HashMapHolder<GameObject>::Find(m_Objects[EP_CGT_FLAGS]); - if (flag) - { - flag->SetGoArtKit(artkit); - } - if (flag2) - { - flag2->SetGoArtKit(artkit); - } + Map* map = sMapMgr->FindMap(0, 0); + auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_capturePointSpawnId); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); + + bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_Objects[EP_CGT_FLAGS]); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); UpdateTowerState(); // complete quest objective if (m_TowerState == EP_TS_A || m_TowerState == EP_TS_H) - SendObjectiveComplete(EP_CGT_CM, 0); + SendObjectiveComplete(EP_CGT_CM); } void OPvPCapturePointEP_CGT::SendChangePhase() @@ -489,22 +486,20 @@ void OPvPCapturePointEP_PWT::ChangeState() break; } - GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID); - GameObject* flag2 = HashMapHolder<GameObject>::Find(m_Objects[EP_PWT_FLAGS]); - if (flag) - { - flag->SetGoArtKit(artkit); - } - if (flag2) - { - flag2->SetGoArtKit(artkit); - } + Map* map = sMapMgr->FindMap(0, 0); + auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_capturePointSpawnId); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); + + bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_Objects[EP_PWT_FLAGS]); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); UpdateTowerState(); // complete quest objective if (m_TowerState == EP_TS_A || m_TowerState == EP_TS_H) - SendObjectiveComplete(EP_PWT_CM, 0); + SendObjectiveComplete(EP_PWT_CM); } void OPvPCapturePointEP_PWT::SendChangePhase() @@ -619,10 +614,13 @@ bool OutdoorPvPEP::SetupOutdoorPvP() for (uint8 i = 0; i < EPBuffZonesNum; ++i) RegisterZone(EPBuffZones[i]); + SetMapFromZone(EPBuffZones[0]); + AddCapturePoint(new OPvPCapturePointEP_EWT(this)); AddCapturePoint(new OPvPCapturePointEP_PWT(this)); AddCapturePoint(new OPvPCapturePointEP_CGT(this)); AddCapturePoint(new OPvPCapturePointEP_NPT(this)); + return true; } diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPGH.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPGH.cpp index 49dc807613..a681f26190 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPGH.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPGH.cpp @@ -6,6 +6,7 @@ #include "GameEventMgr.h" #include "Language.h" +#include "MapManager.h" #include "ObjectMgr.h" #include "OutdoorPvPGH.h" #include "OutdoorPvPMgr.h" @@ -22,6 +23,8 @@ OutdoorPvPGH::OutdoorPvPGH() bool OutdoorPvPGH::SetupOutdoorPvP() { RegisterZone(GH_ZONE); + SetMapFromZone(GH_ZONE); + if ((m_obj = new OPvPCapturePointGH(this))) { AddCapturePoint(m_obj); @@ -99,8 +102,10 @@ void OPvPCapturePointGH::ChangeState() break; } - if (GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID)) - flag->SetGoArtKit(artkit); + Map* map = sMapMgr->FindMap(571, 0); + auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_capturePointSpawnId); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); } class OutdoorPvP_grizzly_hills : public OutdoorPvPScript diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp index a9dbab1794..4973c51f98 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp @@ -5,6 +5,7 @@ */ #include "Language.h" +#include "MapManager.h" #include "ObjectMgr.h" #include "OutdoorPvP.h" #include "OutdoorPvPHP.h" @@ -63,6 +64,8 @@ bool OutdoorPvPHP::SetupOutdoorPvP() for (int i = 0; i < OutdoorPvPHPBuffZonesNum; ++i) RegisterZone(OutdoorPvPHPBuffZones[i]); + SetMapFromZone(OutdoorPvPHPBuffZones[0]); + AddCapturePoint(new OPvPCapturePointHP(this, HP_TOWER_BROKEN_HILL)); AddCapturePoint(new OPvPCapturePointHP(this, HP_TOWER_OVERLOOK)); @@ -241,16 +244,14 @@ void OPvPCapturePointHP::ChangeState() break; } - GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID); - GameObject* flag2 = HashMapHolder<GameObject>::Find(m_Objects[m_TowerType]); - if (flag) - { - flag->SetGoArtKit(artkit); - } - if (flag2) - { - flag2->SetGoArtKit(artkit2); - } + Map* map = sMapMgr->FindMap(530, 0); + auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_capturePointSpawnId); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); + + bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_Objects[m_TowerType]); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit2); // send world state update if (field) @@ -258,7 +259,7 @@ void OPvPCapturePointHP::ChangeState() // complete quest objective if (m_State == OBJECTIVESTATE_ALLIANCE || m_State == OBJECTIVESTATE_HORDE) - SendObjectiveComplete(HP_CREDITMARKER[m_TowerType], 0); + SendObjectiveComplete(HP_CREDITMARKER[m_TowerType]); } void OPvPCapturePointHP::SendChangePhase() diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp index 99336f4d77..43774e3da5 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp @@ -5,6 +5,7 @@ */ #include "GameGraveyard.h" +#include "MapManager.h" #include "Language.h" #include "ObjectMgr.h" #include "OutdoorPvPMgr.h" @@ -24,7 +25,7 @@ void OutdoorPvPNA::HandleKillImpl(Player* player, Unit* killed) { if (killed->GetTypeId() == TYPEID_PLAYER && player->GetTeamId() != killed->ToPlayer()->GetTeamId()) { - player->KilledMonsterCredit(NA_CREDIT_MARKER, 0); // 0 guid, btw it isn't even used in killedmonster function :S + player->KilledMonsterCredit(NA_CREDIT_MARKER); player->CastSpell(player, player->GetTeamId() == TEAM_ALLIANCE ? NA_KILL_TOKEN_ALLIANCE : NA_KILL_TOKEN_HORDE, true); } } @@ -32,7 +33,7 @@ void OutdoorPvPNA::HandleKillImpl(Player* player, Unit* killed) uint32 OPvPCapturePointNA::GetAliveGuardsCount() { uint32 cnt = 0; - for (std::map<uint32, uint64>::iterator itr = m_Creatures.begin(); itr != m_Creatures.end(); ++itr) + for (std::map<uint32, ObjectGuid::LowType>::iterator itr = m_Creatures.begin(); itr != m_Creatures.end(); ++itr) { switch (itr->first) { @@ -51,10 +52,13 @@ uint32 OPvPCapturePointNA::GetAliveGuardsCount() case NA_NPC_GUARD_13: case NA_NPC_GUARD_14: case NA_NPC_GUARD_15: - if (Creature const* const cr = HashMapHolder<Creature>::Find(itr->second)) - if (cr->IsAlive()) + { + auto bounds = m_PvP->GetMap()->GetCreatureBySpawnIdStore().equal_range(itr->second); + for (auto itr2 = bounds.first; itr2 != bounds.second; ++itr2) + if (itr2->second->IsAlive()) ++cnt; break; + } default: break; } @@ -199,6 +203,7 @@ bool OutdoorPvPNA::SetupOutdoorPvP() // m_TypeId = OUTDOOR_PVP_NA; _MUST_ be set in ctor, because of spawns cleanup // add the zones affected by the pvp buff RegisterZone(NA_BUFF_ZONE); + SetMapFromZone(NA_BUFF_ZONE); // halaa m_obj = new OPvPCapturePointNA(this); @@ -393,9 +398,9 @@ bool OPvPCapturePointNA::HandleCustomSpell(Player* player, uint32 spellId, GameO return false; } -int32 OPvPCapturePointNA::HandleOpenGo(Player* player, uint64 guid) +int32 OPvPCapturePointNA::HandleOpenGo(Player* player, GameObject* go) { - int32 retval = OPvPCapturePoint::HandleOpenGo(player, guid); + int32 retval = OPvPCapturePoint::HandleOpenGo(player, go); if (retval >= 0) { const go_type* gos = nullptr; @@ -588,11 +593,9 @@ void OPvPCapturePointNA::ChangeState() break; } - GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID); - if (flag) - { - flag->SetGoArtKit(artkit); - } + auto bounds = sMapMgr->FindMap(530, 0)->GetGameObjectBySpawnIdStore().equal_range(m_capturePointSpawnId); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); UpdateHalaaWorldState(); } diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.h b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.h index 07c1410325..8567773439 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.h +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.h @@ -258,7 +258,7 @@ public: bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go) override; - int32 HandleOpenGo(Player* player, uint64 guid) override; + int32 HandleOpenGo(Player* player, GameObject* go) override; uint32 GetAliveGuardsCount(); TeamId GetControllingFaction() const; diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp index ad21cb4497..a6fb58b7e7 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp @@ -50,6 +50,9 @@ bool OutdoorPvPSI::SetupOutdoorPvP() { for (uint8 i = 0; i < OutdoorPvPSIBuffZonesNum; ++i) RegisterZone(OutdoorPvPSIBuffZones[i]); + + SetMapFromZone(OutdoorPvPSIBuffZones[0]); + return true; } @@ -101,7 +104,7 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 trigger) // add 20 cenarion circle repu player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20); // complete quest - player->KilledMonsterCredit(SI_TURNIN_QUEST_CM_A, 0); + player->KilledMonsterCredit(SI_TURNIN_QUEST_CM_A); } return true; case SI_AREATRIGGER_H: @@ -127,7 +130,7 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 trigger) // add 20 cenarion circle repu player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20); // complete quest - player->KilledMonsterCredit(SI_TURNIN_QUEST_CM_H, 0); + player->KilledMonsterCredit(SI_TURNIN_QUEST_CM_H); } return true; } @@ -158,7 +161,7 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) return true; } - if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), SI_SILITHYST_MOUND, map, player->GetPhaseMask(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) + if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), SI_SILITHYST_MOUND, map, player->GetPhaseMask(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) { delete go; return true; @@ -192,7 +195,7 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) return true; } - if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), SI_SILITHYST_MOUND, map, player->GetPhaseMask(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) + if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), SI_SILITHYST_MOUND, map, player->GetPhaseMask(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY)) { delete go; return true; diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp index 124174a9e1..a0c85d8b7c 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp @@ -5,6 +5,7 @@ */ #include "Language.h" +#include "MapManager.h" #include "ObjectMgr.h" #include "OutdoorPvP.h" #include "OutdoorPvPMgr.h" @@ -250,6 +251,8 @@ bool OutdoorPvPTF::SetupOutdoorPvP() for (uint8 i = 0; i < OutdoorPvPTFBuffZonesNum; ++i) RegisterZone(OutdoorPvPTFBuffZones[i]); + SetMapFromZone(OutdoorPvPTFBuffZones[0]); + AddCapturePoint(new OPvPCapturePointTF(this, TF_TOWER_NW)); AddCapturePoint(new OPvPCapturePointTF(this, TF_TOWER_N)); AddCapturePoint(new OPvPCapturePointTF(this, TF_TOWER_NE)); @@ -329,9 +332,9 @@ void OPvPCapturePointTF::ChangeState() break; } - GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID); - if (flag) - flag->SetGoArtKit(artkit); + auto bounds = sMapMgr->FindMap(530, 0)->GetGameObjectBySpawnIdStore().equal_range(m_capturePointSpawnId); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + itr->second->SetGoArtKit(artkit); UpdateTowerState(); } diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp index 3baec5cd6f..212f0a796c 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp @@ -177,6 +177,8 @@ bool OutdoorPvPZM::SetupOutdoorPvP() for (uint8 i = 0; i < OutdoorPvPZMBuffZonesNum; ++i) RegisterZone(OutdoorPvPZMBuffZones[i]); + SetMapFromZone(OutdoorPvPZMBuffZones[0]); + AddCapturePoint(new OPvPCapturePointZM_Beacon(this, ZM_BEACON_WEST)); AddCapturePoint(new OPvPCapturePointZM_Beacon(this, ZM_BEACON_EAST)); m_GraveYard = new OPvPCapturePointZM_GraveYard(this); @@ -203,9 +205,9 @@ bool OPvPCapturePointZM_GraveYard::Update(uint32 /*diff*/) return retval; } -int32 OPvPCapturePointZM_GraveYard::HandleOpenGo(Player* player, uint64 guid) +int32 OPvPCapturePointZM_GraveYard::HandleOpenGo(Player* player, GameObject* go) { - int32 retval = OPvPCapturePoint::HandleOpenGo(player, guid); + int32 retval = OPvPCapturePoint::HandleOpenGo(player, go); if (retval >= 0) { if (player->HasAura(ZM_BATTLE_STANDARD_A) && m_GraveYardState != ZM_GRAVEYARD_A) @@ -244,7 +246,7 @@ OPvPCapturePointZM_GraveYard::OPvPCapturePointZM_GraveYard(OutdoorPvP* pvp) { m_BothControllingFactionId = TEAM_NEUTRAL; m_GraveYardState = ZM_GRAVEYARD_N; - m_FlagCarrierGUID = 0; + m_FlagCarrierGUID.Clear(); // add field scouts here AddCreature(ZM_ALLIANCE_FIELD_SCOUT, ZM_AllianceFieldScout.entry, ZM_AllianceFieldScout.map, ZM_AllianceFieldScout.x, ZM_AllianceFieldScout.y, ZM_AllianceFieldScout.z, ZM_AllianceFieldScout.o); AddCreature(ZM_HORDE_FIELD_SCOUT, ZM_HordeFieldScout.entry, ZM_HordeFieldScout.map, ZM_HordeFieldScout.x, ZM_HordeFieldScout.y, ZM_HordeFieldScout.z, ZM_HordeFieldScout.o); @@ -312,7 +314,7 @@ void OPvPCapturePointZM_GraveYard::SetBeaconState(TeamId controlling_factionId) p->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_A); p->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_H); } - m_FlagCarrierGUID = 0; + m_FlagCarrierGUID.Clear(); } } break; @@ -323,8 +325,8 @@ void OPvPCapturePointZM_GraveYard::SetBeaconState(TeamId controlling_factionId) bool OPvPCapturePointZM_GraveYard::CanTalkTo(Player* player, Creature* c, GossipMenuItems const& /*gso*/) { - uint64 guid = c->GetGUID(); - std::map<uint64, uint32>::iterator itr = m_CreatureTypes.find(guid); + ObjectGuid guid = c->GetGUID(); + std::map<ObjectGuid::LowType, uint32>::iterator itr = m_CreatureTypes.find(guid.GetCounter()); if (itr != m_CreatureTypes.end()) { if (itr->second == ZM_ALLIANCE_FIELD_SCOUT && player->GetTeamId() == TEAM_ALLIANCE && m_BothControllingFactionId == TEAM_ALLIANCE && !m_FlagCarrierGUID && m_GraveYardState != ZM_GRAVEYARD_A) @@ -335,27 +337,26 @@ bool OPvPCapturePointZM_GraveYard::CanTalkTo(Player* player, Creature* c, Gossip return false; } -bool OPvPCapturePointZM_GraveYard::HandleGossipOption(Player* player, uint64 guid, uint32 /*gossipid*/) +bool OPvPCapturePointZM_GraveYard::HandleGossipOption(Player* player, Creature* creature, uint32 /*gossipid*/) { - std::map<uint64, uint32>::iterator itr = m_CreatureTypes.find(guid); + std::map<ObjectGuid::LowType, uint32>::iterator itr = m_CreatureTypes.find(creature->GetSpawnId()); if (itr != m_CreatureTypes.end()) { - Creature* cr = HashMapHolder<Creature>::Find(guid); - if (!cr) - return true; // if the flag is already taken, then return if (m_FlagCarrierGUID) return true; + if (itr->second == ZM_ALLIANCE_FIELD_SCOUT) { - cr->CastSpell(player, ZM_BATTLE_STANDARD_A, true); + creature->CastSpell(player, ZM_BATTLE_STANDARD_A, true); m_FlagCarrierGUID = player->GetGUID(); } else if (itr->second == ZM_HORDE_FIELD_SCOUT) { - cr->CastSpell(player, ZM_BATTLE_STANDARD_H, true); + creature->CastSpell(player, ZM_BATTLE_STANDARD_H, true); m_FlagCarrierGUID = player->GetGUID(); } + UpdateTowerState(); player->PlayerTalkClass->SendCloseGossip(); return true; @@ -368,10 +369,10 @@ bool OPvPCapturePointZM_GraveYard::HandleDropFlag(Player* /*player*/, uint32 spe switch (spellId) { case ZM_BATTLE_STANDARD_A: - m_FlagCarrierGUID = 0; + m_FlagCarrierGUID.Clear(); return true; case ZM_BATTLE_STANDARD_H: - m_FlagCarrierGUID = 0; + m_FlagCarrierGUID.Clear(); return true; } return false; diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.h b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.h index 10eb79ee3d..e59a96fedf 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.h +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.h @@ -197,11 +197,11 @@ public: void UpdateTowerState(); - int32 HandleOpenGo(Player* player, uint64 guid) override; + int32 HandleOpenGo(Player* player, GameObject* go) override; void SetBeaconState(TeamId controlling_teamId); // not good atm - bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid) override; + bool HandleGossipOption(Player* player, Creature* creature, uint32 gossipid) override; bool HandleDropFlag(Player* player, uint32 spellId) override; @@ -214,7 +214,7 @@ private: protected: TeamId m_BothControllingFactionId; - uint64 m_FlagCarrierGUID; + ObjectGuid m_FlagCarrierGUID; }; class OutdoorPvPZM : public OutdoorPvP diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp index 0948569140..ee120667ea 100644 --- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp +++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp @@ -50,7 +50,7 @@ public: } EventMap events; - uint64 focusGUID; + ObjectGuid focusGUID; void EnterEvadeMode() override { @@ -61,7 +61,7 @@ public: void Reset() override { events.Reset(); - focusGUID = 0; + focusGUID.Clear(); me->SetControlled(false, UNIT_STATE_ROOT); } diff --git a/src/server/scripts/Outland/Auchindoun/SethekkHalls/instance_sethekk_halls.cpp b/src/server/scripts/Outland/Auchindoun/SethekkHalls/instance_sethekk_halls.cpp index bb32834cd6..48e634c9ae 100644 --- a/src/server/scripts/Outland/Auchindoun/SethekkHalls/instance_sethekk_halls.cpp +++ b/src/server/scripts/Outland/Auchindoun/SethekkHalls/instance_sethekk_halls.cpp @@ -21,14 +21,12 @@ public: instance_sethekk_halls_InstanceMapScript(Map* map) : InstanceScript(map) {} uint32 AnzuEncounter; - uint64 m_uiIkissDoorGUID; - uint64 _talonKingsCofferGUID; + ObjectGuid m_uiIkissDoorGUID; + ObjectGuid _talonKingsCofferGUID; void Initialize() override { AnzuEncounter = NOT_STARTED; - m_uiIkissDoorGUID = 0; - _talonKingsCofferGUID = 0; } void OnCreatureCreate(Creature* creature) override diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_ambassador_hellmaw.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_ambassador_hellmaw.cpp index 8e35bfa94b..a636f4df36 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_ambassador_hellmaw.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_ambassador_hellmaw.cpp @@ -53,7 +53,7 @@ public: me->RemoveAurasDueToSpell(SPELL_BANISH); Talk(SAY_INTRO); - Start(true, false, 0, nullptr, false, true); + Start(true, false, ObjectGuid::Empty, nullptr, false, true); isBanished = false; } @@ -70,7 +70,7 @@ public: me->CastSpell(me, SPELL_BANISH, true); } else - Start(true, false, 0, nullptr, false, true); + Start(true, false, ObjectGuid::Empty, nullptr, false, true); } } diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp index f125a4f436..b7965cd202 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp @@ -208,16 +208,15 @@ public: { npc_voidtravelerAI(Creature* creature) : ScriptedAI(creature) { - VorpilGUID = 0; moveTimer = 1000; sacrificed = false; } - uint64 VorpilGUID; + ObjectGuid VorpilGUID; uint32 moveTimer; bool sacrificed; - void SetGUID(uint64 guid, int32) override + void SetGUID(ObjectGuid guid, int32) override { VorpilGUID = guid; } diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp index 5c73d33963..41f74dc39d 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp @@ -22,9 +22,9 @@ public: uint32 m_auiEncounter[MAX_ENCOUNTER]; - uint64 m_uiHellmawGUID; - uint64 m_uiRefectoryDoorGUID; - uint64 m_uiScreamingHallDoorGUID; + ObjectGuid m_uiHellmawGUID; + ObjectGuid m_uiRefectoryDoorGUID; + ObjectGuid m_uiScreamingHallDoorGUID; uint32 m_uiFelOverseerCount; @@ -32,10 +32,6 @@ public: { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - m_uiHellmawGUID = 0; - m_uiRefectoryDoorGUID = 0; - m_uiScreamingHallDoorGUID = 0; - m_uiFelOverseerCount = 0; } diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index 4fb86cbfc4..5495e0d71b 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -223,7 +223,7 @@ public: { BossAI::EnterEvadeMode(); - if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_AKAMA))) + if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_AKAMA))) akama->AI()->EnterEvadeMode(); } @@ -395,7 +395,7 @@ public: switch (events2.ExecuteEvent()) { case EVENT_SUMMON_MINIONS2: - if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_AKAMA))) + if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_AKAMA))) akama->AI()->DoAction(ACTION_FIGHT_MINIONS); break; case EVENT_PHASE_2_EYE_BEAM_START: @@ -432,7 +432,7 @@ public: maiev->AI()->Talk(SAY_MAIEV_SHADOWSONG_ILLIDAN3); } - if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_AKAMA))) + if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_AKAMA))) { akama->AI()->DoAction(ACTION_ILLIDAN_DEAD); akama->SetTarget(me->GetGUID()); @@ -554,7 +554,7 @@ public: Talk(SAY_ILLIDAN_TAKEOFF); me->SendMeleeAttackStop(me->GetVictim()); - me->SetTarget(0); + me->SetTarget(); me->GetMotionMaster()->Clear(); me->StopMovingOnCurrentPos(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -912,40 +912,40 @@ public: SetEscortPaused(false); break; case EVENT_AKAMA_SCENE_20: - if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ILLIDAN_STORMRAGE))) + if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDAN_STORMRAGE))) illidan->SetStandState(UNIT_STAND_STATE_STAND); break; case EVENT_AKAMA_SCENE_21: me->SetFacingTo(M_PI); break; case EVENT_AKAMA_SCENE_22: - if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ILLIDAN_STORMRAGE))) + if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDAN_STORMRAGE))) illidan->AI()->Talk(SAY_ILLIDAN_AKAMA1); break; case EVENT_AKAMA_SCENE_23: Talk(SAY_AKAMA_ILLIDAN1); break; case EVENT_AKAMA_SCENE_24: - if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ILLIDAN_STORMRAGE))) + if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDAN_STORMRAGE))) illidan->AI()->Talk(SAY_ILLIDAN_AKAMA2); break; case EVENT_AKAMA_SCENE_25: Talk(SAY_AKAMA_ILLIDAN2); break; case EVENT_AKAMA_SCENE_26: - if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ILLIDAN_STORMRAGE))) + if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDAN_STORMRAGE))) illidan->AI()->Talk(SAY_ILLIDAN_AKAMA3); break; case EVENT_AKAMA_SCENE_27: - if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ILLIDAN_STORMRAGE))) + if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDAN_STORMRAGE))) illidan->LoadEquipment(1, true); break; case EVENT_AKAMA_SCENE_28: - if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ILLIDAN_STORMRAGE))) + if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDAN_STORMRAGE))) illidan->HandleEmoteCommand(EMOTE_ONESHOT_TALK_NO_SHEATHE); break; case EVENT_AKAMA_SCENE_29: - if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ILLIDAN_STORMRAGE))) + if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDAN_STORMRAGE))) { illidan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC); illidan->SetInCombatWithZone(); diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index df38c7b4ee..f6b314dcf5 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -285,7 +285,7 @@ public: return; me->m_Events.AddEvent(new SuckBackEvent(*me, ACTION_ESSENCE_OF_SUFFERING), me->m_Events.CalculateTime(1500)); - me->SetTarget(0); + me->SetTarget(); me->SetFacingTo(M_PI / 2.0f); } @@ -396,7 +396,7 @@ public: return; me->m_Events.AddEvent(new SuckBackEvent(*me, ACTION_ESSENCE_OF_DESIRE), me->m_Events.CalculateTime(1500)); - me->SetTarget(0); + me->SetTarget(); me->SetFacingTo(M_PI / 2.0f); } @@ -483,11 +483,11 @@ public: boss_essence_of_angerAI(Creature* creature) : ScriptedAI(creature) { } EventMap events; - uint64 targetGUID; + ObjectGuid targetGUID; void Reset() override { - targetGUID = 0; + targetGUID.Clear(); events.Reset(); } @@ -552,7 +552,7 @@ public: case EVENT_ANGER_SEETHE: if (Unit* victim = me->GetVictim()) { - uint64 victimGUID = victim->GetGUID(); + ObjectGuid victimGUID = victim->GetGUID(); if (targetGUID && targetGUID != victimGUID) me->CastSpell(me, SPELL_SEETHE, false); // victim can be lost diff --git a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp index 8bfbe7d615..6a3f077ef7 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp @@ -137,7 +137,7 @@ public: summonsGenerator.DoAction(ACTION_DESPAWN_ALL); summonsChanneler.DespawnAll(); me->CastSpell(me, SPELL_SHADE_OF_AKAMA_TRIGGER, true); - if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_AKAMA_SHADE))) + if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_AKAMA_SHADE))) { akama->SetHomePosition(*akama); akama->AI()->DoAction(ACTION_SHADE_DIED); @@ -184,7 +184,7 @@ public: summonsGenerator.Respawn(); ChannelersAction(ACTION_CHANNELERS_START_CHANNEL); - if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_AKAMA_SHADE))) + if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_AKAMA_SHADE))) akama->Respawn(true); break; } @@ -194,7 +194,7 @@ public: summonsChanneler.Respawn(); ChannelersAction(ACTION_CHANNELERS_START_CHANNEL); - if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_AKAMA_SHADE))) + if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_AKAMA_SHADE))) akama->Respawn(true); break; } @@ -314,7 +314,7 @@ public: void JustDied(Unit* /*killer*/) override { - if (Creature* shade = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_SHADE_OF_AKAMA))) + if (Creature* shade = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_SHADE_OF_AKAMA))) shade->AI()->DoAction(ACTION_AKAMA_DIED); } @@ -345,7 +345,7 @@ public: break; case EVENT_AKAMA_START_CHANNEL: me->CastSpell(me, SPELL_AKAMA_SOUL_CHANNEL, false); - if (Creature* shade = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_SHADE_OF_AKAMA))) + if (Creature* shade = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_SHADE_OF_AKAMA))) { shade->AI()->AttackStart(me); shade->GetMotionMaster()->Clear(); @@ -467,7 +467,7 @@ public: } summon->SetInCombatWithZone(); - if (Unit* akama = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_AKAMA_SHADE))) + if (Unit* akama = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_AKAMA_SHADE))) { summon->AddThreat(akama, 500.0f); summon->AI()->AttackStart(akama); diff --git a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp index 96f0f33a39..3b831447c5 100644 --- a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp +++ b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp @@ -100,7 +100,7 @@ struct HammerOfJusticeSelector : public acore::unary_function<Unit*, bool> class VerasEnvenom : public BasicEvent { public: - VerasEnvenom(Unit& owner, uint64 targetGUID) : _owner(owner), _targetGUID(targetGUID) { } + VerasEnvenom(Unit& owner, ObjectGuid targetGUID) : _owner(owner), _targetGUID(targetGUID) { } bool Execute(uint64 /*eventTime*/, uint32 /*updateTime*/) override { @@ -116,7 +116,7 @@ public: private: Unit& _owner; - uint64 _targetGUID; + ObjectGuid _targetGUID; }; class boss_illidari_council : public CreatureScript @@ -133,10 +133,9 @@ public: { boss_illidari_councilAI(Creature* creature) : BossAI(creature, DATA_ILLIDARI_COUNCIL) { - memset(councilGUIDs, 0, sizeof(councilGUIDs)); } - uint64 councilGUIDs[4]; + ObjectGuid councilGUIDs[4]; void Reset() override { @@ -155,10 +154,10 @@ public: if (!me->isActiveObject() && param == ACTION_START_ENCOUNTER) { me->setActive(true); - councilGUIDs[0] = instance->GetData64(NPC_GATHIOS_THE_SHATTERER); - councilGUIDs[1] = instance->GetData64(NPC_HIGH_NETHERMANCER_ZEREVOR); - councilGUIDs[2] = instance->GetData64(NPC_LADY_MALANDE); - councilGUIDs[3] = instance->GetData64(NPC_VERAS_DARKSHADOW); + councilGUIDs[0] = instance->GetGuidData(NPC_GATHIOS_THE_SHATTERER); + councilGUIDs[1] = instance->GetGuidData(NPC_HIGH_NETHERMANCER_ZEREVOR); + councilGUIDs[2] = instance->GetGuidData(NPC_LADY_MALANDE); + councilGUIDs[3] = instance->GetGuidData(NPC_VERAS_DARKSHADOW); bool spoken = false; for (uint8 i = 0; i < 4; ++i) @@ -226,7 +225,7 @@ struct boss_illidari_council_memberAI : public ScriptedAI void EnterEvadeMode() override { - me->SetOwnerGUID(0); + me->SetOwnerGUID(ObjectGuid::Empty); ScriptedAI::EnterEvadeMode(); } @@ -251,13 +250,13 @@ struct boss_illidari_council_memberAI : public ScriptedAI void JustDied(Unit*) override { Talk(SAY_COUNCIL_DEATH); - if (Creature* council = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ILLIDARI_COUNCIL))) + if (Creature* council = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDARI_COUNCIL))) council->GetAI()->DoAction(ACTION_END_ENCOUNTER); } void EnterCombat(Unit* /*who*/) override { - if (Creature* council = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ILLIDARI_COUNCIL))) + if (Creature* council = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDARI_COUNCIL))) council->GetAI()->DoAction(ACTION_START_ENCOUNTER); } }; @@ -279,14 +278,14 @@ public: Creature* SelectCouncilMember() { if (roll_chance_i(50)) - return ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_LADY_MALANDE)); + return ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_LADY_MALANDE)); if (roll_chance_i(20)) - if (Creature* veras = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_VERAS_DARKSHADOW))) + if (Creature* veras = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_VERAS_DARKSHADOW))) if (!veras->HasAura(SPELL_VANISH)) return veras; - return ObjectAccessor::GetCreature(*me, instance->GetData64(RAND(NPC_GATHIOS_THE_SHATTERER, NPC_HIGH_NETHERMANCER_ZEREVOR))); + return ObjectAccessor::GetCreature(*me, instance->GetGuidData(RAND(NPC_GATHIOS_THE_SHATTERER, NPC_HIGH_NETHERMANCER_ZEREVOR))); } void EnterCombat(Unit* who) override @@ -538,7 +537,7 @@ public: break; case EVENT_SPELL_ENRAGE: DoResetThreat(); - if (Creature* council = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ILLIDARI_COUNCIL))) + if (Creature* council = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDARI_COUNCIL))) council->GetAI()->DoAction(ACTION_ENRAGE); break; } diff --git a/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp b/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp index 25a427915d..99e5a0dae8 100644 --- a/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp +++ b/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp @@ -39,18 +39,7 @@ public: SetBossNumber(MAX_ENCOUNTERS); LoadDoorData(doorData); - ShadeOfAkamaGUID = 0; - AkamaShadeGUID = 0; - TeronGorefiendGUID = 0; - ReliquaryGUID = 0; ashtongueGUIDs.clear(); - GathiosTheShattererGUID = 0; - HighNethermancerZerevorGUID = 0; - LadyMalandeGUID = 0; - VerasDarkshadowGUID = 0; - IllidariCouncilGUID = 0; - AkamaGUID = 0; - IllidanStormrageGUID = 0; } void OnCreatureCreate(Creature* creature) override @@ -164,7 +153,7 @@ public: } } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -188,7 +177,7 @@ public: return IllidanStormrageGUID; } - return 0; + return ObjectGuid::Empty; } bool SetBossState(uint32 type, EncounterState state) override @@ -198,8 +187,8 @@ public: if (type == DATA_SHADE_OF_AKAMA && state == DONE) { - for (std::list<uint64>::const_iterator itr = ashtongueGUIDs.begin(); itr != ashtongueGUIDs.end(); ++itr) - if (Creature* ashtongue = instance->GetCreature(*itr)) + for (ObjectGuid const guid : ashtongueGUIDs) + if (Creature* ashtongue = instance->GetCreature(guid)) ashtongue->setFaction(FACTION_ASHTONGUE); } else if (type == DATA_ILLIDARI_COUNCIL && state == DONE) @@ -255,18 +244,18 @@ public: } protected: - uint64 ShadeOfAkamaGUID; - uint64 AkamaShadeGUID; - uint64 TeronGorefiendGUID; - uint64 ReliquaryGUID; - std::list<uint64> ashtongueGUIDs; - uint64 GathiosTheShattererGUID; - uint64 HighNethermancerZerevorGUID; - uint64 LadyMalandeGUID; - uint64 VerasDarkshadowGUID; - uint64 IllidariCouncilGUID; - uint64 AkamaGUID; - uint64 IllidanStormrageGUID; + ObjectGuid ShadeOfAkamaGUID; + ObjectGuid AkamaShadeGUID; + ObjectGuid TeronGorefiendGUID; + ObjectGuid ReliquaryGUID; + GuidList ashtongueGUIDs; + ObjectGuid GathiosTheShattererGUID; + ObjectGuid HighNethermancerZerevorGUID; + ObjectGuid LadyMalandeGUID; + ObjectGuid VerasDarkshadowGUID; + ObjectGuid IllidariCouncilGUID; + ObjectGuid AkamaGUID; + ObjectGuid IllidanStormrageGUID; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override @@ -304,8 +293,8 @@ public: void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - for (std::set<uint64>::const_iterator itr = _turtleSet.begin(); itr != _turtleSet.end(); ++itr) - if (Creature* turtle = ObjectAccessor::GetCreature(*GetUnitOwner(), *itr)) + for (ObjectGuid const guid : _turtleSet) + if (Creature* turtle = ObjectAccessor::GetCreature(*GetUnitOwner(), guid)) { turtle->TauntFadeOut(GetUnitOwner()); turtle->AddThreat(GetUnitOwner(), -10000000.0f); @@ -319,7 +308,7 @@ public: } private: - std::set<uint64> _turtleSet; + GuidSet _turtleSet; }; AuraScript* GetAuraScript() const override diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp index 0cfda9af1e..3abe20411f 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp @@ -75,7 +75,7 @@ public: bool Execute(uint64 /*execTime*/, uint32 /*diff*/) override { if (InstanceScript* instance = _owner->GetInstanceScript()) - if (Creature* vashj = ObjectAccessor::GetCreature(*_owner, instance->GetData64(NPC_LADY_VASHJ))) + if (Creature* vashj = ObjectAccessor::GetCreature(*_owner, instance->GetGuidData(NPC_LADY_VASHJ))) _owner->GetMotionMaster()->MoveFollow(vashj, 3.0f, vashj->GetAngle(_owner), MOTION_SLOT_CONTROLLED); return true; } @@ -363,7 +363,7 @@ public: if (CheckTimer <= diff) { // check if vashj is death - Unit* Vashj = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_LADYVASHJ)); + Unit* Vashj = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_LADYVASHJ)); if (!Vashj || !Vashj->IsAlive() || CAST_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->ToCreature()->AI())->Phase != 3) { // remove diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index ed0e74a158..b58ced1654 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -273,7 +273,7 @@ public: { } - uint64 ownerGUID; + ObjectGuid ownerGUID; EventMap events; void EnterEvadeMode() override @@ -428,7 +428,7 @@ public: { if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT) if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript()) - if (Creature* leotheras = ObjectAccessor::GetCreature(*GetUnitOwner(), instance->GetData64(NPC_LEOTHERAS_THE_BLIND))) + if (Creature* leotheras = ObjectAccessor::GetCreature(*GetUnitOwner(), instance->GetGuidData(NPC_LEOTHERAS_THE_BLIND))) leotheras->CastSpell(GetUnitOwner(), SPELL_CONSUMING_MADNESS, true); } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp index 83e2da0aa1..f8bfd8a49c 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp @@ -137,7 +137,7 @@ public: me->CastSpell(me, SPELL_SPOUT_VISUAL, TRIGGERED_IGNORE_SET_FACING); me->SetReactState(REACT_PASSIVE); me->SetFacingToObject(me->GetVictim()); - me->SetTarget(0); + me->SetTarget(); events.ScheduleEvent(EVENT_SPELL_SPOUT, 60000); events.RescheduleEvent(EVENT_SPELL_WHIRL, 18000); events.RescheduleEvent(EVENT_SPELL_GEYSER, 25000); @@ -205,7 +205,7 @@ public: if (roll_chance_i(instance->GetBossState(DATA_THE_LURKER_BELOW) != DONE ? 25 : 0) && !instance->IsEncounterInProgress()) { player->CastSpell(player, SPELL_LURKER_SPAWN_TRIGGER, true); - if (Creature* lurker = ObjectAccessor::GetCreature(*go, instance->GetData64(NPC_THE_LURKER_BELOW))) + if (Creature* lurker = ObjectAccessor::GetCreature(*go, instance->GetGuidData(NPC_THE_LURKER_BELOW))) lurker->AI()->DoAction(ACTION_START_EVENT); return true; } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp index 0e9adc022e..17fed515c3 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp @@ -32,11 +32,7 @@ public: SetBossNumber(MAX_ENCOUNTERS); LoadDoorData(doorData); - LadyVashjGUID = 0; - memset(&ShieldGeneratorGUID, 0, sizeof(ShieldGeneratorGUID)); AliveKeepersCount = 0; - LeotherasTheBlindGUID = 0; - LurkerBelowGUID = 0; } bool SetBossState(uint32 type, EncounterState state) override @@ -115,7 +111,7 @@ public: } } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { switch (identifier) { @@ -126,7 +122,8 @@ public: case NPC_LADY_VASHJ: return LadyVashjGUID; } - return 0; + + return ObjectGuid::Empty; } void SetData(uint32 type, uint32 /*data*/) override @@ -207,10 +204,10 @@ public: } private: - uint64 LadyVashjGUID; - uint64 ShieldGeneratorGUID[4]; - uint64 LurkerBelowGUID; - uint64 LeotherasTheBlindGUID; + ObjectGuid LadyVashjGUID; + ObjectGuid ShieldGeneratorGUID[4]; + ObjectGuid LurkerBelowGUID; + ObjectGuid LeotherasTheBlindGUID; int32 AliveKeepersCount; }; diff --git a/src/server/scripts/Outland/CoilfangReservoir/SlavePens/boss_ahune.cpp b/src/server/scripts/Outland/CoilfangReservoir/SlavePens/boss_ahune.cpp index bdf10bb37c..38ddaf6442 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SlavePens/boss_ahune.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SlavePens/boss_ahune.cpp @@ -81,7 +81,7 @@ public: SetCombatMovement(false); SetEquipmentSlots(false, 54806, EQUIP_UNEQUIP, EQUIP_UNEQUIP); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - InvokerGUID = 0; + InvokerGUID.Clear(); events.Reset(); events.RescheduleEvent(EVENT_EMERGE, 12000); events.RescheduleEvent(EVENT_INVOKER_SAY_1, 1000); @@ -90,7 +90,7 @@ public: EventMap events; SummonList summons; - uint64 InvokerGUID; + ObjectGuid InvokerGUID; void StartPhase1() { diff --git a/src/server/scripts/Outland/CoilfangReservoir/SlavePens/instance_the_slave_pens.cpp b/src/server/scripts/Outland/CoilfangReservoir/SlavePens/instance_the_slave_pens.cpp index 547788c1a5..60a9f39f1c 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SlavePens/instance_the_slave_pens.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SlavePens/instance_the_slave_pens.cpp @@ -77,7 +77,7 @@ public: LumaGUID = creature->GetGUID(); break; case NPC_EARTHEN_RING_FLAMECALLER: - SetData64(counter, creature->GetGUID()); + SetGuidData(counter, creature->GetGUID()); ++counter; break; default: @@ -85,7 +85,7 @@ public: } } - void SetData64(uint32 data, uint64 guid) override + void SetGuidData(uint32 data, ObjectGuid guid) override { switch (data) { @@ -103,7 +103,7 @@ public: } } - uint64 GetData64(uint32 type) const override + ObjectGuid GetGuidData(uint32 type) const override { switch (type) { @@ -136,17 +136,18 @@ public: default: break; } - return 0; + + return ObjectGuid::Empty; } protected: - uint64 AhuneGUID; - uint64 AhuneBunnyGUID; - uint64 FrozenCoreGUID; - uint64 LumaGUID; - uint64 FlameCallerGUIDs[3]; - uint64 BonfireBunnyGUIDs[3]; - uint64 BeamBunnyGUIDs[3]; + ObjectGuid AhuneGUID; + ObjectGuid AhuneBunnyGUID; + ObjectGuid FrozenCoreGUID; + ObjectGuid LumaGUID; + ObjectGuid FlameCallerGUIDs[3]; + ObjectGuid BonfireBunnyGUIDs[3]; + ObjectGuid BeamBunnyGUIDs[3]; uint8 counter; }; diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp index 3eaa8604d9..6a3792db7e 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp @@ -157,14 +157,14 @@ public: } uint32 repairTimer; - uint64 bossGUID; + ObjectGuid bossGUID; void Reset() override { repairTimer = 0; - bossGUID = 0; + bossGUID.Clear(); if (InstanceScript* instance = me->GetInstanceScript()) - bossGUID = instance->GetData64(TYPE_MEKGINEER_STEAMRIGGER); + bossGUID = instance->GetGuidData(TYPE_MEKGINEER_STEAMRIGGER); } void MoveInLineOfSight(Unit* /*who*/) override {} diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp index 7d881da9aa..8a7d528a04 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp @@ -51,19 +51,14 @@ public: uint32 m_auiEncounter[MAX_ENCOUNTER]; - uint64 MekgineerGUID; - uint64 MainChambersDoor; - uint64 AccessPanelHydro; - uint64 AccessPanelMek; + ObjectGuid MekgineerGUID; + ObjectGuid MainChambersDoor; + ObjectGuid AccessPanelHydro; + ObjectGuid AccessPanelMek; void Initialize() override { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - - MekgineerGUID = 0; - MainChambersDoor = 0; - AccessPanelHydro = 0; - AccessPanelMek = 0; } bool IsEncounterInProgress() const override @@ -92,21 +87,21 @@ public: case GO_MAIN_CHAMBERS_DOOR: MainChambersDoor = go->GetGUID(); if (GetData(TYPE_HYDROMANCER_THESPIA) == SPECIAL && GetData(TYPE_MEKGINEER_STEAMRIGGER) == SPECIAL) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_ACCESS_PANEL_HYDRO: AccessPanelHydro = go->GetGUID(); if (GetData(TYPE_HYDROMANCER_THESPIA) == DONE) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); else if (GetData(TYPE_HYDROMANCER_THESPIA) == SPECIAL) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_ACCESS_PANEL_MEK: AccessPanelMek = go->GetGUID(); if (GetData(TYPE_MEKGINEER_STEAMRIGGER) == DONE) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); else if (GetData(TYPE_MEKGINEER_STEAMRIGGER) == SPECIAL) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); break; } } @@ -164,11 +159,12 @@ public: return 0; } - uint64 GetData64(uint32 data) const override + ObjectGuid GetGuidData(uint32 data) const override { if (data == TYPE_MEKGINEER_STEAMRIGGER) return MekgineerGUID; - return 0; + + return ObjectGuid::Empty; } std::string GetSaveData() override diff --git a/src/server/scripts/Outland/CoilfangReservoir/underbog/boss_the_black_stalker.cpp b/src/server/scripts/Outland/CoilfangReservoir/underbog/boss_the_black_stalker.cpp index a94fce64ab..28348cf9bd 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/underbog/boss_the_black_stalker.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/underbog/boss_the_black_stalker.cpp @@ -55,13 +55,13 @@ public: EventMap events; SummonList summons; - uint64 lTarget; + ObjectGuid lTarget; void Reset() override { events.Reset(); summons.DespawnAll(); - lTarget = 0; + lTarget.Clear(); } void EnterCombat(Unit*) override @@ -142,7 +142,7 @@ public: if (Unit* target = ObjectAccessor::GetUnit(*me, lTarget)) { if (!target->HasAura(SPELL_LEVITATE)) - lTarget = 0; + lTarget.Clear(); else { target->CastSpell(target, SPELL_MAGNETIC_PULL, true); @@ -154,11 +154,11 @@ public: if (Unit* target = ObjectAccessor::GetUnit(*me, lTarget)) { if (!target->HasAura(SPELL_LEVITATE)) - lTarget = 0; + lTarget.Clear(); else { target->AddAura(SPELL_SUSPENSION, target); - lTarget = 0; + lTarget.Clear(); } } break; diff --git a/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp b/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp index a908501159..9856d4ac91 100644 --- a/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp +++ b/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp @@ -35,7 +35,6 @@ public: LoadDoorData(doorData); LoadMinionData(minionData); - _maulgarGUID = 0; _addsKilled = 0; } @@ -160,7 +159,7 @@ public: protected: uint32 _addsKilled; - uint64 _maulgarGUID; + ObjectGuid _maulgarGUID; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp index 6eb52b09e1..a8afe03aac 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp @@ -98,8 +98,8 @@ public: { if (instance) { - instance->HandleGameObject(instance->GetData64(DATA_DOOR4), true); - instance->HandleGameObject(instance->GetData64(DATA_DOOR5), true); + instance->HandleGameObject(instance->GetGuidData(DATA_DOOR4), true); + instance->HandleGameObject(instance->GetGuidData(DATA_DOOR5), true); instance->SetData(DATA_BROGGOK, DONE); } } @@ -139,7 +139,7 @@ public: { if (InstanceScript* instance = go->GetInstanceScript()) if (instance->GetData(DATA_BROGGOK) != DONE && instance->GetData(DATA_BROGGOK) != IN_PROGRESS) - if (Creature* broggok = ObjectAccessor::GetCreature(*go, instance->GetData64(DATA_BROGGOK))) + if (Creature* broggok = ObjectAccessor::GetCreature(*go, instance->GetGuidData(DATA_BROGGOK))) { instance->SetData(DATA_BROGGOK, IN_PROGRESS); broggok->AI()->DoAction(ACTION_PREPARE_BROGGOK); diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp index 7e2b3ac7d5..8e9c7ca19e 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp @@ -63,12 +63,11 @@ public: boss_kelidan_the_breakerAI(Creature* creature) : ScriptedAI(creature) { instance = creature->GetInstanceScript(); - memset(&channelers, 0, sizeof(channelers)); } InstanceScript* instance; EventMap events; - uint64 channelers[5]; + ObjectGuid channelers[5]; uint32 checkTimer; bool addYell; @@ -172,7 +171,7 @@ public: if (!channeler) channeler = me->SummonCreature(NPC_CHANNELER, ShadowmoonChannelers[i][0], ShadowmoonChannelers[i][1], ShadowmoonChannelers[i][2], ShadowmoonChannelers[i][3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 300000); - channelers[i] = channeler ? channeler->GetGUID() : 0; + channelers[i] = channeler ? channeler->GetGUID() : ObjectGuid::Empty; } } @@ -184,8 +183,8 @@ public: // Xinef: load grid with start doors me->GetMap()->LoadGrid(0, -111.0f); instance->SetData(DATA_KELIDAN, DONE); - instance->HandleGameObject(instance->GetData64(DATA_DOOR1), true); - instance->HandleGameObject(instance->GetData64(DATA_DOOR6), true); + instance->HandleGameObject(instance->GetGuidData(DATA_DOOR1), true); + instance->HandleGameObject(instance->GetGuidData(DATA_DOOR6), true); } } @@ -288,7 +287,7 @@ public: Creature* GetKelidan() { if (me->GetInstanceScript()) - return ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetData64(DATA_KELIDAN)); + return ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(DATA_KELIDAN)); return nullptr; } diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_the_maker.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_the_maker.cpp index cd9588d78e..3c67bb5a82 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_the_maker.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_the_maker.cpp @@ -47,7 +47,7 @@ public: return; instance->SetData(DATA_THE_MAKER, NOT_STARTED); - instance->HandleGameObject(instance->GetData64(DATA_DOOR2), true); + instance->HandleGameObject(instance->GetGuidData(DATA_DOOR2), true); } void EnterCombat(Unit* /*who*/) override @@ -62,7 +62,7 @@ public: return; instance->SetData(DATA_THE_MAKER, IN_PROGRESS); - instance->HandleGameObject(instance->GetData64(DATA_DOOR2), false); + instance->HandleGameObject(instance->GetGuidData(DATA_DOOR2), false); } void KilledUnit(Unit* victim) override @@ -79,8 +79,8 @@ public: return; instance->SetData(DATA_THE_MAKER, DONE); - instance->HandleGameObject(instance->GetData64(DATA_DOOR2), true); - instance->HandleGameObject(instance->GetData64(DATA_DOOR3), true); + instance->HandleGameObject(instance->GetGuidData(DATA_DOOR2), true); + instance->HandleGameObject(instance->GetGuidData(DATA_DOOR3), true); } void UpdateAI(uint32 diff) override diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp index 7493acab51..464a6b9037 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp @@ -17,28 +17,20 @@ public: instance_blood_furnace_InstanceMapScript(Map* map) : InstanceScript(map) {} uint32 _auiEncounter[MAX_ENCOUNTER]; - uint64 _bossGUIDs[3]; - uint64 _doorGUIDs[6]; - uint64 _prisonGUIDs[4]; + ObjectGuid _bossGUIDs[3]; + ObjectGuid _doorGUIDs[6]; + ObjectGuid _prisonGUIDs[4]; - std::set<uint64> _prisonersCell[4]; + GuidSet _prisonersCell[4]; uint8 _prisonerCounter[4]; - uint64 _broggokLeverGUID; + ObjectGuid _broggokLeverGUID; void Initialize() override { memset(&_auiEncounter, 0, sizeof(_auiEncounter)); - memset(&_bossGUIDs, 0, sizeof(_bossGUIDs)); - memset(&_doorGUIDs, 0, sizeof(_doorGUIDs)); - memset(&_prisonGUIDs, 0, sizeof(_prisonGUIDs)); memset(&_prisonerCounter, 0, sizeof(_prisonerCounter)); - - for (uint8 i = 0; i < 4; ++i) - _prisonersCell[i].clear(); - - _broggokLeverGUID = 0; } void OnCreatureCreate(Creature* creature) override @@ -102,7 +94,7 @@ public: _broggokLeverGUID = go->GetGUID(); //Broggok lever } - uint64 GetData64(uint32 data) const override + ObjectGuid GetGuidData(uint32 data) const override { switch (data) { @@ -125,7 +117,8 @@ public: case DATA_PRISON_CELL4: return _prisonGUIDs[data - DATA_PRISON_CELL1]; } - return 0; + + return ObjectGuid::Empty; } void SetData(uint32 type, uint32 data) override @@ -223,10 +216,10 @@ public: } } - void ResetPrisoners(std::set<uint64> prisoners) + void ResetPrisoners(GuidSet prisoners) { - for (std::set<uint64>::iterator i = prisoners.begin(); i != prisoners.end(); ++i) - if (Creature* prisoner = instance->GetCreature(*i)) + for (ObjectGuid guid : prisoners) + if (Creature* prisoner = instance->GetCreature(guid)) ResetPrisoner(prisoner); } @@ -274,7 +267,7 @@ public: } } - void PrisonerDied(uint64 guid) + void PrisonerDied(ObjectGuid guid) { if (_prisonersCell[0].find(guid) != _prisonersCell[0].end() && --_prisonerCounter[0] <= 0) ActivateCell(DATA_PRISON_CELL2); @@ -299,16 +292,16 @@ public: break; case DATA_DOOR5: HandleGameObject(_doorGUIDs[4], true); - if (Creature* broggok = instance->GetCreature(GetData64(DATA_BROGGOK))) + if (Creature* broggok = instance->GetCreature(GetGuidData(DATA_BROGGOK))) broggok->AI()->DoAction(ACTION_ACTIVATE_BROGGOK); break; } } - void ActivatePrisoners(std::set<uint64> prisoners) + void ActivatePrisoners(GuidSet prisoners) { - for (std::set<uint64>::iterator i = prisoners.begin(); i != prisoners.end(); ++i) - if (Creature* prisoner = instance->GetCreature(*i)) + for (ObjectGuid guid : prisoners) + if (Creature* prisoner = instance->GetCreature(guid)) { prisoner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NON_ATTACKABLE); prisoner->SetInCombatWithZone(); diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp index 7ae8849074..04a54b2093 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp @@ -52,7 +52,7 @@ public: { Talk(SAY_WIPE); BossAI::Reset(); - _targetGUID = 0; + _targetGUID.Clear(); } void EnterCombat(Unit* who) override @@ -139,7 +139,7 @@ public: me->GetMotionMaster()->MoveChase(me->GetVictim()); if (Unit* target = ObjectAccessor::GetUnit(*me, _targetGUID)) me->CastSpell(target, SPELL_SHADOW_WHIP, false); - _targetGUID = 0; + _targetGUID.Clear(); break; } @@ -160,7 +160,7 @@ public: } private: - uint64 _targetGUID; + ObjectGuid _targetGUID; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp index 37964297e4..98852f14d7 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp @@ -18,7 +18,6 @@ public: void Initialize() override { SetBossNumber(MAX_ENCOUNTERS); - felIronChestGUID = 0; } void OnGameObjectCreate(GameObject* go) override @@ -74,7 +73,7 @@ public: } protected: - uint64 felIronChestGUID; + ObjectGuid felIronChestGUID; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp index a22c9b8748..20a1579719 100644 --- a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp @@ -69,7 +69,7 @@ enum Events class DealDebrisDamage : public BasicEvent { public: - DealDebrisDamage(Creature& creature, uint64 targetGUID) : _owner(creature), _targetGUID(targetGUID) { } + DealDebrisDamage(Creature& creature, ObjectGuid targetGUID) : _owner(creature), _targetGUID(targetGUID) { } bool Execute(uint64 /*eventTime*/, uint32 /*updateTime*/) override { @@ -80,7 +80,7 @@ public: private: Creature& _owner; - uint64 _targetGUID; + ObjectGuid _targetGUID; }; class boss_magtheridon : public CreatureScript diff --git a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/instance_magtheridons_lair.cpp b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/instance_magtheridons_lair.cpp index 9c087a9fb0..6844f48e8e 100644 --- a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/instance_magtheridons_lair.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/instance_magtheridons_lair.cpp @@ -37,7 +37,6 @@ public: _wardersSet.clear(); _cubesSet.clear(); _columnSet.clear(); - _magtheridonGUID = 0; } void OnCreatureCreate(Creature* creature) override @@ -119,8 +118,8 @@ public: { if (state == IN_PROGRESS) { - for (std::set<uint64>::const_iterator itr = _wardersSet.begin(); itr != _wardersSet.end(); ++itr) - if (Creature* warder = instance->GetCreature(*itr)) + for (ObjectGuid const guid : _wardersSet) + if (Creature* warder = instance->GetCreature(guid)) if (warder->IsAlive()) { warder->InterruptNonMeleeSpells(true); @@ -129,8 +128,8 @@ public: } else { - for (std::set<uint64>::const_iterator itr = _cubesSet.begin(); itr != _cubesSet.end(); ++itr) - if (GameObject* cube = instance->GetGameObject(*itr)) + for (ObjectGuid const guid : _cubesSet) + if (GameObject* cube = instance->GetGameObject(guid)) cube->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); if (state == NOT_STARTED) @@ -150,13 +149,13 @@ public: magtheridon->SetInCombatWithZone(); break; case DATA_ACTIVATE_CUBES: - for (std::set<uint64>::const_iterator itr = _cubesSet.begin(); itr != _cubesSet.end(); ++itr) - if (GameObject* cube = instance->GetGameObject(*itr)) + for (ObjectGuid const guid : _cubesSet) + if (GameObject* cube = instance->GetGameObject(guid)) cube->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; case DATA_COLLAPSE: - for (std::set<uint64>::const_iterator itr = _columnSet.begin(); itr != _columnSet.end(); ++itr) - if (GameObject* column = instance->GetGameObject(*itr)) + for (ObjectGuid const guid : _columnSet) + if (GameObject* column = instance->GetGameObject(guid)) column->SetGoState(GOState(data)); break; } @@ -206,10 +205,10 @@ public: } private: - uint64 _magtheridonGUID; - std::set<uint64> _wardersSet; - std::set<uint64> _cubesSet; - std::set<uint64> _columnSet; + ObjectGuid _magtheridonGUID; + GuidSet _wardersSet; + GuidSet _cubesSet; + GuidSet _columnSet; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp index a7cc2fcf92..63a12c367f 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp @@ -56,7 +56,7 @@ public: { BossAI::InitializeAI(); if (instance) - if (Creature* executioner = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_EXECUTIONER))) + if (Creature* executioner = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_EXECUTIONER))) executioner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } @@ -66,7 +66,7 @@ public: _JustDied(); if (instance) - if (Creature* executioner = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_EXECUTIONER))) + if (Creature* executioner = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_EXECUTIONER))) executioner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp index 843a59baeb..99803b2cd3 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp @@ -24,12 +24,7 @@ public: void Initialize() override { SetBossNumber(ENCOUNTER_COUNT); - nethekurseDoor1GUID = 0; - nethekurseDoor2GUID = 0; - warchiefKargathGUID = 0; - executionerGUID = 0; - memset(&prisonerGUID, 0, sizeof(prisonerGUID)); TeamIdInInstance = TEAM_NEUTRAL; RescueTimer = 100 * MINUTE * IN_MILLISECONDS; } @@ -47,12 +42,12 @@ public: case GO_GRAND_WARLOCK_CHAMBER_DOOR_1: nethekurseDoor1GUID = go->GetGUID(); if (GetBossState(DATA_NETHEKURSE) == DONE) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); break; case GO_GRAND_WARLOCK_CHAMBER_DOOR_2: nethekurseDoor2GUID = go->GetGUID(); if (GetBossState(DATA_NETHEKURSE) == DONE) - HandleGameObject(0, true, go); + HandleGameObject(ObjectGuid::Empty, true, go); break; } } @@ -132,7 +127,7 @@ public: } } - uint64 GetData64(uint32 data) const override + ObjectGuid GetGuidData(uint32 data) const override { switch (data) { @@ -143,7 +138,8 @@ public: case DATA_EXECUTIONER: return executionerGUID; } - return 0; + + return ObjectGuid::Empty; } void Update(uint32 diff) override @@ -223,12 +219,12 @@ public: } protected: - uint64 warchiefKargathGUID; - uint64 nethekurseDoor1GUID; - uint64 nethekurseDoor2GUID; + ObjectGuid warchiefKargathGUID; + ObjectGuid nethekurseDoor1GUID; + ObjectGuid nethekurseDoor2GUID; - uint64 executionerGUID; - uint64 prisonerGUID[3]; + ObjectGuid executionerGUID; + ObjectGuid prisonerGUID[3]; uint32 RescueTimer; TeamId TeamIdInInstance; }; diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp index 3bf3e54e91..bf807693be 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp @@ -395,7 +395,7 @@ public: { PreventHitEffect(effIndex); if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* alar = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(NPC_ALAR))) + if (Creature* alar = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(NPC_ALAR))) Unit::DealDamage(GetCaster(), alar, alar->CountPctFromMaxHealth(2)); } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 6b0d1f0c84..9607ca670a 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -182,7 +182,7 @@ public: void PrepareAdvisors() { for (uint8 i = DATA_KAEL_ADVISOR1; i <= DATA_KAEL_ADVISOR4; ++i) - if (Creature* advisor = ObjectAccessor::GetCreature(*me, instance->GetData64(i))) + if (Creature* advisor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(i))) { advisor->Respawn(true); advisor->StopMovingOnCurrentPos(); @@ -198,7 +198,7 @@ public: { for (SummonList::const_iterator i = summons.begin(); i != summons.end(); ++i) if (Creature* summon = ObjectAccessor::GetCreature(*me, *i)) - if (summon->GetDBTableGUIDLow()) + if (summon->GetSpawnId()) { summon->SetReactState(REACT_PASSIVE); summon->setDeathState(JUST_RESPAWNED); @@ -209,11 +209,11 @@ public: void SetRoomState(GOState state) { - if (GameObject* window = ObjectAccessor::GetGameObject(*me, instance->GetData64(GO_BRIDGE_WINDOW))) + if (GameObject* window = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_BRIDGE_WINDOW))) window->SetGoState(state); - if (GameObject* window = ObjectAccessor::GetGameObject(*me, instance->GetData64(GO_KAEL_STATUE_RIGHT))) + if (GameObject* window = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_KAEL_STATUE_RIGHT))) window->SetGoState(state); - if (GameObject* window = ObjectAccessor::GetGameObject(*me, instance->GetData64(GO_KAEL_STATUE_LEFT))) + if (GameObject* window = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_KAEL_STATUE_LEFT))) window->SetGoState(state); } @@ -273,11 +273,11 @@ public: if (phase == PHASE_FINAL) return; - if (summon->GetDBTableGUIDLow() && phase == PHASE_ALL_ADVISORS) + if (summon->GetSpawnId() && phase == PHASE_ALL_ADVISORS) { for (SummonList::const_iterator i = summons.begin(); i != summons.end(); ++i) if (Creature* summon = ObjectAccessor::GetCreature(*me, *i)) - if (summon->GetDBTableGUIDLow() && summon->IsAlive()) + if (summon->GetSpawnId() && summon->IsAlive()) return; events2.ScheduleEvent(EVENT_PREFIGHT_PHASE71, 2000); @@ -434,7 +434,7 @@ public: for (SummonList::const_iterator i = summons.begin(); i != summons.end(); ++i) { if (Creature* summon = ObjectAccessor::GetCreature(*me, *i)) - if (!summon->GetDBTableGUIDLow()) + if (!summon->GetSpawnId()) { summon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); summon->SetInCombatWithZone(); @@ -456,7 +456,7 @@ public: case EVENT_PREFIGHT_PHASE63: for (SummonList::const_iterator i = summons.begin(); i != summons.end(); ++i) if (Creature* summon = ObjectAccessor::GetCreature(*me, *i)) - if (summon->GetDBTableGUIDLow()) + if (summon->GetSpawnId()) { summon->SetReactState(REACT_AGGRESSIVE); summon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -486,19 +486,19 @@ public: events.ScheduleEvent(EVENT_CHECK_HEALTH, 1000); break; case EVENT_SCENE_1: - me->SetTarget(0); + me->SetTarget(); me->SetFacingTo(M_PI); me->SetWalk(true); Talk(SAY_PHASE5_NUTS); break; case EVENT_SCENE_2: - me->SetTarget(0); + me->SetTarget(); me->CastSpell(me, SPELL_KAEL_EXPLODES1, true); me->CastSpell(me, SPELL_KAEL_GAINING_POWER, false); me->SetDisableGravity(true); break; case EVENT_SCENE_3: - me->SetTarget(0); + me->SetTarget(); for (uint8 i = 0; i < 2; ++i) if (Creature* trigger = me->SummonCreature(WORLD_TRIGGER, triggersPos[i], TEMPSUMMON_TIMED_DESPAWN, 60000)) trigger->CastSpell(me, SPELL_NETHERBEAM1 + i, false); @@ -506,7 +506,7 @@ public: me->CastSpell(me, SPELL_GROW, true); break; case EVENT_SCENE_4: - me->SetTarget(0); + me->SetTarget(); me->CastSpell(me, SPELL_GROW, true); me->CastSpell(me, SPELL_KAEL_EXPLODES2, true); me->CastSpell(me, SPELL_NETHERBEAM_AURA1, true); @@ -515,7 +515,7 @@ public: trigger->CastSpell(me, SPELL_NETHERBEAM1 + i, false); break; case EVENT_SCENE_5: - me->SetTarget(0); + me->SetTarget(); me->CastSpell(me, SPELL_GROW, true); me->CastSpell(me, SPELL_KAEL_EXPLODES3, true); me->CastSpell(me, SPELL_NETHERBEAM_AURA2, true); @@ -676,7 +676,7 @@ public: events.ScheduleEvent(EVENT_SPELL_NETHER_VAPOR, 0); me->CastSpell(me, SPELL_SHOCK_BARRIER, false); me->CastSpell(me, SPELL_GRAVITY_LAPSE, false); - me->SetTarget(0); + me->SetTarget(); me->GetMotionMaster()->Clear(); me->StopMoving(); Talk(SAY_GRAVITYLAPSE); @@ -723,7 +723,7 @@ public: { if (GetCaster()->GetTypeId() == TYPEID_UNIT) if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* kael = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(NPC_KAELTHAS))) + if (Creature* kael = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(NPC_KAELTHAS))) kael->AI()->SummonedCreatureDies(GetCaster()->ToCreature(), nullptr); return true; } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp b/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp index 8ca620c989..8e4baa3d49 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp @@ -15,28 +15,19 @@ public: { instance_the_eye_InstanceMapScript(Map* map) : InstanceScript(map) {} - uint64 ThaladredTheDarkenerGUID; - uint64 LordSanguinarGUID; - uint64 GrandAstromancerCapernianGUID; - uint64 MasterEngineerTelonicusGUID; - uint64 AlarGUID; - uint64 KaelthasGUID; - uint64 BridgeWindowGUID; - uint64 KaelStateRightGUID; - uint64 KaelStateLeftGUID; + ObjectGuid ThaladredTheDarkenerGUID; + ObjectGuid LordSanguinarGUID; + ObjectGuid GrandAstromancerCapernianGUID; + ObjectGuid MasterEngineerTelonicusGUID; + ObjectGuid AlarGUID; + ObjectGuid KaelthasGUID; + ObjectGuid BridgeWindowGUID; + ObjectGuid KaelStateRightGUID; + ObjectGuid KaelStateLeftGUID; void Initialize() override { SetBossNumber(MAX_ENCOUNTER); - AlarGUID = 0; - KaelthasGUID = 0; - ThaladredTheDarkenerGUID = 0; - LordSanguinarGUID = 0; - GrandAstromancerCapernianGUID = 0; - MasterEngineerTelonicusGUID = 0; - BridgeWindowGUID = 0; - KaelStateRightGUID = 0; - KaelStateLeftGUID = 0; } void OnCreatureCreate(Creature* creature) override @@ -80,7 +71,7 @@ public: } } - uint64 GetData64(uint32 identifier) const override + ObjectGuid GetGuidData(uint32 identifier) const override { switch (identifier) { @@ -103,7 +94,8 @@ public: case DATA_KAEL_ADVISOR4: return MasterEngineerTelonicusGUID; } - return 0; + + return ObjectGuid::Empty; } std::string GetSaveData() override diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/instance_mechanar.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/instance_mechanar.cpp index 559a9a82f5..b227a59770 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/instance_mechanar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/instance_mechanar.cpp @@ -26,7 +26,6 @@ public: SetBossNumber(MAX_ENCOUNTER); LoadDoorData(doorData); - _pathaleonGUID = 0; _passageEncounter = 0; _passageTimer = 0; _passageGUIDs.clear(); @@ -237,10 +236,10 @@ public: } private: - uint64 _pathaleonGUID; + ObjectGuid _pathaleonGUID; uint32 _passageTimer; uint32 _passageEncounter; - std::set<uint64> _passageGUIDs; + GuidSet _passageGUIDs; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp index d3e7ee123b..66bd9d7db5 100644 --- a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp +++ b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp @@ -356,13 +356,13 @@ public: me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); me->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); me->CastSpell((Unit*)nullptr, SPELL_TARGET_OMEGA, false); - instance->HandleGameObject(instance->GetData64(DATA_WARDENS_SHIELD), true); + instance->HandleGameObject(instance->GetGuidData(DATA_WARDENS_SHIELD), true); instance->SetBossState(DATA_WARDEN_MELLICHAR, NOT_STARTED); } void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType, SpellSchoolMask) override { - if (attacker && IS_PLAYER_GUID(attacker->GetCharmerOrOwnerOrOwnGUID()) && damage > 0 && !me->isActiveObject()) + if (attacker && attacker->GetCharmerOrOwnerOrOwnGUID().IsPlayer() && damage > 0 && !me->isActiveObject()) { me->setActive(true); me->InterruptNonMeleeSpells(false); @@ -418,7 +418,7 @@ public: events.ScheduleEvent(EVENT_WARDEN_INTRO2, 1400); break; case EVENT_WARDEN_INTRO2: - instance->HandleGameObject(instance->GetData64(DATA_WARDENS_SHIELD), false); + instance->HandleGameObject(instance->GetGuidData(DATA_WARDENS_SHIELD), false); events.ScheduleEvent(EVENT_WARDEN_INTRO3, 20000); break; case EVENT_WARDEN_INTRO3: @@ -537,7 +537,7 @@ public: events.ScheduleEvent(EVENT_WARDEN_INTRO28, 5000); break; case EVENT_WARDEN_INTRO28: - instance->HandleGameObject(instance->GetData64(DATA_WARDENS_SHIELD), true); + instance->HandleGameObject(instance->GetGuidData(DATA_WARDENS_SHIELD), true); if (Creature* creature = summons.GetCreatureWithEntry(NPC_HARBINGER_SKYRISS)) creature->CastSpell((Unit*)nullptr, SPELL_MIND_REND, false); events.ScheduleEvent(EVENT_WARDEN_INTRO29, 4000); diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/boss_dalliah_the_doomsayer.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/boss_dalliah_the_doomsayer.cpp index 5bd9f3e396..538ed1255e 100644 --- a/src/server/scripts/Outland/TempestKeep/arcatraz/boss_dalliah_the_doomsayer.cpp +++ b/src/server/scripts/Outland/TempestKeep/arcatraz/boss_dalliah_the_doomsayer.cpp @@ -68,7 +68,7 @@ public: _JustDied(); Talk(SAY_DEATH); - if (Creature* soccothrates = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SOCCOTHRATES))) + if (Creature* soccothrates = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SOCCOTHRATES))) if (soccothrates->IsAlive() && !soccothrates->IsInCombat()) soccothrates->AI()->SetData(1, 1); } @@ -137,14 +137,14 @@ public: events.ScheduleEvent(EVENT_SHADOW_WAVE, urand(11000, 16000)); break; case EVENT_ME_FIRST: - if (Creature* soccothrates = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SOCCOTHRATES))) + if (Creature* soccothrates = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SOCCOTHRATES))) if (soccothrates->IsAlive() && !soccothrates->IsInCombat()) soccothrates->AI()->Talk(SAY_AGGRO_DALLIAH_FIRST); break; case EVENT_CHECK_HEALTH: if (HealthBelowPct(25)) { - if (Creature* soccothrates = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SOCCOTHRATES))) + if (Creature* soccothrates = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SOCCOTHRATES))) soccothrates->AI()->Talk(SAY_DALLIAH_25_PERCENT); break; } diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/boss_wrath_scryer_soccothrates.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/boss_wrath_scryer_soccothrates.cpp index 3df1384ed8..0fca3ca3dc 100644 --- a/src/server/scripts/Outland/TempestKeep/arcatraz/boss_wrath_scryer_soccothrates.cpp +++ b/src/server/scripts/Outland/TempestKeep/arcatraz/boss_wrath_scryer_soccothrates.cpp @@ -89,7 +89,7 @@ public: _JustDied(); Talk(SAY_DEATH); - if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_DALLIAH))) + if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_DALLIAH))) if (dalliah->IsAlive() && !dalliah->IsInCombat()) dalliah->AI()->SetData(1, 1); } @@ -133,7 +133,7 @@ public: switch (events2.ExecuteEvent()) { case EVENT_PREFIGHT_1: - if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_DALLIAH))) + if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_DALLIAH))) dalliah->AI()->Talk(SAY_DALLIAH_CONVO_1); events2.ScheduleEvent(EVENT_PREFIGHT_2, 3000); break; @@ -142,7 +142,7 @@ public: events2.ScheduleEvent(EVENT_PREFIGHT_3, 3000); break; case EVENT_PREFIGHT_3: - if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_DALLIAH))) + if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_DALLIAH))) dalliah->AI()->Talk(SAY_DALLIAH_CONVO_2); events2.ScheduleEvent(EVENT_PREFIGHT_4, 6000); break; @@ -151,7 +151,7 @@ public: events2.ScheduleEvent(EVENT_PREFIGHT_5, 2000); break; case EVENT_PREFIGHT_5: - if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_DALLIAH))) + if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_DALLIAH))) dalliah->AI()->Talk(SAY_DALLIAH_CONVO_3); events2.ScheduleEvent(EVENT_PREFIGHT_6, 3000); break; @@ -160,7 +160,7 @@ public: events2.ScheduleEvent(EVENT_PREFIGHT_7, 2000); break; case EVENT_PREFIGHT_7: - if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_DALLIAH))) + if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_DALLIAH))) dalliah->GetMotionMaster()->MovePoint(0, 118.6048f, 96.84852f, 22.44115f); events2.ScheduleEvent(EVENT_PREFIGHT_8, 4000); break; @@ -169,7 +169,7 @@ public: events2.ScheduleEvent(EVENT_PREFIGHT_9, 4000); break; case EVENT_PREFIGHT_9: - if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_DALLIAH))) + if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_DALLIAH))) { dalliah->SetFacingToObject(me); dalliah->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC); @@ -217,14 +217,14 @@ public: me->CastSpell(me, SPELL_FELFIRE, true); break; case EVENT_ME_FIRST: - if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_DALLIAH))) + if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_DALLIAH))) if (dalliah->IsAlive() && !dalliah->IsInCombat()) dalliah->AI()->Talk(SAY_AGGRO_SOCCOTHRATES_FIRST); break; case EVENT_CHECK_HEALTH: if (HealthBelowPct(25)) { - if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_DALLIAH))) + if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_DALLIAH))) dalliah->AI()->Talk(SAY_SOCCOTHRATES_25_PERCENT); break; } diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/instance_arcatraz.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/instance_arcatraz.cpp index 1fa781ae8a..57b58faa32 100644 --- a/src/server/scripts/Outland/TempestKeep/arcatraz/instance_arcatraz.cpp +++ b/src/server/scripts/Outland/TempestKeep/arcatraz/instance_arcatraz.cpp @@ -24,13 +24,6 @@ public: { SetBossNumber(MAX_ENCOUTER); LoadDoorData(doorData); - - DalliahGUID = 0; - SoccothratesGUID = 0; - MellicharGUID = 0; - WardensShieldGUID = 0; - - memset(StasisPodGUIDs, 0, 5 * sizeof(uint64)); } void OnCreatureCreate(Creature* creature) override @@ -115,7 +108,7 @@ public: return 0; } - uint64 GetData64(uint32 data) const override + ObjectGuid GetGuidData(uint32 data) const override { switch (data) { @@ -126,7 +119,8 @@ public: case DATA_WARDENS_SHIELD: return WardensShieldGUID; } - return 0; + + return ObjectGuid::Empty; } bool SetBossState(uint32 type, EncounterState state) override @@ -191,11 +185,11 @@ public: } protected: - uint64 DalliahGUID; - uint64 SoccothratesGUID; - uint64 StasisPodGUIDs[5]; - uint64 MellicharGUID; - uint64 WardensShieldGUID; + ObjectGuid DalliahGUID; + ObjectGuid SoccothratesGUID; + ObjectGuid StasisPodGUIDs[5]; + ObjectGuid MellicharGUID; + ObjectGuid WardensShieldGUID; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Outland/TempestKeep/botanica/instance_the_botanica.cpp b/src/server/scripts/Outland/TempestKeep/botanica/instance_the_botanica.cpp index a06f935ad0..68948e9ba2 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/instance_the_botanica.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/instance_the_botanica.cpp @@ -105,8 +105,8 @@ public: void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - for (std::set<uint64>::const_iterator itr = _falconSet.begin(); itr != _falconSet.end(); ++itr) - if (Creature* falcon = ObjectAccessor::GetCreature(*GetUnitOwner(), *itr)) + for (ObjectGuid const guid : _falconSet) + if (Creature* falcon = ObjectAccessor::GetCreature(*GetUnitOwner(), guid)) { falcon->TauntFadeOut(GetUnitOwner()); falcon->AddThreat(GetUnitOwner(), -10000000.0f); @@ -120,7 +120,7 @@ public: } private: - std::set<uint64> _falconSet; + GuidSet _falconSet; }; AuraScript* GetAuraScript() const override diff --git a/src/server/scripts/Outland/boss_doomwalker.cpp b/src/server/scripts/Outland/boss_doomwalker.cpp index ae262a4db0..e520cd3f0a 100644 --- a/src/server/scripts/Outland/boss_doomwalker.cpp +++ b/src/server/scripts/Outland/boss_doomwalker.cpp @@ -81,7 +81,7 @@ public: void MoveInLineOfSight(Unit* who) override { if (who && who->GetTypeId() == TYPEID_PLAYER && me->IsValidAttackTarget(who)) - if (who->HasAura(SPELL_MARK_DEATH, 0) && !who->HasAura(27827)) // Spirit of Redemption + if (who->HasAura(SPELL_MARK_DEATH) && !who->HasAura(27827)) // Spirit of Redemption who->CastSpell(who, SPELL_AURA_DEATH, 1); } diff --git a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp index c2d4c0e6d6..077cf1a29d 100644 --- a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp +++ b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp @@ -64,8 +64,8 @@ public: EventMap events; bool PartyTime; - uint64 PlayerGUID; - uint64 CannonGUID; + ObjectGuid PlayerGUID; + ObjectGuid CannonGUID; uint8 count; void Reset() override @@ -77,8 +77,8 @@ public: void Initialize() { PartyTime = false; - PlayerGUID = 0; - CannonGUID = 0; + PlayerGUID.Clear(); + CannonGUID.Clear(); count = 0; } @@ -106,9 +106,9 @@ public: if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID)) { if (GetClosestCreatureWithEntry(me, NPC_SOUTH_GATE, 200.0f)) - player->KilledMonsterCredit(NPC_SOUTH_GATE_CREDIT, TRIGGERED_NONE); + player->KilledMonsterCredit(NPC_SOUTH_GATE_CREDIT); else if (GetClosestCreatureWithEntry(me, NPC_NORTH_GATE, 200.0f)) - player->KilledMonsterCredit(NPC_NORTH_GATE_CREDIT, TRIGGERED_NONE); + player->KilledMonsterCredit(NPC_NORTH_GATE_CREDIT); // complete quest part if (Creature* bunny = GetClosestCreatureWithEntry(me, NPC_EXPLOSION_BUNNY, 200.0f)) bunny->CastSpell(nullptr, SPELL_EXPLOSION, TRIGGERED_NONE); @@ -560,7 +560,7 @@ public: uint8 gameLevel; uint8 fails; uint8 gameTicks; - uint64 playerGUID; + ObjectGuid playerGUID; uint32 clusterIds[SIMON_MAX_COLORS]; float zCoordCorrection; float searchDistance; @@ -670,7 +670,7 @@ public: } // Used for getting involved player guid. Parameter id is used for defining if is a large(Monument) or small(Relic) node - void SetGUID(uint64 guid, int32 id) override + void SetGUID(ObjectGuid guid, int32 id) override { me->SetCanFly(true); @@ -1073,7 +1073,7 @@ public: { npc_oscillating_frequency_scanner_master_bunnyAI(Creature* creature) : ScriptedAI(creature) { - playerGuid = 0; + playerGuid.Clear(); timer = 500; } @@ -1112,7 +1112,7 @@ public: } private: - uint64 playerGuid; + ObjectGuid playerGuid; uint32 timer; }; diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp index 8759f00a5c..498c179f1a 100644 --- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp @@ -336,7 +336,7 @@ public: void Reset() override { checkTimer = 5000; //check for creature every 5 sec - helboarGUID = 0; + helboarGUID.Clear(); } void MovementInform(uint32 type, uint32 id) override @@ -378,7 +378,7 @@ public: private: uint32 checkTimer; - uint64 helboarGUID; + ObjectGuid helboarGUID; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Outland/zone_nagrand.cpp b/src/server/scripts/Outland/zone_nagrand.cpp index e4778af9b2..77780753b7 100644 --- a/src/server/scripts/Outland/zone_nagrand.cpp +++ b/src/server/scripts/Outland/zone_nagrand.cpp @@ -287,7 +287,7 @@ public: { corki->GetMotionMaster()->MovePoint(1, go->GetPositionX() + 5, go->GetPositionY(), go->GetPositionZ()); if (player) - player->KilledMonsterCredit(NPC_CORKI_CREDIT_1, 0); + player->KilledMonsterCredit(NPC_CORKI_CREDIT_1); } } @@ -297,7 +297,7 @@ public: { corki->GetMotionMaster()->MovePoint(1, go->GetPositionX() - 5, go->GetPositionY(), go->GetPositionZ()); if (player) - player->KilledMonsterCredit(NPC_CORKI_2, 0); + player->KilledMonsterCredit(NPC_CORKI_2); } } @@ -307,7 +307,7 @@ public: { corki->GetMotionMaster()->MovePoint(1, go->GetPositionX() + 4, go->GetPositionY(), go->GetPositionZ()); if (player) - player->KilledMonsterCredit(NPC_CORKI_CREDIT_3, 0); + player->KilledMonsterCredit(NPC_CORKI_CREDIT_3); } } @@ -425,7 +425,7 @@ public: uint32 HealTimer; uint32 FrostShockTimer; - void SetGUID(uint64 guid, int32 /*questId*/) override + void SetGUID(ObjectGuid guid, int32 /*questId*/) override { me->SetStandState(UNIT_STAND_STATE_STAND); Start(true, false, guid); @@ -583,7 +583,7 @@ public: if (Creature* prisoner = go->FindNearestCreature(NPC_MAGHAR_PRISONER, 5.0f)) { - player->KilledMonsterCredit(NPC_MAGHAR_PRISONER, 0); + player->KilledMonsterCredit(NPC_MAGHAR_PRISONER); prisoner->AI()->Talk(SAY_FREE, player); prisoner->DespawnOrUnsummon(6000); diff --git a/src/server/scripts/Outland/zone_netherstorm.cpp b/src/server/scripts/Outland/zone_netherstorm.cpp index 3e0faad7c3..430c319a3c 100644 --- a/src/server/scripts/Outland/zone_netherstorm.cpp +++ b/src/server/scripts/Outland/zone_netherstorm.cpp @@ -1040,8 +1040,7 @@ public: _events.ScheduleEvent(EVENT_SPELL_BURNING_LIGHT, 4000); break; case EVENT_SPELL_CONSECRATION: - if (me->FindNearestCreature(me->GetVictim()->GetGUID(), 10.0f, true)) - me->CastSpell(me, CONSECRATION, false); + me->CastSpell(me->GetVictim(), CONSECRATION, false); _events.ScheduleEvent(EVENT_SPELL_CONSECRATION, 14000); break; } @@ -1098,8 +1097,8 @@ public: { if (!summons.empty()) { - for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr) - if (Creature* cr = ObjectAccessor::GetCreature(*me, *itr)) + for (ObjectGuid guid : summons) + if (Creature* cr = ObjectAccessor::GetCreature(*me, guid)) { float x, y, z, o; cr->GetRespawnPosition(x, y, z, &o); @@ -1126,7 +1125,7 @@ public: npc_escortAI::MoveInLineOfSight(who); } - void SetGUID(uint64 playerGUID, int32 type) override + void SetGUID(ObjectGuid playerGUID, int32 type) override { if (type == DATA_START_ENCOUNTER) { @@ -1175,7 +1174,7 @@ public: void SummonsAction(Unit* who) { float i = 0; - for (std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr, i += 1.0f) + for (GuidList::iterator itr = summons.begin(); itr != summons.end(); ++itr, i += 1.0f) if (Creature* cr = ObjectAccessor::GetCreature(*me, *itr)) { if (who == nullptr) @@ -1280,7 +1279,7 @@ public: if (uiAction == GOSSIP_ACTION_INFO_DEF + 1) { creature->AI()->SetGUID(player->GetGUID(), DATA_START_ENCOUNTER); - player->KilledMonsterCredit(creature->GetEntry(), 0); + player->KilledMonsterCredit(creature->GetEntry()); } else if (uiAction == GOSSIP_ACTION_INFO_DEF + 2) { @@ -1363,9 +1362,9 @@ public: { npc_commander_dawnforgeAI(Creature* creature) : ScriptedAI(creature) { } - uint64 PlayerGUID; - uint64 ardonisGUID; - uint64 pathaleonGUID; + ObjectGuid PlayerGUID; + ObjectGuid ardonisGUID; + ObjectGuid pathaleonGUID; uint32 Phase; uint32 PhaseSubphase; @@ -1374,9 +1373,9 @@ public: void Reset() override { - PlayerGUID = 0; - ardonisGUID = 0; - pathaleonGUID = 0; + PlayerGUID.Clear(); + ardonisGUID.Clear(); + pathaleonGUID.Clear(); Phase = 1; PhaseSubphase = 0; @@ -1698,7 +1697,7 @@ public: bool Drained; uint8 WeakPercent; - uint64 PlayerGUID; + ObjectGuid PlayerGUID; uint32 ManaBurnTimer; @@ -1709,7 +1708,7 @@ public: Drained = false; WeakPercent = 25 + (rand() % 16); // 25-40 - PlayerGUID = 0; + PlayerGUID.Clear(); ManaBurnTimer = 5000 + (rand() % 3 * 1000); // 5-8 sec cd diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp index 1d76e5a39a..ad98ea86a6 100644 --- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp @@ -70,7 +70,7 @@ public: } go->SetLootState(GO_JUST_DEACTIVATED); - charmer->KilledMonsterCredit(21959, 0); + charmer->KilledMonsterCredit(21959); } } @@ -99,7 +99,7 @@ public: { if (Player* player = GetTarget()->ToPlayer()) { - player->KilledMonsterCredit(21502, 0); + player->KilledMonsterCredit(21502); player->SetControlled(false, UNIT_STATE_STUNNED); } } @@ -197,7 +197,7 @@ public: private: EventMap events; - uint64 infernalGUID; + ObjectGuid infernalGUID; float ground; }; @@ -259,7 +259,7 @@ public: } private: - uint64 casterGUID; + ObjectGuid casterGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -301,7 +301,7 @@ public: { npc_mature_netherwing_drakeAI(Creature* creature) : ScriptedAI(creature) { } - uint64 uiPlayerGUID; + ObjectGuid uiPlayerGUID; bool bCanEat; bool bIsEating; @@ -311,7 +311,7 @@ public: void Reset() override { - uiPlayerGUID = 0; + uiPlayerGUID.Clear(); bCanEat = false; bIsEating = false; @@ -380,7 +380,7 @@ public: if (Player* player = ObjectAccessor::GetPlayer(*me, uiPlayerGUID)) { - player->KilledMonsterCredit(NPC_EVENT_PINGER, 0); + player->KilledMonsterCredit(NPC_EVENT_PINGER); if (GameObject* go = player->FindNearestGameObject(GO_CARCASS, 10)) go->Delete(); @@ -444,12 +444,12 @@ public: { npc_enslaved_netherwing_drakeAI(Creature* creature) : ScriptedAI(creature) { - PlayerGUID = 0; + PlayerGUID.Clear(); Tapped = false; Reset(); } - uint64 PlayerGUID; + ObjectGuid PlayerGUID; uint32 FlyTimer; bool Tapped; @@ -590,13 +590,13 @@ public: npc_dragonmaw_peonAI(Creature* creature) : ScriptedAI(creature) { } EventMap events; - uint64 PlayerGUID; + ObjectGuid PlayerGUID; bool Tapped; void Reset() override { events.Reset(); - PlayerGUID = 0; + PlayerGUID.Clear(); Tapped = false; } @@ -639,7 +639,7 @@ public: { Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID); if (player && player->GetQuestStatus(QUEST_A_SLOW_DEATH) == QUEST_STATUS_INCOMPLETE) - player->KilledMonsterCredit(DRAGONMAW_PEON_KILL_CREDIT, 0); + player->KilledMonsterCredit(DRAGONMAW_PEON_KILL_CREDIT); } } @@ -1089,8 +1089,8 @@ public: uint8 AnimationCount; - uint64 LordIllidanGUID; - uint64 AggroTargetGUID; + ObjectGuid LordIllidanGUID; + ObjectGuid AggroTargetGUID; bool Timers; @@ -1098,13 +1098,13 @@ public: { AnimationTimer = 4000; AnimationCount = 0; - LordIllidanGUID = 0; - AggroTargetGUID = 0; + LordIllidanGUID.Clear(); + AggroTargetGUID.Clear(); Timers = false; me->AddUnitState(UNIT_STATE_ROOT); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->SetTarget(0); + me->SetTarget(); } void EnterCombat(Unit* /*who*/) override { } @@ -1245,7 +1245,7 @@ public: { npc_lord_illidan_stormrageAI(Creature* creature) : ScriptedAI(creature) { } - uint64 PlayerGUID; + ObjectGuid PlayerGUID; uint32 WaveTimer; uint32 AnnounceTimer; @@ -1259,7 +1259,7 @@ public: void Reset() override { - PlayerGUID = 0; + PlayerGUID.Clear(); WaveTimer = 10000; AnnounceTimer = 7000; @@ -1390,13 +1390,13 @@ public: { npc_illidari_spawnAI(Creature* creature) : ScriptedAI(creature) { } - uint64 LordIllidanGUID; + ObjectGuid LordIllidanGUID; uint32 SpellTimer1, SpellTimer2, SpellTimer3; bool Timers; void Reset() override { - LordIllidanGUID = 0; + LordIllidanGUID.Clear(); Timers = false; } @@ -1706,7 +1706,7 @@ public: if (Unit* owner = totemOspirits->GetOwner()) if (Player* player = owner->ToPlayer()) - player->KilledMonsterCredit(credit, 0); + player->KilledMonsterCredit(credit); DoCast(totemOspirits, SPELL_SOUL_CAPTURED); } } @@ -1739,7 +1739,7 @@ public: void Reset() override { tapped = false; - tuberGUID = 0; + tuberGUID.Clear(); resetTimer = 60000; } @@ -1794,7 +1794,7 @@ public: } private: bool tapped; - uint64 tuberGUID; + ObjectGuid tuberGUID; uint32 resetTimer; }; diff --git a/src/server/scripts/Outland/zone_zangarmarsh.cpp b/src/server/scripts/Outland/zone_zangarmarsh.cpp index 5294b33c40..b40c48fe1f 100644 --- a/src/server/scripts/Outland/zone_zangarmarsh.cpp +++ b/src/server/scripts/Outland/zone_zangarmarsh.cpp @@ -54,7 +54,7 @@ public: if (creature->AI()->GetData(1)) { creature->CastSpell(player, SPELL_MARK_OF_BITE, true); - player->KilledMonsterCredit(creature->GetEntry(), 0); + player->KilledMonsterCredit(creature->GetEntry()); creature->DespawnOrUnsummon(1000); } else diff --git a/src/server/scripts/Pet/pet_dk.cpp b/src/server/scripts/Pet/pet_dk.cpp index 6eb917b5eb..3c2b8adee1 100644 --- a/src/server/scripts/Pet/pet_dk.cpp +++ b/src/server/scripts/Pet/pet_dk.cpp @@ -41,7 +41,7 @@ public: _despawnTimer = 36000; // 30 secs + 4 fly out + 2 initial attack timer _despawning = false; _initialSelection = true; - _targetGUID = 0; + _targetGUID.Clear(); } void MovementInform(uint32 type, uint32 point) override @@ -199,7 +199,7 @@ public: } private: - uint64 _targetGUID; + ObjectGuid _targetGUID; uint32 _despawnTimer; uint32 _selectionTimer; uint32 _initialCastTimer; diff --git a/src/server/scripts/Pet/pet_generic.cpp b/src/server/scripts/Pet/pet_generic.cpp index b73967bb29..55fba334fc 100644 --- a/src/server/scripts/Pet/pet_generic.cpp +++ b/src/server/scripts/Pet/pet_generic.cpp @@ -39,7 +39,7 @@ public: void Reset() override { - _victimGUID = 0; + _victimGUID.Clear(); if (Unit* owner = me->GetOwner()) me->GetMotionMaster()->MoveFollow(owner, 0.0f, 0.0f); @@ -72,7 +72,7 @@ public: } private: - uint64 _victimGUID; + ObjectGuid _victimGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -100,7 +100,7 @@ public: struct npc_pet_gen_soul_trader_beaconAI : public ScriptedAI { - uint64 ownerGUID; + ObjectGuid ownerGUID; EventMap events; npc_pet_gen_soul_trader_beaconAI(Creature* c) : ScriptedAI(c) { @@ -635,13 +635,13 @@ public: npc_pet_gen_imp_in_a_bottleAI(Creature* c) : NullCreatureAI(c) { _talkTimer = 0; - _ownerGUID = 0; + _ownerGUID.Clear(); _hasParty = false; } WorldPacket _data; uint32 _talkTimer; - uint64 _ownerGUID; + ObjectGuid _ownerGUID; bool _hasParty; void InitializeAI() override @@ -661,7 +661,7 @@ public: _data.Initialize(SMSG_MESSAGECHAT, 200); // guess size _data << uint8(CHAT_MSG_MONSTER_PARTY); _data << uint32(LANG_UNIVERSAL); - _data << uint64(me->GetGUID()); + _data << me->GetGUID(); _data << uint32(0); _data << uint32(me->GetName().size() + 1); _data << me->GetName(); @@ -769,13 +769,13 @@ public: { npc_pet_gen_plump_turkeyAI(Creature* c) : PassiveAI(c) { - goGUID = 0; + goGUID.Clear(); jumpTimer = 0; checkTimer = 0; jumping = false; } - uint64 goGUID; + ObjectGuid goGUID; uint32 jumpTimer; uint32 checkTimer; bool jumping; @@ -893,7 +893,7 @@ public: } uint32 checkTimer; - uint64 targetGUID; + ObjectGuid targetGUID; void IsSummonedBy(Unit* summoner) override { @@ -902,7 +902,7 @@ public: me->SetOwnerGUID(summoner->GetGUID()); checkTimer = 0; - targetGUID = 0; + targetGUID.Clear(); me->CastSpell(me, 48649 /*SPELL_PET_TOY_FETCH_BALL_COME_HERE*/, true); } diff --git a/src/server/scripts/Pet/pet_mage.cpp b/src/server/scripts/Pet/pet_mage.cpp index d4384e84a2..0edb6ff0b5 100644 --- a/src/server/scripts/Pet/pet_mage.cpp +++ b/src/server/scripts/Pet/pet_mage.cpp @@ -52,7 +52,7 @@ public: npc_pet_mage_mirror_imageAI(Creature* creature) : CasterAI(creature) { } uint32 selectionTimer; - uint64 _ebonGargoyleGUID; + ObjectGuid _ebonGargoyleGUID; uint32 checktarget; uint32 dist = urand(1, 5); @@ -99,7 +99,7 @@ public: ref = ref->next(); } - _ebonGargoyleGUID = 0; + _ebonGargoyleGUID.Clear(); // Xinef: copy caster auras Unit::VisibleAuraMap const* visibleAuraMap = owner->GetVisibleAuras(); @@ -149,7 +149,7 @@ public: Unit* gargoyle = ObjectAccessor::GetUnit(*me, _ebonGargoyleGUID); if (gargoyle && gargoyle->GetAI()) gargoyle->GetAI()->AttackStart(me); - _ebonGargoyleGUID = 0; + _ebonGargoyleGUID.Clear(); } Unit* owner = me->GetOwner(); if (owner && owner->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index 7678b6df0a..0516bef416 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -1294,7 +1294,7 @@ public: class CorpseExplosionCheck { public: - explicit CorpseExplosionCheck(uint64 casterGUID, bool allowGhoul) : _casterGUID(casterGUID), _allowGhoul(allowGhoul) { } + explicit CorpseExplosionCheck(ObjectGuid casterGUID, bool allowGhoul) : _casterGUID(casterGUID), _allowGhoul(allowGhoul) { } bool operator()(WorldObject* obj) const { @@ -1310,7 +1310,7 @@ public: } private: - uint64 _casterGUID; + ObjectGuid _casterGUID; bool _allowGhoul; }; @@ -2373,12 +2373,12 @@ public: { PrepareSpellScript(spell_dk_scourge_strike_SpellScript); float multiplier; - uint64 guid; + ObjectGuid guid; bool Load() override { multiplier = 1.0f; - guid = 0; + guid.Clear(); return true; } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 735d403404..96c7ab0eca 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -194,7 +194,7 @@ public: } if (entry) - target->ToPlayer()->KilledMonsterCredit(entry, 0); + target->ToPlayer()->KilledMonsterCredit(entry); } } @@ -2373,7 +2373,7 @@ public: void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { // Remove all auras with spell id 46221, except the one currently being applied - while (Aura* aur = GetUnitOwner()->GetOwnedAura(SPELL_ANIMAL_BLOOD, 0, 0, 0, GetAura())) + while (Aura* aur = GetUnitOwner()->GetOwnedAura(SPELL_ANIMAL_BLOOD, ObjectGuid::Empty, ObjectGuid::Empty, 0, GetAura())) GetUnitOwner()->RemoveOwnedAura(aur); } @@ -3148,7 +3148,7 @@ public: if (Unit* target = GetHitUnit()) { WorldPacket data(SMSG_SPIRIT_HEALER_CONFIRM, 8); - data << uint64(target->GetGUID()); + data << target->GetGUID(); originalCaster->GetSession()->SendPacket(&data); } } @@ -4549,7 +4549,7 @@ public: target->SetTemporaryUnsummonedPetNumber(0); // Prevent stacking of mounts and client crashes upon dismounting - target->RemoveAurasByType(SPELL_AURA_MOUNTED, 0, GetHitAura()); + target->RemoveAurasByType(SPELL_AURA_MOUNTED, ObjectGuid::Empty, GetHitAura()); // Triggered spell id dependent on riding skill and zone bool canFly = false; @@ -5096,7 +5096,7 @@ public: bool instant_exit = true; if (Player* pCaster = caster->ToPlayer()) // if is a creature instant exits combat, else check if someone in party is in combat in visibility distance { - uint64 myGUID = pCaster->GetGUID(); + ObjectGuid myGUID = pCaster->GetGUID(); float visibilityRange = pCaster->GetMap()->GetVisibilityRange(); if (Group* pGroup = pCaster->GetGroup()) { diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 53ef4de8fc..7e19c5d9bf 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -205,7 +205,7 @@ public: if (Player* target = GetHitPlayer()) { - target->KilledMonsterCredit(29579, 0); // Brann's entry + target->KilledMonsterCredit(29579); // Brann's entry target->CastSpell(target, 55038, true); // Brann summoning spell } } diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 0e81595337..7818bb573a 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -549,7 +549,7 @@ public: void FilterTargets(std::list<WorldObject*>& unitList) { - unitList.remove_if(acore::ObjectGUIDCheck(GetCaster()->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT), true)); + unitList.remove_if(acore::ObjectGUIDCheck(GetCaster()->GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT), true)); } void Register() override diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 9113592e7b..0be38a08df 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -64,7 +64,7 @@ public: { Player* player = GetCaster()->ToPlayer(); - player->KilledMonsterCredit(23343, 0); + player->KilledMonsterCredit(23343); if (Creature* cr = GetCaster()->SummonCreature(23343, ar->GetPositionX(), ar->GetPositionY(), ar->GetPositionZ(), ar->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 180000)) { cr->CastSpell(player, 40926, true); @@ -241,7 +241,7 @@ public: if (Unit* target = GetHitUnit()) if (Unit* owner = target->ToTempSummon()->GetSummoner()) if (owner->GetTypeId() == TYPEID_PLAYER) - owner->ToPlayer()->KilledMonsterCredit(23327, 0); // Some trigger, just count + owner->ToPlayer()->KilledMonsterCredit(23327); // Some trigger, just count } void Register() override @@ -348,12 +348,12 @@ public: void HandleDummy(SpellEffIndex /*effIndex*/) { if (Creature* target = GetHitCreature()) - if (target->GetDBTableGUIDLow() == 77757 || target->GetDBTableGUIDLow() == 78693) + if (target->GetSpawnId() == 77757 || target->GetSpawnId() == 78693) { count++; if (count == 2) if (GetCaster() && GetCaster()->ToPlayer()) - GetCaster()->ToPlayer()->KilledMonsterCredit(22383, 0); + GetCaster()->ToPlayer()->KilledMonsterCredit(22383); } } @@ -382,7 +382,7 @@ public: { if (GetCaster() && GetHitUnit()) if (Player* player = GetCaster()->GetCharmerOrOwnerPlayerOrPlayerItself()) - player->KilledMonsterCredit(GetHitUnit()->GetEntry(), 0); + player->KilledMonsterCredit(GetHitUnit()->GetEntry()); } void Register() override @@ -536,7 +536,7 @@ public: if (Unit* target = GetHitUnit()) if (Player* player = target->GetCharmerOrOwnerPlayerOrPlayerItself()) if (player->HasAura(38224)) - player->KilledMonsterCredit(22051, 0); + player->KilledMonsterCredit(22051); } void Register() override @@ -1201,7 +1201,7 @@ public: { creatureTarget->UpdateEntry(newEntry); creatureTarget->DespawnOrUnsummon(DESPAWN_TIME); - caster->KilledMonsterCredit(newEntry, 0); + caster->KilledMonsterCredit(newEntry); } } } @@ -1738,7 +1738,7 @@ public: if (Creature* target = GetHitCreature()) { caster->CastSpell(caster, SPELL_TRIGGER_AID_OF_THE_EARTHEN, true, nullptr); - caster->KilledMonsterCredit(NPC_FALLEN_EARTHEN_DEFENDER, 0); + caster->KilledMonsterCredit(NPC_FALLEN_EARTHEN_DEFENDER); target->DespawnOrUnsummon(); } } @@ -1872,7 +1872,7 @@ public: if (Creature* target = GetHitCreature()) { target->DespawnOrUnsummon(); - caster->KilledMonsterCredit(NPC_SCALPS_KC_BUNNY, 0); + caster->KilledMonsterCredit(NPC_SCALPS_KC_BUNNY); } } @@ -1916,7 +1916,7 @@ public: if (Creature* target = GetHitCreature()) if (target && !target->HasAura(SPELL_FLAMES)) { - caster->KilledMonsterCredit(NPC_VILLAGER_KILL_CREDIT, 0); + caster->KilledMonsterCredit(NPC_VILLAGER_KILL_CREDIT); target->CastSpell(target, SPELL_FLAMES, true); target->DespawnOrUnsummon(20000); } @@ -1960,7 +1960,7 @@ public: Player* caster = GetCaster()->ToPlayer(); if (Creature* target = GetHitCreature()) { - caster->KilledMonsterCredit(NPC_SHARD_KILL_CREDIT, 0); + caster->KilledMonsterCredit(NPC_SHARD_KILL_CREDIT); target->CastSpell(target, uint32(GetEffectValue()), true); target->DespawnOrUnsummon(2000); } @@ -2003,7 +2003,7 @@ public: Unit* caster = GetCaster(); if (caster->IsVehicle()) if (Unit* player = caster->GetVehicleKit()->GetPassenger(0)) - player->ToPlayer()->KilledMonsterCredit(NPC_KING_OF_THE_MOUNTAINT_KC, 0); + player->ToPlayer()->KilledMonsterCredit(NPC_KING_OF_THE_MOUNTAINT_KC); } void Register() override @@ -2154,7 +2154,7 @@ public: if (Creature* trigger = target->FindNearestCreature(NPC_ICE_SPIKE_BUNNY, 25.0f)) { sCreatureTextMgr->SendChat(trigger, SAY_1, target, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, target); - target->KilledMonsterCredit(NPC_KILLCREDIT, 0); + target->KilledMonsterCredit(NPC_KILLCREDIT); sCreatureTextMgr->SendChat(trigger, SAY_2, target, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, target); } } diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index 433def97e3..e021b4b265 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -116,7 +116,7 @@ public: bool Load() override { - _procTargetGUID = 0; + _procTargetGUID.Clear(); return true; } @@ -154,7 +154,7 @@ public: } private: - uint64 _procTargetGUID; + ObjectGuid _procTargetGUID; }; AuraScript* GetAuraScript() const override @@ -282,7 +282,8 @@ public: SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(enchant->spellid[s]); if (!spellInfo) { - LOG_ERROR("server", "Player::CastItemCombatSpell Enchant %i, player (Name: %s, GUID: %u) cast unknown spell %i", enchant->ID, player->GetName().c_str(), player->GetGUIDLow(), enchant->spellid[s]); + LOG_ERROR("server", "Player::CastItemCombatSpell Enchant %i, player (Name: %s, %s) cast unknown spell %i", + enchant->ID, player->GetName().c_str(), player->GetGUID().ToString().c_str(), enchant->spellid[s]); continue; } @@ -394,7 +395,7 @@ public: { while (!_targets.empty()) { - uint64 guid = acore::Containers::SelectRandomContainerElement(_targets); + ObjectGuid guid = acore::Containers::SelectRandomContainerElement(_targets); if (Unit* target = ObjectAccessor::GetUnit(*GetTarget(), guid)) { // xinef: target may be no longer valid @@ -437,7 +438,7 @@ public: } private: - std::list<uint64> _targets; + GuidList _targets; }; AuraScript* GetAuraScript() const override diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 1f516f841e..6020f7b09b 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -152,7 +152,7 @@ public: if (owner->GetAuraEffectDummy(56250)) { Unit* target = GetTarget(); - target->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE, 0, target->GetAura(32409)); // SW:D shall not be removed. + target->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE, ObjectGuid::Empty, target->GetAura(32409)); // SW:D shall not be removed. target->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT); target->RemoveAurasByType(SPELL_AURA_PERIODIC_LEECH); } @@ -275,7 +275,7 @@ public: void HandleAuraApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { // Remove Fel Armor and Demon Armor - GetTarget()->RemoveAurasWithFamily(SPELLFAMILY_WARLOCK, 0, 0x20000020, 0, 0); + GetTarget()->RemoveAurasWithFamily(SPELLFAMILY_WARLOCK, 0, 0x20000020, 0, ObjectGuid::Empty); } void Register() override diff --git a/src/server/scripts/World/action_ip_logger.cpp b/src/server/scripts/World/action_ip_logger.cpp index 23884f04ae..065d73d2f8 100644 --- a/src/server/scripts/World/action_ip_logger.cpp +++ b/src/server/scripts/World/action_ip_logger.cpp @@ -194,7 +194,7 @@ public: // We declare all the required variables uint32 playerGuid = player->GetSession()->GetAccountId(); - uint32 characterGuid = player->GetGUIDLow(); + ObjectGuid::LowType characterGuid = player->GetGUID().GetCounter(); const std::string currentIp = player->GetSession()->GetRemoteAddress(); std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it... @@ -245,18 +245,18 @@ public: CharacterDeleteActionIpLogger() : PlayerScript("CharacterDeleteActionIpLogger") { } // CHARACTER_DELETE = 10 - void OnDelete(uint64 guid, uint32 accountId) override + void OnDelete(ObjectGuid guid, uint32 accountId) override { DeleteIPLogAction(guid, accountId, CHARACTER_DELETE); } // CHARACTER_FAILED_DELETE = 11 - void OnFailedDelete(uint64 guid, uint32 accountId) override + void OnFailedDelete(ObjectGuid guid, uint32 accountId) override { DeleteIPLogAction(guid, accountId, CHARACTER_FAILED_DELETE); } - void DeleteIPLogAction(uint64 guid, uint32 playerGuid, IPLoggingTypes aType) + void DeleteIPLogAction(ObjectGuid guid, ObjectGuid::LowType playerGuid, IPLoggingTypes aType) { if (!sWorld->getBoolConfig(CONFIG_IP_BASED_ACTION_LOGGING)) return; @@ -265,7 +265,7 @@ public: // Else, this script isn't loaded in the first place: We require no config check. // We declare all the required variables - uint32 characterGuid = GUID_LOPART(guid); // We have no access to any member function of Player* or WorldSession*. So use old-fashioned way. + ObjectGuid::LowType characterGuid = guid.GetCounter(); // We have no access to any member function of Player* or WorldSession*. So use old-fashioned way. // Query playerGuid/accountId, as we only have characterGuid std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it later. diff --git a/src/server/scripts/World/boss_emerald_dragons.cpp b/src/server/scripts/World/boss_emerald_dragons.cpp index 8efe2d81ee..1bdf04a0ed 100644 --- a/src/server/scripts/World/boss_emerald_dragons.cpp +++ b/src/server/scripts/World/boss_emerald_dragons.cpp @@ -390,7 +390,7 @@ public: struct npc_spirit_shadeAI : public PassiveAI { - npc_spirit_shadeAI(Creature* creature) : PassiveAI(creature), _summonerGuid(0) + npc_spirit_shadeAI(Creature* creature) : PassiveAI(creature) { } @@ -405,7 +405,7 @@ public: void MovementInform(uint32 moveType, uint32 data) override { - if (moveType == FOLLOW_MOTION_TYPE && data == _summonerGuid) + if (moveType == FOLLOW_MOTION_TYPE && data == _summonerGuid.GetCounter()) { me->CastSpell((Unit*)nullptr, SPELL_DARK_OFFERING, false); me->DespawnOrUnsummon(1000); @@ -413,7 +413,7 @@ public: } private: - uint64 _summonerGuid; + ObjectGuid _summonerGuid; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 8f5b90a1fd..65a6d23cd0 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -311,7 +311,7 @@ public: GetCreatureListWithEntryInGrid(cList, go, NPC_WINTERFIN_TADPOLE, 5.0f); for (std::list<Creature*>::const_iterator itr = cList.begin(); itr != cList.end(); ++itr) { - player->KilledMonsterCredit(NPC_WINTERFIN_TADPOLE, 0); + player->KilledMonsterCredit(NPC_WINTERFIN_TADPOLE); (*itr)->DespawnOrUnsummon(urand(45000, 60000)); (*itr)->GetMotionMaster()->MoveFollow(player, 1.0f, frand(0.0f, 2 * M_PI), MOTION_SLOT_CONTROLLED); } @@ -1247,7 +1247,7 @@ public: return false; pPrisoner->DespawnOrUnsummon(); - player->KilledMonsterCredit(NPC_EBON_BLADE_PRISONER_HUMAN, 0); + player->KilledMonsterCredit(NPC_EBON_BLADE_PRISONER_HUMAN); switch (pPrisoner->GetEntry()) { case NPC_EBON_BLADE_PRISONER_HUMAN: @@ -1486,7 +1486,7 @@ public: if (qInfo) { /// @todo prisoner should help player for a short period of time - player->KilledMonsterCredit(qInfo->RequiredNpcOrGo[0], 0); + player->KilledMonsterCredit(qInfo->RequiredNpcOrGo[0]); pPrisoner->DisappearAndDie(); } return true; diff --git a/src/server/scripts/World/guards.cpp b/src/server/scripts/World/guards.cpp index e01a6812dc..d508ff191a 100644 --- a/src/server/scripts/World/guards.cpp +++ b/src/server/scripts/World/guards.cpp @@ -44,7 +44,7 @@ public: { banishTimer = 5000; exileTimer = 8500; - playerGUID = 0; + playerGUID.Clear(); canTeleport = false; } @@ -62,7 +62,7 @@ public: temp->CastSpell(temp, SPELL_EXILE, true); temp->CastSpell(temp, SPELL_BANISH_TELEPORT, true); } - playerGUID = 0; + playerGUID.Clear(); exileTimer = 8500; canTeleport = false; } @@ -88,7 +88,7 @@ public: private: uint32 exileTimer; uint32 banishTimer; - uint64 playerGUID; + ObjectGuid playerGUID; bool canTeleport; }; @@ -111,7 +111,7 @@ public: { banishTimer = 5000; exileTimer = 8500; - playerGUID = 0; + playerGUID.Clear(); canTeleport = false; } @@ -129,7 +129,7 @@ public: temp->CastSpell(temp, SPELL_EXILE, true); temp->CastSpell(temp, SPELL_BANISH_TELEPORT, true); } - playerGUID = 0; + playerGUID.Clear(); exileTimer = 8500; canTeleport = false; } @@ -154,7 +154,7 @@ public: private: uint32 exileTimer; uint32 banishTimer; - uint64 playerGUID; + ObjectGuid playerGUID; bool canTeleport; }; diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 59d348e214..3657d052f5 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -488,7 +488,7 @@ public: npc_air_force_botsAI(Creature* creature) : ScriptedAI(creature) { SpawnAssoc = nullptr; - SpawnedGUID = 0; + SpawnedGUID.Clear(); // find the correct spawnhandling static uint32 entryCount = sizeof(spawnAssociations) / sizeof(SpawnAssociation); @@ -518,7 +518,7 @@ public: } SpawnAssociation* SpawnAssoc; - uint64 SpawnedGUID; + ObjectGuid SpawnedGUID; void Reset() override {} @@ -561,11 +561,11 @@ public: if (!playerTarget) return; - Creature* lastSpawnedGuard = SpawnedGUID == 0 ? nullptr : GetSummonedGuard(); + Creature* lastSpawnedGuard = !SpawnedGUID ? nullptr : GetSummonedGuard(); // prevent calling ObjectAccessor::GetUnit at next MoveInLineOfSight call - speedup if (!lastSpawnedGuard) - SpawnedGUID = 0; + SpawnedGUID.Clear(); switch (SpawnAssoc->spawnType) { @@ -892,7 +892,7 @@ public: { npc_doctorAI(Creature* creature) : ScriptedAI(creature) { } - uint64 PlayerGUID; + ObjectGuid PlayerGUID; uint32 SummonPatientTimer; uint32 SummonPatientCount; @@ -901,12 +901,12 @@ public: bool Event; - std::list<uint64> Patients; + GuidList Patients; std::vector<Location*> Coordinates; void Reset() override { - PlayerGUID = 0; + PlayerGUID.Clear(); SummonPatientTimer = 10000; SummonPatientCount = 0; @@ -983,10 +983,9 @@ public: { if (!Patients.empty()) { - std::list<uint64>::const_iterator itr; - for (itr = Patients.begin(); itr != Patients.end(); ++itr) + for (ObjectGuid const guid : Patients) { - if (Creature* patient = ObjectAccessor::GetCreature((*me), *itr)) + if (Creature* patient = ObjectAccessor::GetCreature(*me, guid)) patient->setDeathState(JUST_DIED); } } @@ -1037,12 +1036,12 @@ public: { npc_injured_patientAI(Creature* creature) : ScriptedAI(creature) { } - uint64 DoctorGUID; + ObjectGuid DoctorGUID; Location* Coord; void Reset() override { - DoctorGUID = 0; + DoctorGUID.Clear(); Coord = nullptr; //no select @@ -1236,7 +1235,7 @@ public: Reset(); } - uint64 CasterGUID; + ObjectGuid CasterGUID; bool IsHealed; bool CanRun; @@ -1245,7 +1244,7 @@ public: void Reset() override { - CasterGUID = 0; + CasterGUID.Clear(); IsHealed = false; CanRun = false; @@ -1393,7 +1392,7 @@ public: break; } - Start(false, true, true); + Start(false, true); } else EnterEvadeMode(); //something went wrong @@ -2321,12 +2320,12 @@ public: uint32 jumpTimer; uint32 bunnyTimer; uint32 searchTimer; - uint64 rabbitGUID; + ObjectGuid rabbitGUID; void Reset() override { inLove = false; - rabbitGUID = 0; + rabbitGUID.Clear(); jumpTimer = urand(5000, 10000); bunnyTimer = urand(10000, 20000); searchTimer = urand(5000, 10000); diff --git a/src/server/worldserver/WorldThread/WorldRunnable.cpp b/src/server/worldserver/WorldThread/WorldRunnable.cpp index 8f4fa92738..0eecaf5922 100644 --- a/src/server/worldserver/WorldThread/WorldRunnable.cpp +++ b/src/server/worldserver/WorldThread/WorldRunnable.cpp @@ -75,9 +75,8 @@ void WorldRunnable::run() sWorldSocketMgr->StopNetwork(); sMapMgr->UnloadAll(); // unload all grids (including locked in memory) - sObjectAccessor->UnloadAll(); // unload 'i_player2corpse' storage and remove from world - sScriptMgr->Unload(); sOutdoorPvPMgr->Die(); + sScriptMgr->Unload(); #ifdef ELUNA Eluna::Uninitialize(); #endif diff --git a/src/test/mocks/WorldMock.h b/src/test/mocks/WorldMock.h index 4759f10736..059497bd46 100644 --- a/src/test/mocks/WorldMock.h +++ b/src/test/mocks/WorldMock.h @@ -21,7 +21,7 @@ public: ~WorldMock() override {} MOCK_METHOD(WorldSession*, FindSession, (uint32 id), (const)); MOCK_METHOD(WorldSession*, FindOfflineSession, (uint32 id), (const)); - MOCK_METHOD(WorldSession*, FindOfflineSessionForCharacterGUID, (uint32 guidLow),(const)); + MOCK_METHOD(WorldSession*, FindOfflineSessionForCharacterGUID, (ObjectGuid::LowType guidLow),(const)); MOCK_METHOD(void, AddSession, (WorldSession* s), ()); MOCK_METHOD(void, SendAutoBroadcast, ()); MOCK_METHOD(bool, KickSession, (uint32 id), ()); @@ -97,16 +97,16 @@ public: MOCK_METHOD(void, KickAllLess, (AccountTypes sec), ()); MOCK_METHOD(uint32, GetNextWhoListUpdateDelaySecs, ()); MOCK_METHOD(void, LoadGlobalPlayerDataStore, ()); - MOCK_METHOD(uint32, GetGlobalPlayerGUID, (std::string const& name), (const)); - MOCK_METHOD(GlobalPlayerData const*, GetGlobalPlayerData, (uint32 guid), (const)); - MOCK_METHOD(void, AddGlobalPlayerData, (uint32 guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, uint16 mailCount, uint32 guildId), ()); - MOCK_METHOD(void, UpdateGlobalPlayerData, (uint32 guid, uint8 mask, std::string const& name, uint8 level, uint8 gender, uint8 race, uint8 playerClass), ()); - MOCK_METHOD(void, UpdateGlobalPlayerMails, (uint32 guid, int16 count, bool add), ()); - MOCK_METHOD(void, UpdateGlobalPlayerGuild, (uint32 guid, uint32 guildId), ()); - MOCK_METHOD(void, UpdateGlobalPlayerGroup, (uint32 guid, uint32 groupId), ()); - MOCK_METHOD(void, UpdateGlobalPlayerArenaTeam, (uint32 guid, uint8 slot, uint32 arenaTeamId), ()); - MOCK_METHOD(void, UpdateGlobalNameData, (uint32 guidLow, std::string const& oldName, std::string const& newName), ()); - MOCK_METHOD(void, DeleteGlobalPlayerData, (uint32 guid, std::string const& name), ()); + MOCK_METHOD(ObjectGuid, GetGlobalPlayerGUID, (std::string const& name), (const)); + MOCK_METHOD(GlobalPlayerData const*, GetGlobalPlayerData, (ObjectGuid::LowType guid), (const)); + MOCK_METHOD(void, AddGlobalPlayerData, (ObjectGuid::LowType guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, uint16 mailCount, uint32 guildId), ()); + MOCK_METHOD(void, UpdateGlobalPlayerData, (ObjectGuid::LowType guid, uint8 mask, std::string const& name, uint8 level, uint8 gender, uint8 race, uint8 playerClass), ()); + MOCK_METHOD(void, UpdateGlobalPlayerMails, (ObjectGuid::LowType guid, int16 count, bool add), ()); + MOCK_METHOD(void, UpdateGlobalPlayerGuild, (ObjectGuid::LowType guid, uint32 guildId), ()); + MOCK_METHOD(void, UpdateGlobalPlayerGroup, (ObjectGuid::LowType guid, uint32 groupId), ()); + MOCK_METHOD(void, UpdateGlobalPlayerArenaTeam, (ObjectGuid::LowType guid, uint8 slot, uint32 arenaTeamId), ()); + MOCK_METHOD(void, UpdateGlobalNameData, (ObjectGuid::LowType guidLow, std::string const& oldName, std::string const& newName), ()); + MOCK_METHOD(void, DeleteGlobalPlayerData, (ObjectGuid::LowType guid, std::string const& name), ()); MOCK_METHOD(void, ProcessCliCommands, ()); MOCK_METHOD(void, QueueCliCommand, (CliCommandHolder* commandHolder), ()); MOCK_METHOD(void, ForceGameEventUpdate, ()); @@ -123,6 +123,7 @@ public: MOCK_METHOD(time_t, GetNextTimeWithMonthAndHour, (int8 month, int8 hour), ()); MOCK_METHOD(std::string const&, GetRealmName, (), (const)); MOCK_METHOD(void, SetRealmName, (std::string name), ()); + MOCK_METHOD(void, RemoveOldCorpses, ()); }; #pragma GCC diagnostic pop |