Merge pull request #1926 from EngineerSmith/enet-data

Added variants for peer:send and host:broadcast which accepts light userdata and size
This commit is contained in:
Sasha Szpakowski
2023-05-09 14:26:58 -03:00
committed by GitHub
2 changed files with 12 additions and 2 deletions
+1
View File
@@ -79,6 +79,7 @@ Released: N/A
* Added love.sensor module.
* Added love.sensorupdated callback.
* Added love.joysticksensorupdated callback.
* Added variant for enet peer:send and host:broadcast which accepts a pointer (light userdata) and a size.
* Changed love.filesystem.exists to no longer be deprecated.
* Changed the default font from Vera size 12 to Noto Sans size 13.
+11 -2
View File
@@ -234,12 +234,21 @@ static void push_event(lua_State *l, ENetEvent *event) {
/**
* Read a packet off the stack as a string
* idx is position of string
* idx is position of string or lightuserdata
*/
static ENetPacket *read_packet(lua_State *l, int idx, enet_uint8 *channel_id) {
size_t size;
int argc = lua_gettop(l);
const void *data = luaL_checklstring(l, idx, &size);
const void* data;
if (lua_islightuserdata(l, idx)) {
data = lua_touserdata(l, idx);
size = (size_t) luaL_checknumber(l, idx + 1);
idx++;
}
else {
data = luaL_checklstring(l, idx, &size);
}
ENetPacket *packet;
enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE;