diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index c77e03f..ce757d6 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -113,6 +113,7 @@ luaL_Reg GlobalMethods[] = { "GetGUIDLow", &LuaGlobalFunctions::GetGUIDLow }, { "GetGUIDType", &LuaGlobalFunctions::GetGUIDType }, { "GetGUIDEntry", &LuaGlobalFunctions::GetGUIDEntry }, + { "GetPackedGUIDSize", &LuaGlobalFunctions::GetPackedGUIDSize }, { "GetAreaName", &LuaGlobalFunctions::GetAreaName }, { "GetOwnerHalaa", &LuaGlobalFunctions::GetOwnerHalaa }, { "bit_not", &LuaGlobalFunctions::bit_not }, @@ -1204,6 +1205,7 @@ ElunaRegister PacketMethods[] = { "WriteLong", &LuaPacket::WriteLong }, { "WriteULong", &LuaPacket::WriteULong }, { "WriteGUID", &LuaPacket::WriteGUID }, + { "WritePackedGUID", &LuaPacket::WritePackedGUID }, { "WriteString", &LuaPacket::WriteString }, { "WriteFloat", &LuaPacket::WriteFloat }, { "WriteDouble", &LuaPacket::WriteDouble }, diff --git a/src/LuaEngine/methods/GlobalMethods.h b/src/LuaEngine/methods/GlobalMethods.h index e5c8061..eb3d3e0 100644 --- a/src/LuaEngine/methods/GlobalMethods.h +++ b/src/LuaEngine/methods/GlobalMethods.h @@ -468,6 +468,20 @@ namespace LuaGlobalFunctions return 1; } + /** + * Returns the byte size in bytes (2-9) of the ObjectGuid when packed. + * + * @param ObjectGuid guid : the ObjectGuid to get packed size for + * @return number size + */ + int GetPackedGUIDSize(lua_State* L) + { + ObjectGuid guid = Eluna::CHECKVAL(L, 1); + PackedGuid packedGuid(guid); + Eluna::Push(L, static_cast(packedGuid.size())); + return 1; + } + /** * Returns the area or zone's name. * diff --git a/src/LuaEngine/methods/WorldPacketMethods.h b/src/LuaEngine/methods/WorldPacketMethods.h index 6414fdf..ecc7b9b 100644 --- a/src/LuaEngine/methods/WorldPacketMethods.h +++ b/src/LuaEngine/methods/WorldPacketMethods.h @@ -212,6 +212,19 @@ namespace LuaPacket return 0; } + /** + * Writes an ObjectGuid as packed GUID format to the [WorldPacket]. + * + * @param ObjectGuid value : the ObjectGuid to be packed to the [WorldPacket] + */ + int WritePackedGUID(lua_State* L, WorldPacket* packet) + { + ObjectGuid guid = Eluna::CHECKVAL(L, 2); + PackedGuid packedGuid(guid); + (*packet) << packedGuid; + return 0; + } + /** * Writes a string to the [WorldPacket]. *