Revert "Lua spriteinfo brightmap support"

This reverts commit f7def8d787.
This commit is contained in:
NepDisk 2024-09-02 04:48:50 -04:00
parent 38a52b0052
commit be09e70a99
2 changed files with 12 additions and 53 deletions

View file

@ -268,20 +268,6 @@ static UINT8 GetPivotFrame(lua_State *L, int idx)
return frame;
}
static int PushCast(lua_State *L, const char *meta)
{
// bypass LUA_PushUserdata
void **userdata = lua_newuserdata(L, sizeof(void *));
*userdata = lua_touserdata(L, 1);
luaL_getmetatable(L, meta);
lua_setmetatable(L, -2);
// stack is left with the userdata on top, as if getting it had originally succeeded.
return 1;
}
// spriteinfo[]
static int lib_getSpriteInfo(lua_State *L)
{
@ -470,15 +456,23 @@ static int lib_spriteinfolen(lua_State *L)
// spriteinfo_t
static int spriteinfo_get(lua_State *L)
{
spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEINFO));
const char *field = luaL_checkstring(L, 2);
luaL_checkudata(L, 1, META_SPRITEINFO);
I_Assert(sprinfo != NULL);
// push spriteframepivot_t userdata
if (fastcmp(field, "pivot"))
return PushCast(L, META_PIVOTLIST);
else if (fastcmp(field, "brightmap"))
return PushCast(L, META_SPRITEBRIGHTLIST);
{
// bypass LUA_PushUserdata
void **userdata = lua_newuserdata(L, sizeof(void *));
*userdata = sprinfo;
luaL_getmetatable(L, META_PIVOTLIST);
lua_setmetatable(L, -2);
// stack is left with the userdata on top, as if getting it had originally succeeded.
return 1;
}
else
return luaL_error(L, LUA_QL("spriteinfo_t") " has no field named " LUA_QS, field);
@ -648,29 +642,6 @@ static int framepivot_num(lua_State *L)
return 1;
}
static int brightlist_get(lua_State *L)
{
const spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEBRIGHTLIST));
const UINT8 frame = GetPivotFrame(L, 2);
lua_pushstring(L, sprinfo->bright[frame]);
return 1;
}
static int brightlist_set(lua_State *L)
{
spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEBRIGHTLIST));
const UINT8 frame = GetPivotFrame(L, 2);
const char *val = luaL_checkstring(L, 3);
Z_Free(sprinfo->bright[frame]);
sprinfo->bright[frame] = Z_StrDup(val);
return 0;
}
////////////////
// STATE INFO //
////////////////
@ -2125,17 +2096,6 @@ int LUA_InfoLib(lua_State *L)
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_SPRITEBRIGHTLIST);
lua_pushcfunction(L, brightlist_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, brightlist_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, pivotlist_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_PRECIPPROPS);
lua_pushcfunction(L, precipprops_get);
lua_setfield(L, -2, "__index");

View file

@ -28,7 +28,6 @@ extern lua_State *gL;
#define META_SPRITEINFO "SPRITEINFO_T*"
#define META_PIVOTLIST "SPRITEFRAMEPIVOT_T[]"
#define META_FRAMEPIVOT "SPRITEFRAMEPIVOT_T*"
#define META_SPRITEBRIGHTLIST "SPRITEBRIGHTMAP_T[]"
#define META_PRECIPPROPS "PRECIPPROPS_T*"
#define META_TAGLIST "TAGLIST"