diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 91f094b81..c687921ec 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -516,7 +516,9 @@ static int player_get(lua_State *L) } lua_getfield(L, -1, field); if (lua_isnil(L, -1)) // no value for this field + { CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "player_t", field); + } return 1; } diff --git a/src/lua_udatalib.c b/src/lua_udatalib.c index 239e56e13..d7cd68278 100644 --- a/src/lua_udatalib.c +++ b/src/lua_udatalib.c @@ -87,7 +87,7 @@ int udatalib_setter_boolean_nocheck(lua_State *L) UDATALIB_SIMPLE_SETTER(boolean, lua_toboolean) int udatalib_setter_spritenum(lua_State *L) -UDATALIB_SIMPLE_SETTER(spritenum_t, (spritenum_t)luaL_checkinteger) +UDATALIB_SIMPLE_SETTER(spritenum_t, luaL_checkinteger) int udatalib_setter_tic(lua_State *L) UDATALIB_SIMPLE_SETTER(tic_t, (tic_t)luaL_checkinteger) diff --git a/src/lua_udatalib.h b/src/lua_udatalib.h index 30fb0d3a9..36d1ef5ff 100644 --- a/src/lua_udatalib.h +++ b/src/lua_udatalib.h @@ -1,8 +1,6 @@ #ifndef __LUA_UDATALIB_H__ #define __LUA_UDATALIB_H__ -#include - #ifdef HAVE_BLUA #include "doomdef.h" @@ -16,7 +14,7 @@ typedef struct udata_field_s { const char *name; - intptr_t offset; + size_t offset; lua_CFunction getter; lua_CFunction setter; } udata_field_t; @@ -82,8 +80,8 @@ void udatalib_addfields(lua_State *L, int mt, const udata_field_t fields[]); // Get pointer to field value within getter or setter #define UDATALIB_GETFIELD(type, field) \ { \ - intptr_t offset = lua_tointeger(L, lua_upvalueindex(1)); \ - field = (type*)((intptr_t)lua_touserdata(L, 1) + offset); \ + size_t offset = lua_tointeger(L, lua_upvalueindex(1)); \ + field = (type*)((uint8_t*)lua_touserdata(L, 1) + offset); \ } // Creates implementation for simple getter and setter. Super lazy, yes.