From 1977bbaf744925ca046567b80c9ba814201ce147 Mon Sep 17 00:00:00 2001 From: Bkacjios Date: Mon, 6 Jan 2025 15:29:52 -0500 Subject: [PATCH] Fixed Lua 5.3 builds --- mumble/defines.h | 13 +++++++++++++ mumble/mumble.c | 9 ++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mumble/defines.h b/mumble/defines.h index 1b9cdf5..1d313d7 100644 --- a/mumble/defines.h +++ b/mumble/defines.h @@ -84,6 +84,19 @@ #define lua_objlen lua_rawlen #endif +#if LUA_VERSION_NUM >= 502 +#define luaL_register(L, libname, l) \ + ((libname) == NULL ? luaL_setfuncs(L, (l), 0) : \ + (lua_newtable(L), luaL_setfuncs(L, (l), 0), lua_pushvalue(L, -1), lua_setglobal(L, (libname)))) +#endif + +#if LUA_VERSION_NUM >= 503 +#define luaL_optlong(L, n, d) ((long)luaL_opt(L, luaL_checkinteger, (n), (lua_Integer)(d))) +#define luaL_checkint(L, n) ((int)luaL_checkinteger(L, (n))) +#define lua_objlen(L, idx) lua_rawlen(L, (idx)) +#define lua_dump(L, writer, data) lua_dump(L, writer, data, 1) +#endif + #define lua_stackguard_entry(L) int __lua_stackguard_entry = lua_gettop(L); #define lua_stackguard_exit(L) assert(__lua_stackguard_entry == lua_gettop(L)); diff --git a/mumble/mumble.c b/mumble/mumble.c index 2fb4eb5..c574ad6 100755 --- a/mumble/mumble.c +++ b/mumble/mumble.c @@ -1415,7 +1415,11 @@ int luaopen_mumble(lua_State *l) { lua_newtable(l); MUMBLE_DATA_REG = mumble_ref(l); - luaL_register(l, "mumble", mumble); +#if LUA_VERSION_NUM >= 502 + luaL_newlib(l, mumble); +#else + luaL_register(l, "mumble", mumble); +#endif { // Create a table of all RejectType enums lua_newtable(l); @@ -1710,9 +1714,8 @@ int luaopen_mumble(lua_State *l) { lua_rawgeti(l, LUA_REGISTRYINDEX, MUMBLE_REGISTRY); lua_setfield(l, -2, "registry"); } - lua_pop(l, 1); - return 0; + return 1; } static void mumble_close() {