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 },
|
{ "GetGUIDLow", &LuaGlobalFunctions::GetGUIDLow },
|
||||||
{ "GetGUIDType", &LuaGlobalFunctions::GetGUIDType },
|
{ "GetGUIDType", &LuaGlobalFunctions::GetGUIDType },
|
||||||
{ "GetGUIDEntry", &LuaGlobalFunctions::GetGUIDEntry },
|
{ "GetGUIDEntry", &LuaGlobalFunctions::GetGUIDEntry },
|
||||||
|
{ "GetPackedGUIDSize", &LuaGlobalFunctions::GetPackedGUIDSize },
|
||||||
{ "GetAreaName", &LuaGlobalFunctions::GetAreaName },
|
{ "GetAreaName", &LuaGlobalFunctions::GetAreaName },
|
||||||
{ "GetOwnerHalaa", &LuaGlobalFunctions::GetOwnerHalaa },
|
{ "GetOwnerHalaa", &LuaGlobalFunctions::GetOwnerHalaa },
|
||||||
{ "bit_not", &LuaGlobalFunctions::bit_not },
|
{ "bit_not", &LuaGlobalFunctions::bit_not },
|
||||||
@@ -1204,6 +1205,7 @@ ElunaRegister<WorldPacket> PacketMethods[] =
|
|||||||
{ "WriteLong", &LuaPacket::WriteLong },
|
{ "WriteLong", &LuaPacket::WriteLong },
|
||||||
{ "WriteULong", &LuaPacket::WriteULong },
|
{ "WriteULong", &LuaPacket::WriteULong },
|
||||||
{ "WriteGUID", &LuaPacket::WriteGUID },
|
{ "WriteGUID", &LuaPacket::WriteGUID },
|
||||||
|
{ "WritePackedGUID", &LuaPacket::WritePackedGUID },
|
||||||
{ "WriteString", &LuaPacket::WriteString },
|
{ "WriteString", &LuaPacket::WriteString },
|
||||||
{ "WriteFloat", &LuaPacket::WriteFloat },
|
{ "WriteFloat", &LuaPacket::WriteFloat },
|
||||||
{ "WriteDouble", &LuaPacket::WriteDouble },
|
{ "WriteDouble", &LuaPacket::WriteDouble },
|
||||||
|
|||||||
@@ -468,6 +468,20 @@ namespace LuaGlobalFunctions
|
|||||||
return 1;
|
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.
|
* Returns the area or zone's name.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -212,6 +212,19 @@ namespace LuaPacket
|
|||||||
return 0;
|
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].
|
* Writes a string to the [WorldPacket].
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user