mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
feat(LuaEngine/Packed GUIDs) Add support for writing packed GUIDs and reading packed GUID size (#295)
This commit is contained in:
@@ -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<WorldPacket> PacketMethods[] =
|
||||
{ "WriteLong", &LuaPacket::WriteLong },
|
||||
{ "WriteULong", &LuaPacket::WriteULong },
|
||||
{ "WriteGUID", &LuaPacket::WriteGUID },
|
||||
{ "WritePackedGUID", &LuaPacket::WritePackedGUID },
|
||||
{ "WriteString", &LuaPacket::WriteString },
|
||||
{ "WriteFloat", &LuaPacket::WriteFloat },
|
||||
{ "WriteDouble", &LuaPacket::WriteDouble },
|
||||
|
||||
@@ -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<ObjectGuid>(L, 1);
|
||||
PackedGuid packedGuid(guid);
|
||||
Eluna::Push(L, static_cast<int>(packedGuid.size()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the area or zone's name.
|
||||
*
|
||||
|
||||
@@ -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<ObjectGuid>(L, 2);
|
||||
PackedGuid packedGuid(guid);
|
||||
(*packet) << packedGuid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string to the [WorldPacket].
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user