diff --git a/BindingMap.h b/BindingMap.h index 1e5b281..287d489 100644 --- a/BindingMap.h +++ b/BindingMap.h @@ -251,10 +251,10 @@ template struct UniqueObjectKey { T event_id; - uint64 guid; + ObjectGuid guid; uint32 instance_id; - UniqueObjectKey(T event_id, uint64 guid, uint32 instance_id) : + UniqueObjectKey(T event_id, ObjectGuid guid, uint32 instance_id) : event_id(event_id), guid(guid), instance_id(instance_id) @@ -367,7 +367,7 @@ namespace std hash_helper::result_type operator()(argument_type const& k) const { - return hash_helper::hash(k.event_id, k.instance_id, k.guid); + return hash_helper::hash(k.event_id, k.instance_id, k.guid.GetRawValue()); } }; } diff --git a/CorpseMethods.h b/CorpseMethods.h index 852081e..aba7d20 100644 --- a/CorpseMethods.h +++ b/CorpseMethods.h @@ -17,7 +17,7 @@ namespace LuaCorpse /** * Returns the GUID of the [Player] that left the [Corpse] behind. * - * @return uint64 ownerGUID + * @return ObjectGuid ownerGUID */ int GetOwnerGUID(lua_State* L, Corpse* corpse) { diff --git a/CreatureMethods.h b/CreatureMethods.h index 6b1d82c..256ff58 100644 --- a/CreatureMethods.h +++ b/CreatureMethods.h @@ -924,7 +924,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); */ int GetDBTableGUIDLow(lua_State* L, Creature* creature) { -#if defined(TRINITY) +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->GetSpawnId()); #else // on mangos based this is same as lowguid diff --git a/ElunaUtility.h b/ElunaUtility.h index ad79e1c..f9ea024 100644 --- a/ElunaUtility.h +++ b/ElunaUtility.h @@ -47,10 +47,24 @@ typedef QueryResult ElunaQuery; #define HIGHGUID_GROUP HighGuid::Group #elif AZEROTHCORE typedef QueryResult ElunaQuery; -#define ELUNA_LOG_INFO(...) sLog->outString(__VA_ARGS__); -#define ELUNA_LOG_ERROR(...) sLog->outError(__VA_ARGS__); -#define ELUNA_LOG_DEBUG(...) sLog->outDebug(LOG_FILTER_NONE,__VA_ARGS__); +#define ELUNA_LOG_INFO(...) LOG_INFO("eluna", __VA_ARGS__); +#define ELUNA_LOG_ERROR(...) LOG_ERROR("eluna", __VA_ARGS__); +#define ELUNA_LOG_DEBUG(...) LOG_DEBUG("eluna", __VA_ARGS__); #define GET_GUID GetGUID + +#define HIGHGUID_PLAYER HighGuid::Player +#define HIGHGUID_UNIT HighGuid::Unit +#define HIGHGUID_ITEM HighGuid::Item +#define HIGHGUID_GAMEOBJECT HighGuid::GameObject +#define HIGHGUID_PET HighGuid::Pet +#define HIGHGUID_TRANSPORT HighGuid::Transport +#define HIGHGUID_VEHICLE HighGuid::Vehicle +#define HIGHGUID_CONTAINER HighGuid::Container +#define HIGHGUID_DYNAMICOBJECT HighGuid::DynamicObject +#define HIGHGUID_CORPSE HighGuid::Corpse +#define HIGHGUID_MO_TRANSPORT HighGuid::Mo_Transport +#define HIGHGUID_INSTANCE HighGuid::Instance +#define HIGHGUID_GROUP HighGuid::Group #else typedef QueryNamedResult ElunaQuery; #define ASSERT MANGOS_ASSERT @@ -63,7 +77,7 @@ typedef QueryNamedResult ElunaQuery; #define GetTemplate GetProto #endif -#if defined(TRINITY) || defined(MANGOS) +#if defined(TRINITY) || defined(AZEROTHCORE) || defined(MANGOS) #ifndef MAKE_NEW_GUID #define MAKE_NEW_GUID(l, e, h) ObjectGuid(h, e, l) #endif diff --git a/GameObjectMethods.h b/GameObjectMethods.h index cf9ed65..b96305f 100644 --- a/GameObjectMethods.h +++ b/GameObjectMethods.h @@ -160,10 +160,8 @@ namespace LuaGameObject */ int GetDBTableGUIDLow(lua_State* L, GameObject* go) { -#ifdef TRINITY +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, go->GetSpawnId()); -#elif AZEROTHCORE - Eluna::Push(L, go->GetDBTableGUIDLow()); #else // on mangos based this is same as lowguid Eluna::Push(L, go->GetGUIDLow()); diff --git a/GlobalMethods.h b/GlobalMethods.h index 67c26e0..4d32e30 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -124,13 +124,13 @@ namespace LuaGlobalFunctions /** * Finds and Returns [Player] by guid if found * - * @param uint64 guid : guid of the [Player], you can get it with [Object:GetGUID] + * @param ObjectGuid guid : guid of the [Player], you can get it with [Object:GetGUID] * @return [Player] player */ int GetPlayerByGUID(lua_State* L) { - uint64 guid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, eObjectAccessor()FindPlayer(ObjectGuid(guid))); + ObjectGuid guid = Eluna::CHECKVAL(L, 1); + Eluna::Push(L, eObjectAccessor()FindPlayer(guid)); return 1; } @@ -261,14 +261,14 @@ namespace LuaGlobalFunctions /** * Returns [Guild] by the leader's GUID * - * @param uint64 guid : the guid of a [Guild] leader + * @param ObjectGuid guid : the guid of a [Guild] leader * @return [Guild] guild, or `nil` if it doesn't exist */ int GetGuildByLeaderGUID(lua_State* L) { - uint64 guid = Eluna::CHECKVAL(L, 1); + ObjectGuid guid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, eGuildMgr->GetGuildByLeader(ObjectGuid(guid))); + Eluna::Push(L, eGuildMgr->GetGuildByLeader(guid)); return 1; } @@ -291,7 +291,7 @@ namespace LuaGlobalFunctions * [Player] and [Creature] for example can have the same low GUID but not GUID. * * @param uint32 lowguid : low GUID of the [Player] - * @return uint64 guid + * @return ObjectGuid guid */ int GetPlayerGUID(lua_State* L) { @@ -307,7 +307,7 @@ namespace LuaGlobalFunctions * [Player] and [Item] for example can have the same low GUID but not GUID. * * @param uint32 lowguid : low GUID of the [Item] - * @return uint64 guid + * @return ObjectGuid guid */ int GetItemGUID(lua_State* L) { @@ -325,7 +325,7 @@ namespace LuaGlobalFunctions * * @param uint32 lowguid : low GUID of the [GameObject] * @param uint32 entry : entry ID of the [GameObject] - * @return uint64 guid + * @return ObjectGuid guid */ int GetObjectGUID(lua_State* L) { @@ -344,7 +344,7 @@ namespace LuaGlobalFunctions * * @param uint32 lowguid : low GUID of the [Creature] * @param uint32 entry : entry ID of the [Creature] - * @return uint64 guid + * @return ObjectGuid guid */ int GetUnitGUID(lua_State* L) { @@ -370,14 +370,14 @@ namespace LuaGlobalFunctions * For example creatures in instances use the same low GUID assigned for that spawn in the database. * This is why to identify a creature you have to know the instanceId and low GUID. See [Map:GetIntstanceId] * - * @param uint64 guid : GUID of an [Object] + * @param ObjectGuid guid : GUID of an [Object] * @return uint32 lowguid : low GUID of the [Object] */ int GetGUIDLow(lua_State* L) { - uint64 guid = Eluna::CHECKVAL(L, 1); + ObjectGuid guid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, GUID_LOPART(guid)); + Eluna::Push(L, guid.GetCounter()); return 1; } @@ -435,13 +435,13 @@ namespace LuaGlobalFunctions * * GUID consist of entry ID, low GUID, and type ID. * - * @param uint64 guid : GUID of an [Object] + * @param ObjectGuid guid : GUID of an [Object] * @return int32 typeId : type ID of the [Object] */ int GetGUIDType(lua_State* L) { - uint64 guid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, static_cast(GUID_HIPART(guid))); + ObjectGuid guid = Eluna::CHECKVAL(L, 1); + Eluna::Push(L, static_cast(guid.GetHigh())); return 1; } @@ -450,13 +450,13 @@ namespace LuaGlobalFunctions * * GUID consist of entry ID, low GUID, and type ID. * - * @param uint64 guid : GUID of an [Creature] or [GameObject] + * @param ObjectGuid guid : GUID of an [Creature] or [GameObject] * @return uint32 entry : entry ID, or `0` if `guid` is not a [Creature] or [GameObject] */ int GetGUIDEntry(lua_State* L) { - uint64 guid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, GUID_ENPART(guid)); + ObjectGuid guid = Eluna::CHECKVAL(L, 1); + Eluna::Push(L, guid.GetEntry()); return 1; } @@ -537,7 +537,7 @@ namespace LuaGlobalFunctions lua_pushvalue(L, 3); int functionRef = luaL_ref(L, LUA_REGISTRYINDEX); if (functionRef >= 0) - return Eluna::GetEluna(L)->Register(L, regtype, id, 0, 0, ev, functionRef, shots); + return Eluna::GetEluna(L)->Register(L, regtype, id, ObjectGuid(), 0, ev, functionRef, shots); else luaL_argerror(L, 3, "unable to make a ref to function"); return 0; @@ -552,7 +552,7 @@ namespace LuaGlobalFunctions lua_pushvalue(L, 2); int functionRef = luaL_ref(L, LUA_REGISTRYINDEX); if (functionRef >= 0) - return Eluna::GetEluna(L)->Register(L, regtype, 0, 0, 0, ev, functionRef, shots); + return Eluna::GetEluna(L)->Register(L, regtype, 0, ObjectGuid(), 0, ev, functionRef, shots); else luaL_argerror(L, 2, "unable to make a ref to function"); return 0; @@ -560,7 +560,7 @@ namespace LuaGlobalFunctions static int RegisterUniqueHelper(lua_State* L, int regtype) { - uint64 guid = Eluna::CHECKVAL(L, 1); + ObjectGuid guid = Eluna::CHECKVAL(L, 1); uint32 instanceId = Eluna::CHECKVAL(L, 2); uint32 ev = Eluna::CHECKVAL(L, 3); luaL_checktype(L, 4, LUA_TFUNCTION); @@ -1149,7 +1149,7 @@ namespace LuaGlobalFunctions * @proto cancel = (guid, instance_id, event, function) * @proto cancel = (guid, instance_id, event, function, shots) * - * @param uint64 guid : the GUID of a single [Creature] + * @param ObjectGuid guid : the GUID of a single [Creature] * @param uint32 instance_id : the instance ID of a single [Creature] * @param uint32 event : refer to CreatureEvents above * @param function function : function that will be called when the event occurs @@ -1708,7 +1708,7 @@ namespace LuaGlobalFunctions #ifndef AZEROTHCORE if (!creature->Create(map->GenerateLowGuid(), map, phase, entry, pos)) #else - if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, phase, entry, 0, x, y, z, o)) + if (!creature->Create(map->GenerateLowGuid(), map, phase, entry, 0, x, y, z, o)) #endif { delete creature; @@ -1718,11 +1718,8 @@ namespace LuaGlobalFunctions creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase); -#ifndef AZEROTHCORE uint32 db_guid = creature->GetSpawnId(); -#else - uint32 db_guid = creature->GetDBTableGUIDLow(); -#endif + // 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(); @@ -1731,7 +1728,7 @@ namespace LuaGlobalFunctions #ifndef AZEROTHCORE if (!creature->LoadFromDB(db_guid, map, true, true)) #else - if (!creature->LoadFromDB(db_guid, map)) + if (!creature->LoadFromDB(db_guid, map, true)) #endif { delete creature; @@ -1783,7 +1780,7 @@ namespace LuaGlobalFunctions QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); if (!object->Create(guidLow, objectInfo->entry, map, phase, Position(x, y, z, o), rot, 0, GO_STATE_READY)) #else - uint32 guidLow = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT); + uint32 guidLow = map->GenerateLowGuid(); if (!object->Create(guidLow, entry, map, phase, x, y, z, o, G3D::Quat(0.0f, 0.0f, 0.0f, 0.0f), 100, GO_STATE_READY)) #endif { @@ -1799,11 +1796,7 @@ namespace LuaGlobalFunctions { // fill the gameobject data and save to the db object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase); -#ifndef AZEROTHCORE guidLow = object->GetSpawnId(); -#else - guidLow = object->GetDBTableGUIDLow(); -#endif // delete the old object and do a clean load from DB with a fresh new GameObject instance. // this is required to avoid weird behavior and memory leaks @@ -2157,7 +2150,7 @@ namespace LuaGlobalFunctions item->SaveToDB(); #endif draft.AddItem(item); -#if defined TRINITY +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, item->GetGUID().GetCounter()); #else Eluna::Push(L, item->GetGUIDLow()); @@ -2768,7 +2761,7 @@ namespace LuaGlobalFunctions * * @proto (entry) * @proto (entry, event_type) - * @param uint64 guid : the GUID of a single [Creature] whose handlers will be cleared + * @param ObjectGuid guid : the GUID of a single [Creature] whose handlers will be cleared * @param uint32 instance_id : the instance ID of a single [Creature] whose handlers will be cleared * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterCreatureEvent] */ @@ -2778,7 +2771,7 @@ namespace LuaGlobalFunctions if (lua_isnoneornil(L, 3)) { - uint64 guid = Eluna::CHECKVAL(L, 1); + ObjectGuid guid = Eluna::CHECKVAL(L, 1); uint32 instanceId = Eluna::CHECKVAL(L, 2); Eluna* E = Eluna::GetEluna(L); @@ -2787,7 +2780,7 @@ namespace LuaGlobalFunctions } else { - uint64 guid = Eluna::CHECKVAL(L, 1); + ObjectGuid guid = Eluna::CHECKVAL(L, 1); uint32 instanceId = Eluna::CHECKVAL(L, 2); uint32 event_type = Eluna::CHECKVAL(L, 3); Eluna::GetEluna(L)->CreatureUniqueBindings->Clear(Key((Hooks::CreatureEvents)event_type, guid, instanceId)); diff --git a/GroupHooks.cpp b/GroupHooks.cpp index 8ed8f7c..f674957 100644 --- a/GroupHooks.cpp +++ b/GroupHooks.cpp @@ -20,7 +20,7 @@ using namespace Hooks; return;\ LOCK_ELUNA -void Eluna::OnAddMember(Group* group, uint64 guid) +void Eluna::OnAddMember(Group* group, ObjectGuid guid) { START_HOOK(GROUP_EVENT_ON_MEMBER_ADD); Push(group); @@ -28,7 +28,7 @@ void Eluna::OnAddMember(Group* group, uint64 guid) CallAllFunctions(GroupEventBindings, key); } -void Eluna::OnInviteMember(Group* group, uint64 guid) +void Eluna::OnInviteMember(Group* group, ObjectGuid guid) { START_HOOK(GROUP_EVENT_ON_MEMBER_INVITE); Push(group); @@ -36,7 +36,7 @@ void Eluna::OnInviteMember(Group* group, uint64 guid) CallAllFunctions(GroupEventBindings, key); } -void Eluna::OnRemoveMember(Group* group, uint64 guid, uint8 method) +void Eluna::OnRemoveMember(Group* group, ObjectGuid guid, uint8 method) { START_HOOK(GROUP_EVENT_ON_MEMBER_REMOVE); Push(group); @@ -45,7 +45,7 @@ void Eluna::OnRemoveMember(Group* group, uint64 guid, uint8 method) CallAllFunctions(GroupEventBindings, key); } -void Eluna::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid) +void Eluna::OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid) { START_HOOK(GROUP_EVENT_ON_LEADER_CHANGE); Push(group); @@ -61,7 +61,7 @@ void Eluna::OnDisband(Group* group) CallAllFunctions(GroupEventBindings, key); } -void Eluna::OnCreate(Group* group, uint64 leaderGuid, GroupType groupType) +void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType) { START_HOOK(GROUP_EVENT_ON_CREATE); Push(group); diff --git a/GroupMethods.h b/GroupMethods.h index 3fedbc8..27ac9b9 100644 --- a/GroupMethods.h +++ b/GroupMethods.h @@ -15,13 +15,13 @@ namespace LuaGroup /** * Returns 'true' if the [Player] is the [Group] leader * - * @param uint64 guid : guid of a possible leader + * @param ObjectGuid guid : guid of a possible leader * @return bool isLeader */ int IsLeader(lua_State* L, Group* group) { - uint64 guid = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, group->IsLeader(ObjectGuid(guid))); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); + Eluna::Push(L, group->IsLeader(guid)); return 1; } @@ -61,26 +61,26 @@ namespace LuaGroup /** * Returns 'true' if the [Player] is a member of this [Group] * - * @param uint64 guid : guid of a player + * @param ObjectGuid guid : guid of a player * @return bool isMember */ int IsMember(lua_State* L, Group* group) { - uint64 guid = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, group->IsMember(ObjectGuid(guid))); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); + Eluna::Push(L, group->IsMember(guid)); return 1; } /** * Returns 'true' if the [Player] is an assistant of this [Group] * - * @param uint64 guid : guid of a player + * @param ObjectGuid guid : guid of a player * @return bool isAssistant */ int IsAssistant(lua_State* L, Group* group) { - uint64 guid = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, group->IsAssistant(ObjectGuid(guid))); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); + Eluna::Push(L, group->IsAssistant(guid)); return 1; } @@ -195,7 +195,7 @@ namespace LuaGroup /** * Returns [Group] leader GUID * - * @return uint64 leaderGUID + * @return ObjectGuid leaderGUID */ int GetLeaderGUID(lua_State* L, Group* group) { @@ -210,7 +210,7 @@ namespace LuaGroup /** * Returns the [Group]'s GUID * - * @return uint64 groupGUID + * @return ObjectGuid groupGUID */ int GetGUID(lua_State* L, Group* group) { @@ -226,7 +226,7 @@ namespace LuaGroup * Returns a [Group] member's GUID by their name * * @param string name : the [Player]'s name - * @return uint64 memberGUID + * @return ObjectGuid memberGUID */ int GetMemberGUID(lua_State* L, Group* group) { @@ -253,25 +253,25 @@ namespace LuaGroup /** * Returns the [Player]'s subgroup ID of this [Group] * - * @param uint64 guid : guid of the player + * @param ObjectGuid guid : guid of the player * @return uint8 subGroupID : a valid subgroup ID or MAX_RAID_SUBGROUPS+1 */ int GetMemberGroup(lua_State* L, Group* group) { - uint64 guid = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, group->GetMemberGroup(ObjectGuid(guid))); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); + Eluna::Push(L, group->GetMemberGroup(guid)); return 1; } /** * Sets the leader of this [Group] * - * @param uint64 guid : guid of the new leader + * @param ObjectGuid guid : guid of the new leader */ int SetLeader(lua_State* L, Group* group) { - uint64 guid = Eluna::CHECKVAL(L, 2); - group->ChangeLeader(ObjectGuid(guid)); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); + group->ChangeLeader(guid); group->SendUpdate(); return 0; } @@ -281,18 +281,18 @@ namespace LuaGroup * * @param [WorldPacket] packet : the [WorldPacket] to send * @param bool ignorePlayersInBg : ignores [Player]s in a battleground - * @param uint64 ignore : ignore a [Player] by their GUID + * @param ObjectGuid ignore : ignore a [Player] by their GUID */ int SendPacket(lua_State* L, Group* group) { WorldPacket* data = Eluna::CHECKOBJ(L, 2); bool ignorePlayersInBg = Eluna::CHECKVAL(L, 3); - uint64 ignore = Eluna::CHECKVAL(L, 4); + ObjectGuid ignore = Eluna::CHECKVAL(L, 4); #ifdef CMANGOS - group->BroadcastPacket(*data, ignorePlayersInBg, -1, ObjectGuid(ignore)); + group->BroadcastPacket(*data, ignorePlayersInBg, -1, ignore); #else - group->BroadcastPacket(data, ignorePlayersInBg, -1, ObjectGuid(ignore)); + group->BroadcastPacket(data, ignorePlayersInBg, -1, ignore); #endif return 0; } @@ -310,19 +310,19 @@ namespace LuaGroup * }; * * - * @param uint64 guid : guid of the player to remove + * @param ObjectGuid guid : guid of the player to remove * @param [RemoveMethod] method : method used to remove the player * @return bool removed */ int RemoveMember(lua_State* L, Group* group) { - uint64 guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); uint32 method = Eluna::CHECKVAL(L, 3, 0); #if defined TRINITY || AZEROTHCORE - Eluna::Push(L, group->RemoveMember(ObjectGuid(guid), (RemoveMethod)method)); + Eluna::Push(L, group->RemoveMember(guid, (RemoveMethod)method)); #else - Eluna::Push(L, group->RemoveMember(ObjectGuid(guid), method)); + Eluna::Push(L, group->RemoveMember(guid, method)); #endif return 1; } @@ -350,12 +350,12 @@ namespace LuaGroup /** * Sets the member's subGroup * - * @param uint64 guid : guid of the player to move + * @param ObjectGuid guid : guid of the player to move * @param uint8 groupID : the subGroup's ID */ int SetMembersGroup(lua_State* L, Group* group) { - uint64 guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); uint8 subGroup = Eluna::CHECKVAL(L, 3); if (subGroup >= MAX_RAID_SUBGROUPS) @@ -367,7 +367,7 @@ namespace LuaGroup if (!group->HasFreeSlotSubGroup(subGroup)) return 0; - group->ChangeMembersGroup(ObjectGuid(guid), subGroup); + group->ChangeMembersGroup(guid, subGroup); return 0; } @@ -375,22 +375,22 @@ namespace LuaGroup * Sets the target icon of an object for the [Group] * * @param uint8 icon : the icon (Skull, Square, etc) - * @param uint64 target : GUID of the icon target, 0 is to clear the icon - * @param uint64 setter : GUID of the icon setter + * @param ObjectGuid target : GUID of the icon target, 0 is to clear the icon + * @param ObjectGuid setter : GUID of the icon setter */ int SetTargetIcon(lua_State* L, Group* group) { uint8 icon = Eluna::CHECKVAL(L, 2); - uint64 target = Eluna::CHECKVAL(L, 3); - uint64 setter = Eluna::CHECKVAL(L, 4, 0); + ObjectGuid target = Eluna::CHECKVAL(L, 3); + ObjectGuid setter = Eluna::CHECKVAL(L, 4, ObjectGuid()); if (icon >= TARGETICONCOUNT) return luaL_argerror(L, 2, "valid target icon expected"); #if (defined(CLASSIC) || defined(TBC)) - group->SetTargetIcon(icon, ObjectGuid(target)); + group->SetTargetIcon(icon, target); #else - group->SetTargetIcon(icon, ObjectGuid(setter), ObjectGuid(target)); + group->SetTargetIcon(icon, setter, target); #endif return 0; } diff --git a/GuildMethods.h b/GuildMethods.h index 64b8c19..ba9863f 100644 --- a/GuildMethods.h +++ b/GuildMethods.h @@ -92,7 +92,7 @@ namespace LuaGuild /** * Returns [Guild] leader GUID * - * @return uint64 leaderGUID + * @return ObjectGuid leaderGUID */ int GetLeaderGUID(lua_State* L, Guild* guild) { diff --git a/ItemHooks.cpp b/ItemHooks.cpp index 5cc10be..ddd0223 100644 --- a/ItemHooks.cpp +++ b/ItemHooks.cpp @@ -71,7 +71,7 @@ bool Eluna::OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets) // This is a hack fix to stop spell casting visual bug when a spell is not cast on use WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, 18); data << uint8(59); // EQUIP_ERR_NONE / EQUIP_ERR_CANT_BE_DISENCHANTED - data << ObjectGuid(guid); + data << guid; data << ObjectGuid(uint64(0)); data << uint8(0); #ifdef CMANGOS diff --git a/LuaEngine.cpp b/LuaEngine.cpp index b7c7234..5b3b8dd 100644 --- a/LuaEngine.cpp +++ b/LuaEngine.cpp @@ -749,6 +749,10 @@ void Eluna::Push(lua_State* luastate, Object const* obj) ElunaTemplate::Push(luastate, obj); } } +void Eluna::Push(lua_State* luastate, ObjectGuid const guid) +{ + ElunaTemplate::Push(luastate, new unsigned long long(guid.GetRawValue())); +} static int CheckIntegerRange(lua_State* luastate, int narg, int min, int max) { @@ -851,6 +855,10 @@ template<> unsigned long Eluna::CHECKVAL(lua_State* luastate, int { return static_cast(CHECKVAL(luastate, narg)); } +template<> ObjectGuid Eluna::CHECKVAL(lua_State* luastate, int narg) +{ + return ObjectGuid(uint64((CHECKVAL(luastate, narg)))); +} template<> Object* Eluna::CHECKOBJ(lua_State* luastate, int narg, bool error) { @@ -936,7 +944,7 @@ static void createCancelCallback(lua_State* L, uint64 bindingID, BindingMap* } // Saves the function reference ID given to the register type's store for given entry under the given event -int Eluna::Register(lua_State* L, uint8 regtype, uint32 entry, uint64 guid, uint32 instanceId, uint32 event_id, int functionRef, uint32 shots) +int Eluna::Register(lua_State* L, uint8 regtype, uint32 entry, ObjectGuid guid, uint32 instanceId, uint32 event_id, int functionRef, uint32 shots) { uint64 bindingID; @@ -1037,7 +1045,7 @@ int Eluna::Register(lua_State* L, uint8 regtype, uint32 entry, uint64 guid, uint } else { - if (guid == 0) + if (guid.IsEmpty()) { luaL_unref(L, LUA_REGISTRYINDEX, functionRef); luaL_error(L, "guid was 0!"); @@ -1167,7 +1175,7 @@ int Eluna::Register(lua_State* L, uint8 regtype, uint32 entry, uint64 guid, uint } luaL_unref(L, LUA_REGISTRYINDEX, functionRef); std::ostringstream oss; - oss << "regtype " << static_cast(regtype) << ", event " << event_id << ", entry " << entry << ", guid " << guid << ", instance " << instanceId; + oss << "regtype " << static_cast(regtype) << ", event " << event_id << ", entry " << entry << ", guid " << guid.GetRawValue() << ", instance " << instanceId; luaL_error(L, "Unknown event type (%s)", oss.str().c_str()); return 0; } diff --git a/LuaEngine.h b/LuaEngine.h index bc64940..19bec63 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -188,7 +188,7 @@ private: // Some helpers for hooks to call event handlers. // The bodies of the templates are in HookHelpers.h, so if you want to use them you need to #include "HookHelpers.h". template int SetupStack(BindingMap* bindings1, BindingMap* bindings2, const K1& key1, const K2& key2, int number_of_arguments); - int CallOneFunction(int number_of_functions, int number_of_arguments, int number_of_results); + int CallOneFunction(int number_of_functions, int number_of_arguments, int number_of_results); void CleanUpStack(int number_of_arguments); template void ReplaceArgument(T value, uint8 index); template void CallAllFunctions(BindingMap* bindings1, BindingMap* bindings2, const K1& key1, const K2& key2); @@ -223,6 +223,7 @@ private: void Push(const double value) { Push(L, value); ++push_counter; } void Push(const std::string& value) { Push(L, value); ++push_counter; } void Push(const char* value) { Push(L, value); ++push_counter; } + void Push(ObjectGuid const value) { Push(L, value); ++push_counter; } template void Push(T const* ptr) { Push(L, ptr); ++push_counter; } @@ -288,6 +289,7 @@ public: static void Push(lua_State* luastate, Unit const* unit); static void Push(lua_State* luastate, Pet const* pet); static void Push(lua_State* luastate, TempSummon const* summon); + static void Push(lua_State* luastate, ObjectGuid const guid); template static void Push(lua_State* luastate, T const* ptr) { @@ -323,7 +325,7 @@ public: bool IsEnabled() const { return enabled && IsInitialized(); } bool HasLuaState() const { return L != NULL; } uint64 GetCallstackId() const { return callstackid; } - int Register(lua_State* L, uint8 reg, uint32 entry, uint64 guid, uint32 instanceId, uint32 event_id, int functionRef, uint32 shots); + int Register(lua_State* L, uint8 reg, uint32 entry, ObjectGuid guid, uint32 instanceId, uint32 event_id, int functionRef, uint32 shots); // Checks template static T CHECKVAL(lua_State* luastate, int narg); @@ -345,7 +347,7 @@ public: void OnTimedEvent(int funcRef, uint32 delay, uint32 calls, WorldObject* obj); bool OnCommand(Player* player, const char* text); void OnWorldUpdate(uint32 diff); - void OnLootItem(Player* pPlayer, Item* pItem, uint32 count, uint64 guid); + void OnLootItem(Player* pPlayer, Item* pItem, uint32 count, ObjectGuid guid); void OnLootMoney(Player* pPlayer, uint32 amount); void OnFirstLogin(Player* pPlayer); void OnEquip(Player* pPlayer, Item* pItem, uint8 bag, uint8 slot); @@ -449,7 +451,7 @@ public: bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Channel* pChannel); bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Player* pReceiver); void OnEmote(Player* pPlayer, uint32 emote); - void OnTextEmote(Player* pPlayer, uint32 textEmote, uint32 emoteNum, uint64 guid); + void OnTextEmote(Player* pPlayer, uint32 textEmote, uint32 emoteNum, ObjectGuid guid); void OnSpellCast(Player* pPlayer, Spell* pSpell, bool skipCheck); void OnLogin(Player* pPlayer); void OnLogout(Player* pPlayer); @@ -498,12 +500,12 @@ public: void OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); /* Group */ - void OnAddMember(Group* group, uint64 guid); - void OnInviteMember(Group* group, uint64 guid); - void OnRemoveMember(Group* group, uint64 guid, uint8 method); - void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid); + void OnAddMember(Group* group, ObjectGuid guid); + void OnInviteMember(Group* group, ObjectGuid guid); + void OnRemoveMember(Group* group, ObjectGuid guid, uint8 method); + void OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid); void OnDisband(Group* group); - void OnCreate(Group* group, uint64 leaderGuid, GroupType groupType); + void OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType); /* Map */ void OnCreate(Map* map); diff --git a/MapMethods.h b/MapMethods.h index d1513e6..65016ba 100644 --- a/MapMethods.h +++ b/MapMethods.h @@ -205,45 +205,41 @@ namespace LuaMap /** * Returns a [WorldObject] by its GUID from the map if it is spawned. * - * @param uint64 guid + * @param ObjectGuid guid */ int GetWorldObject(lua_State* L, Map* map) { - uint64 guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); #if defined TRINITY || AZEROTHCORE - switch (GUID_HIPART(guid)) + switch (guid.GetHigh()) { case HIGHGUID_PLAYER: -#ifndef AZEROTHCORE - Eluna::Push(L, eObjectAccessor()GetPlayer(map, ObjectGuid(guid))); -#else - Eluna::Push(L, map->GetPlayer(ObjectGuid(guid))); -#endif // !AZEROTHCORE + Eluna::Push(L, eObjectAccessor()GetPlayer(map, guid)); break; case HIGHGUID_TRANSPORT: case HIGHGUID_MO_TRANSPORT: case HIGHGUID_GAMEOBJECT: - Eluna::Push(L, map->GetGameObject(ObjectGuid(guid))); + Eluna::Push(L, map->GetGameObject(guid)); break; case HIGHGUID_VEHICLE: case HIGHGUID_UNIT: - Eluna::Push(L, map->GetCreature(ObjectGuid(guid))); + Eluna::Push(L, map->GetCreature(guid)); break; case HIGHGUID_PET: - Eluna::Push(L, map->GetPet(ObjectGuid(guid))); + Eluna::Push(L, map->GetPet(guid)); break; case HIGHGUID_DYNAMICOBJECT: - Eluna::Push(L, map->GetDynamicObject(ObjectGuid(guid))); + Eluna::Push(L, map->GetDynamicObject(guid)); break; case HIGHGUID_CORPSE: - Eluna::Push(L, map->GetCorpse(ObjectGuid(guid))); + Eluna::Push(L, map->GetCorpse(guid)); break; default: break; } #else - Eluna::Push(L, map->GetWorldObject(ObjectGuid(guid))); + Eluna::Push(L, map->GetWorldObject(guid)); #endif return 1; } diff --git a/ObjectMethods.h b/ObjectMethods.h index 409e200..156d63f 100644 --- a/ObjectMethods.h +++ b/ObjectMethods.h @@ -163,8 +163,8 @@ namespace LuaObject * the same GUID but not on the same map. * * On TrinityCore this value is unique across all maps - * - * @return uint64 guid + * + * @return ObjectGuid guid */ int GetGUID(lua_State* L, Object* obj) { @@ -186,7 +186,7 @@ namespace LuaObject */ int GetGUIDLow(lua_State* L, Object* obj) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, obj->GetGUID().GetCounter()); #else Eluna::Push(L, obj->GetGUIDLow()); diff --git a/PlayerHooks.cpp b/PlayerHooks.cpp index 9b52af0..0ef56f6 100644 --- a/PlayerHooks.cpp +++ b/PlayerHooks.cpp @@ -59,7 +59,7 @@ bool Eluna::OnCommand(Player* player, const char* text) return CallAllFunctionsBool(PlayerEventBindings, key, true); } -void Eluna::OnLootItem(Player* pPlayer, Item* pItem, uint32 count, uint64 guid) +void Eluna::OnLootItem(Player* pPlayer, Item* pItem, uint32 count, ObjectGuid guid) { START_HOOK(PLAYER_EVENT_ON_LOOT_ITEM); Push(pPlayer); @@ -311,7 +311,7 @@ void Eluna::OnEmote(Player* pPlayer, uint32 emote) CallAllFunctions(PlayerEventBindings, key); } -void Eluna::OnTextEmote(Player* pPlayer, uint32 textEmote, uint32 emoteNum, uint64 guid) +void Eluna::OnTextEmote(Player* pPlayer, uint32 textEmote, uint32 emoteNum, ObjectGuid guid) { START_HOOK(PLAYER_EVENT_ON_TEXT_EMOTE); Push(pPlayer); diff --git a/PlayerMethods.h b/PlayerMethods.h index 9ecaf80..8ff39b1 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -1370,14 +1370,14 @@ namespace LuaPlayer * * The item can be equipped, in bags or in bank. * - * @param uint64 guid : an item guid + * @param ObjectGuid guid : an item guid * @return [Item] item */ int GetItemByGUID(lua_State* L, Player* player) { - uint64 guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, player->GetItemByGuid(ObjectGuid(guid))); + Eluna::Push(L, player->GetItemByGuid(guid)); return 1; } @@ -2135,18 +2135,18 @@ namespace LuaPlayer /** * Shows the mailbox window to the player from specified guid. * - * @param uint64 guid = playerguid : guid of the mailbox window sender + * @param ObjectGuid guid = playerguid : guid of the mailbox window sender */ int SendShowMailBox(lua_State* L, Player* player) { - uint64 guid = Eluna::CHECKVAL(L, 2, player->GET_GUID()); + ObjectGuid guid = Eluna::CHECKVAL(L, 2, player->GET_GUID()); #if (defined(CLASSIC) || defined(TBC)) WorldPacket data(CMSG_GET_MAIL_LIST, 8); - data << uint64(guid); + data << guid; player->GetSession()->HandleGetMailList(data); #else - player->GetSession()->SendShowMailBox(ObjectGuid(guid)); + player->GetSession()->SendShowMailBox(guid); #endif return 0; } @@ -2209,7 +2209,7 @@ namespace LuaPlayer player->SetSummonPoint(summoner->GetMapId(), x, y, z); WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); - data << uint64(summoner->GetGUIDLow()); + data << summoner->GET_GUID(); data << uint32(summoner->GetZoneId()); data << uint32(MAX_PLAYER_SUMMON_DELAY * IN_MILLISECONDS); #ifdef CMANGOS @@ -2278,11 +2278,10 @@ namespace LuaPlayer return 0; WorldPacket data(MSG_AUCTION_HELLO, 12); + data << unit->GET_GUID(); #ifdef TRINITY - data << uint64(unit->GetGUID().GetCounter()); data << uint32(ahEntry->ID); #else - data << uint64(unit->GetGUIDLow()); data << uint32(ahEntry->houseId); #endif data << uint8(1); @@ -2434,7 +2433,7 @@ namespace LuaPlayer #ifndef AZEROTHCORE player->UnbindInstance(map, (Difficulty)difficulty); #else - sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUIDLow(), map, Difficulty(difficulty), true, player); + sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), map, Difficulty(difficulty), true, player); #endif//AZEROTHCORE #else//CLASSIC player->UnbindInstance(map); @@ -2459,12 +2458,12 @@ namespace LuaPlayer #elif defined AZEROTHCORE for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { - const BoundInstancesMap& binds = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUIDLow(), Difficulty(i)); + const BoundInstancesMap& binds = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUID(), Difficulty(i)); for (BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end();) { if (itr->first != player->GetMapId()) { - sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUIDLow(), itr->first, Difficulty(i), true, player); + sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), itr->first, Difficulty(i), true, player); itr = binds.begin(); } else @@ -2870,11 +2869,7 @@ namespace LuaPlayer { if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature)) for (uint16 z = 0; z < creatureCount; ++z) -#ifndef AZEROTHCORE player->KilledMonster(creatureInfo, ObjectGuid::Empty); -#else - player->KilledMonster(creatureInfo, 0); -#endif } else if (creature < 0) for (uint16 z = 0; z < creatureCount; ++z) @@ -3061,7 +3056,7 @@ namespace LuaPlayer * @param string text * @param uint32 lang : language the [Player] will speak * @param [Player] receiver : is the [Player] that will receive the whisper, if TrinityCore - * @param uint64 guid : is the GUID of a [Player] that will receive the whisper, not TrinityCore + * @param ObjectGuid guid : is the GUID of a [Player] that will receive the whisper, not TrinityCore */ int Whisper(lua_State* L, Player* player) { @@ -3070,12 +3065,12 @@ namespace LuaPlayer #ifdef TRINITY Player* receiver = Eluna::CHECKOBJ(L, 4); #else - uint64 guid = Eluna::CHECKVAL(L, 4); + ObjectGuid guid = Eluna::CHECKVAL(L, 4); #endif #ifdef TRINITY player->Whisper(text, (Language)lang, receiver); #else - player->Whisper(text, lang, ObjectGuid(guid)); + player->Whisper(text, lang, guid); #endif return 0; } @@ -3637,10 +3632,10 @@ namespace LuaPlayer WorldPacket data(SMSG_MESSAGECHAT, 100); data << uint8(channel); data << int32(LANG_ADDON); - data << uint64(player->GET_GUID()); + data << player->GET_GUID(); #ifndef CLASSIC data << uint32(0); - data << uint64(receiver->GET_GUID()); + data << receiver->GET_GUID(); #endif data << uint32(fullmsg.length() + 1); data << fullmsg; @@ -4114,7 +4109,7 @@ namespace LuaPlayer /*int KillGOCredit(lua_State* L, Player* player) { uint32 entry = Eluna::CHECKVAL(L, 2); - uint64 guid = Eluna::CHECKVAL(L, 3); + ObjectGuid guid = Eluna::CHECKVAL(L, 3); player->KillCreditGO(entry, guid); return 0; }*/ diff --git a/ServerHooks.cpp b/ServerHooks.cpp index a11ce6a..de36faf 100644 --- a/ServerHooks.cpp +++ b/ServerHooks.cpp @@ -140,19 +140,23 @@ void Eluna::OnChange(Weather* /*weather*/, uint32 zone, WeatherState state, floa // Auction House void Eluna::OnAdd(AuctionHouseObject* /*ah*/, AuctionEntry* entry) { +#ifdef AZEROTHCORE + Player* owner = eObjectAccessor()FindPlayer(entry->owner); +#else Player* owner = eObjectAccessor()FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER)); +#endif + #ifdef TRINITY Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); uint32 expiretime = entry->expire_time; #elif AZEROTHCORE - Item* item = eAuctionMgr->GetAItem(entry->item_guidlow); + Item* item = eAuctionMgr->GetAItem(entry->item_guid); uint32 expiretime = entry->expire_time; #else Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow); uint32 expiretime = entry->expireTime; #endif - if (!owner || !item) return; @@ -170,12 +174,17 @@ void Eluna::OnAdd(AuctionHouseObject* /*ah*/, AuctionEntry* entry) void Eluna::OnRemove(AuctionHouseObject* /*ah*/, AuctionEntry* entry) { +#ifdef AZEROTHCORE + Player* owner = eObjectAccessor()FindPlayer(entry->owner); +#else Player* owner = eObjectAccessor()FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER)); +#endif + #ifdef TRINITY Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); uint32 expiretime = entry->expire_time; #elif AZEROTHCORE - Item* item = eAuctionMgr->GetAItem(entry->item_guidlow); + Item* item = eAuctionMgr->GetAItem(entry->item_guid); uint32 expiretime = entry->expire_time; #else Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow); @@ -200,12 +209,17 @@ void Eluna::OnRemove(AuctionHouseObject* /*ah*/, AuctionEntry* entry) void Eluna::OnSuccessful(AuctionHouseObject* /*ah*/, AuctionEntry* entry) { +#ifdef AZEROTHCORE + Player* owner = eObjectAccessor()FindPlayer(entry->owner); +#else Player* owner = eObjectAccessor()FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER)); +#endif + #ifdef TRINITY Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); uint32 expiretime = entry->expire_time; #elif AZEROTHCORE - Item* item = eAuctionMgr->GetAItem(entry->item_guidlow); + Item* item = eAuctionMgr->GetAItem(entry->item_guid); uint32 expiretime = entry->expire_time; #else Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow); @@ -230,12 +244,17 @@ void Eluna::OnSuccessful(AuctionHouseObject* /*ah*/, AuctionEntry* entry) void Eluna::OnExpire(AuctionHouseObject* /*ah*/, AuctionEntry* entry) { +#ifdef AZEROTHCORE + Player* owner = eObjectAccessor()FindPlayer(entry->owner); +#else Player* owner = eObjectAccessor()FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER)); +#endif + #ifdef TRINITY Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); uint32 expiretime = entry->expire_time; #elif AZEROTHCORE - Item* item = eAuctionMgr->GetAItem(entry->item_guidlow); + Item* item = eAuctionMgr->GetAItem(entry->item_guid); uint32 expiretime = entry->expire_time; #else Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow); diff --git a/UnitMethods.h b/UnitMethods.h index 392c1b6..9b2bf23 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -602,7 +602,7 @@ namespace LuaUnit /** * Returns the [Unit]'s owner's GUID. * - * @return uint64 ownerGUID + * @return ObjectGuid ownerGUID */ int GetOwnerGUID(lua_State* L, Unit* unit) { @@ -628,7 +628,7 @@ namespace LuaUnit /** * Returns the [Unit]'s creator's GUID. * - * @return uint64 creatorGUID + * @return ObjectGuid creatorGUID */ int GetCreatorGUID(lua_State* L, Unit* unit) { @@ -643,7 +643,7 @@ namespace LuaUnit /** * Returns the [Unit]'s charmer's GUID. * - * @return uint64 charmerGUID + * @return ObjectGuid charmerGUID */ int GetCharmerGUID(lua_State* L, Unit* unit) { @@ -658,7 +658,7 @@ namespace LuaUnit /** * Returns the GUID of the [Unit]'s charmed entity. * - * @return uint64 charmedGUID + * @return ObjectGuid charmedGUID */ int GetCharmGUID(lua_State* L, Unit* unit) { @@ -675,7 +675,7 @@ namespace LuaUnit /** * Returns the GUID of the [Unit]'s pet. * - * @return uint64 petGUID + * @return ObjectGuid petGUID */ int GetPetGUID(lua_State* L, Unit* unit) { @@ -690,7 +690,7 @@ namespace LuaUnit /** * Returns the GUID of the [Unit]'s charmer or owner. * - * @return uint64 controllerGUID + * @return ObjectGuid controllerGUID */ int GetControllerGUID(lua_State* L, Unit* unit) { @@ -705,7 +705,7 @@ namespace LuaUnit /** * Returns the GUID of the [Unit]'s charmer or owner or its own GUID. * - * @return uint64 controllerGUID + * @return ObjectGuid controllerGUID */ int GetControllerGUIDS(lua_State* L, Unit* unit) { @@ -1355,7 +1355,7 @@ namespace LuaUnit /** * Returns the Critter Guid * - * @return uint64 critterGuid + * @return ObjectGuid critterGuid */ int GetCritterGUID(lua_State* L, Unit* unit) { @@ -1444,16 +1444,16 @@ namespace LuaUnit /** * Sets the [Unit]'s owner GUID to given GUID. * - * @param uint64 guid : new owner guid + * @param ObjectGuid guid : new owner guid */ int SetOwnerGUID(lua_State* L, Unit* unit) { - uint64 guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); #if defined TRINITY || AZEROTHCORE - unit->SetOwnerGUID(ObjectGuid(guid)); + unit->SetOwnerGUID(guid); #else - unit->SetOwnerGuid(ObjectGuid(guid)); + unit->SetOwnerGuid(guid); #endif return 0; } @@ -1785,15 +1785,15 @@ namespace LuaUnit /** * Sets creator GUID * - * @param uint64 guid + * @param ObjectGuid guid */ int SetCreatorGUID(lua_State* L, Unit* unit) { - uint64 guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); #if defined TRINITY || AZEROTHCORE - unit->SetCreatorGUID(ObjectGuid(guid)); + unit->SetCreatorGUID(guid); #else - unit->SetCreatorGuid(ObjectGuid(guid)); + unit->SetCreatorGuid(guid); #endif return 0; } @@ -1801,15 +1801,15 @@ namespace LuaUnit /** * Sets pet GUID * - * @param uint64 guid + * @param ObjectGuid guid */ int SetPetGUID(lua_State* L, Unit* unit) { - uint64 guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); #if defined TRINITY || AZEROTHCORE - unit->SetPetGUID(ObjectGuid(guid)); + unit->SetPetGUID(guid); #else - unit->SetPetGuid(ObjectGuid(guid)); + unit->SetPetGuid(guid); #endif return 0; } @@ -1907,11 +1907,11 @@ namespace LuaUnit int SetCritterGUID(lua_State* L, Unit* unit) { - uint64 guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); #if defined TRINITY || AZEROTHCORE - unit->SetCritterGUID(ObjectGuid(guid)); + unit->SetCritterGUID(guid); #else - unit->SetCritterGuid(ObjectGuid(guid)); + unit->SetCritterGuid(guid); #endif return 0; } @@ -2444,7 +2444,7 @@ namespace LuaUnit * @param int32 bp1 = nil : custom basepoints for [Spell] effect 2. If nil, no change is made * @param int32 bp2 = nil : custom basepoints for [Spell] effect 3. If nil, no change is made * @param [Item] castItem = nil - * @param uint64 originalCaster = 0 + * @param ObjectGuid originalCaster = ObjectGuid() */ int CastCustomSpell(lua_State* L, Unit* unit) { @@ -2458,7 +2458,7 @@ namespace LuaUnit bool has_bp2 = !lua_isnoneornil(L, 7); int32 bp2 = Eluna::CHECKVAL(L, 7, 0); Item* castItem = Eluna::CHECKOBJ(L, 8, false); - uint64 originalCaster = Eluna::CHECKVAL(L, 9, 0); + ObjectGuid originalCaster = Eluna::CHECKVAL(L, 9, ObjectGuid()); #ifdef TRINITY CastSpellExtraArgs args; @@ -2473,7 +2473,7 @@ namespace LuaUnit if (castItem) args.SetCastItem(castItem); if (originalCaster) - args.SetOriginalCaster(ObjectGuid(originalCaster)); + args.SetOriginalCaster(originalCaster); unit->CastSpell(target, spell, args); #else unit->CastCustomSpell(target, spell, has_bp0 ? &bp0 : NULL, has_bp1 ? &bp1 : NULL, has_bp2 ? &bp2 : NULL, triggered, castItem, NULL, ObjectGuid(originalCaster)); diff --git a/WorldPacketMethods.h b/WorldPacketMethods.h index afabcdd..750c096 100644 --- a/WorldPacketMethods.h +++ b/WorldPacketMethods.h @@ -163,11 +163,11 @@ namespace LuaPacket /** * Reads and returns an unsigned 64-bit integer value from the [WorldPacket]. * - * @return uint64 value : value returned as string + * @return ObjectGuid value : value returned as string */ int ReadGUID(lua_State* L, WorldPacket* packet) { - uint64 guid; + ObjectGuid guid; (*packet) >> guid; Eluna::Push(L, guid); return 1; @@ -189,11 +189,11 @@ namespace LuaPacket /** * Writes an unsigned 64-bit integer value to the [WorldPacket]. * - * @param uint64 value : the value to be written to the [WorldPacket] + * @param ObjectGuid value : the value to be written to the [WorldPacket] */ int WriteGUID(lua_State* L, WorldPacket* packet) { - uint64 guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(L, 2); (*packet) << guid; return 0; }