mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-27 03:31:08 +00:00
Add lighttable_t support
This commit is contained in:
parent
4ea2887d7f
commit
b670f97ed1
5 changed files with 38 additions and 4 deletions
|
@ -214,6 +214,7 @@ static const struct {
|
||||||
{META_PATCH, "patch_t"},
|
{META_PATCH, "patch_t"},
|
||||||
{META_COLORMAP, "colormap"},
|
{META_COLORMAP, "colormap"},
|
||||||
{META_EXTRACOLORMAP,"extracolormap_t"},
|
{META_EXTRACOLORMAP,"extracolormap_t"},
|
||||||
|
{META_LIGHTTABLE, "lighttable_t"},
|
||||||
{META_CAMERA, "camera_t"},
|
{META_CAMERA, "camera_t"},
|
||||||
|
|
||||||
{META_ACTION, "action"},
|
{META_ACTION, "action"},
|
||||||
|
|
|
@ -209,7 +209,7 @@ static int extracolormap_get(lua_State *L)
|
||||||
lua_pushinteger(L, exc->fadeend);
|
lua_pushinteger(L, exc->fadeend);
|
||||||
break;
|
break;
|
||||||
case extracolormap_colormap:
|
case extracolormap_colormap:
|
||||||
LUA_PushUserdata(L, exc->colormap, META_COLORMAP);
|
LUA_PushUserdata(L, exc->colormap, META_LIGHTTABLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -321,6 +321,29 @@ static int extracolormap_set(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lighttable_get(lua_State *L)
|
||||||
|
{
|
||||||
|
void **userdata;
|
||||||
|
|
||||||
|
lighttable_t *table = *((lighttable_t **)luaL_checkudata(L, 1, META_LIGHTTABLE));
|
||||||
|
UINT32 row = luaL_checkinteger(L, 2);
|
||||||
|
if (row < 1 || row > 34)
|
||||||
|
return luaL_error(L, "lighttable row %d out of range (1 - %d)", row, 34);
|
||||||
|
|
||||||
|
userdata = lua_newuserdata(L, sizeof(void *));
|
||||||
|
*userdata = &table[256 * (row - 1)];
|
||||||
|
luaL_getmetatable(L, META_COLORMAP);
|
||||||
|
lua_setmetatable(L, -2);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lighttable_len(lua_State *L)
|
||||||
|
{
|
||||||
|
lua_pushinteger(L, NUM_PALETTE_ENTRIES);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int LUA_ColorLib(lua_State *L)
|
int LUA_ColorLib(lua_State *L)
|
||||||
{
|
{
|
||||||
luaL_newmetatable(L, META_EXTRACOLORMAP);
|
luaL_newmetatable(L, META_EXTRACOLORMAP);
|
||||||
|
@ -331,5 +354,13 @@ int LUA_ColorLib(lua_State *L)
|
||||||
lua_setfield(L, -2, "__newindex");
|
lua_setfield(L, -2, "__newindex");
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
luaL_newmetatable(L, META_LIGHTTABLE);
|
||||||
|
lua_pushcfunction(L, lighttable_get);
|
||||||
|
lua_setfield(L, -2, "__index");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, lighttable_len);
|
||||||
|
lua_setfield(L, -2, "__len");
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,8 @@ extern boolean mousegrabbedbylua;
|
||||||
#define META_HUDINFO "HUDINFO_T*"
|
#define META_HUDINFO "HUDINFO_T*"
|
||||||
#define META_PATCH "PATCH_T*"
|
#define META_PATCH "PATCH_T*"
|
||||||
#define META_COLORMAP "COLORMAP"
|
#define META_COLORMAP "COLORMAP"
|
||||||
#define META_EXTRACOLORMAP "EXTRACOLORMAP_T"
|
#define META_EXTRACOLORMAP "EXTRACOLORMAP_T*"
|
||||||
|
#define META_LIGHTTABLE "LIGHTTABLE_T*"
|
||||||
#define META_CAMERA "CAMERA_T*"
|
#define META_CAMERA "CAMERA_T*"
|
||||||
|
|
||||||
#define META_ACTION "ACTIONF_T*"
|
#define META_ACTION "ACTIONF_T*"
|
||||||
|
|
|
@ -53,6 +53,9 @@ typedef struct
|
||||||
// Could even use more than 32 levels.
|
// Could even use more than 32 levels.
|
||||||
typedef UINT8 lighttable_t;
|
typedef UINT8 lighttable_t;
|
||||||
|
|
||||||
|
#define NUM_PALETTE_ENTRIES 256
|
||||||
|
#define DEFAULT_STARTTRANSCOLOR 96
|
||||||
|
|
||||||
#define CMF_FADEFULLBRIGHTSPRITES 1
|
#define CMF_FADEFULLBRIGHTSPRITES 1
|
||||||
#define CMF_FOG 4
|
#define CMF_FOG 4
|
||||||
|
|
||||||
|
|
|
@ -132,8 +132,6 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask;
|
||||||
#define RAINBOW_TT_CACHE_INDEX (MAXSKINS + 4)
|
#define RAINBOW_TT_CACHE_INDEX (MAXSKINS + 4)
|
||||||
#define BLINK_TT_CACHE_INDEX (MAXSKINS + 5)
|
#define BLINK_TT_CACHE_INDEX (MAXSKINS + 5)
|
||||||
#define DASHMODE_TT_CACHE_INDEX (MAXSKINS + 6)
|
#define DASHMODE_TT_CACHE_INDEX (MAXSKINS + 6)
|
||||||
#define DEFAULT_STARTTRANSCOLOR 96
|
|
||||||
#define NUM_PALETTE_ENTRIES 256
|
|
||||||
|
|
||||||
static UINT8 **translationtablecache[MAXSKINS + 7] = {NULL};
|
static UINT8 **translationtablecache[MAXSKINS + 7] = {NULL};
|
||||||
UINT8 skincolor_modified[MAXSKINCOLORS];
|
UINT8 skincolor_modified[MAXSKINCOLORS];
|
||||||
|
|
Loading…
Reference in a new issue