Merge branch 'lua-input-improvements' into 'next'

A few Lua input improvements

See merge request STJr/SRB2!2185
This commit is contained in:
Krabs 2023-11-04 16:02:09 +00:00
commit 7b1939c346
25 changed files with 337 additions and 702 deletions

View file

@ -297,7 +297,8 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word)
CacheAndPushConstant(L, word, (lua_Integer)PF_FULLSTASIS);
return 1;
}
else if (fastcmp(p, "USEDOWN")) // Remove case when 2.3 nears release...
// TODO: 2.3: Delete this alias
else if (fastcmp(p, "USEDOWN"))
{
CacheAndPushConstant(L, word, (lua_Integer)PF_SPINDOWN);
return 1;
@ -583,7 +584,8 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word)
return 0;
}
if (fastcmp(word, "BT_USE")) // Remove case when 2.3 nears release...
// TODO: 2.3: Delete this alias
if (fastcmp(word, "BT_USE"))
{
CacheAndPushConstant(L, word, (lua_Integer)BT_SPIN);
return 1;
@ -771,8 +773,7 @@ int LUA_SOCLib(lua_State *L)
lua_register(L,"getActionName",lib_getActionName);
luaL_newmetatable(L, META_ACTION);
lua_pushcfunction(L, action_call);
lua_setfield(L, -2, "__call");
LUA_SetCFunctionField(L, "__call", action_call);
lua_pop(L, 1);
return 0;

View file

@ -911,6 +911,7 @@ static void readspriteframe(MYFILE *f, spriteinfo_t *sprinfo, UINT8 frame)
sprinfo->pivot[frame].x = value;
else if (fastcmp(word, "YPIVOT"))
sprinfo->pivot[frame].y = value;
// TODO: 2.3: Delete
else if (fastcmp(word, "ROTAXIS"))
deh_warning("SpriteInfo: ROTAXIS is deprecated and will be removed.");
else
@ -1617,6 +1618,7 @@ void readlevelheader(MYFILE *f, INT32 num)
sizeof(mapheaderinfo[num-1]->musname), va("Level header %d: music", num));
}
}
// TODO: 2.3: Delete
else if (fastcmp(word, "MUSICSLOT"))
deh_warning("Level header %d: MusicSlot parameter is deprecated and will be removed.\nUse \"Music\" instead.", num);
else if (fastcmp(word, "MUSICTRACK"))

View file

@ -51,6 +51,7 @@
#include "r_fps.h" // frame interpolation/uncapped
#include "lua_hud.h"
#include "lua_libs.h"
gameaction_t gameaction;
gamestate_t gamestate = GS_NULL;
@ -1170,7 +1171,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
// why build a ticcmd if we're paused?
// Or, for that matter, if we're being reborn.
// ...OR if we're blindfolded. No looking into the floor.
if (paused || P_AutoPause() || (gamestate == GS_LEVEL && (player->playerstate == PST_REBORN || ((gametyperules & GTR_TAG)
if (ignoregameinputs || paused || P_AutoPause() || (gamestate == GS_LEVEL && (player->playerstate == PST_REBORN || ((gametyperules & GTR_TAG)
&& (leveltime < hidetime * TICRATE) && (player->pflags & PF_TAGIT)))))
{//@TODO splitscreen player
cmd->angleturn = ticcmd_oldangleturn[forplayer];
@ -4346,7 +4347,7 @@ void G_LoadGameSettings(void)
}
#define GAMEDATA_ID 0x86E4A27C // Change every major version, as usual
#define COMPAT_GAMEDATA_ID 0xFCAFE211 // Can be removed entirely for 2.3
#define COMPAT_GAMEDATA_ID 0xFCAFE211 // TODO: 2.3: Delete
// G_LoadGameData
// Loads the main data file, which stores information such as emblems found, etc.

View file

@ -18,6 +18,8 @@
#include "hu_stuff.h" // need HUFONT start & end
#include "netcode/d_net.h"
#include "console.h"
#include "lua_script.h"
#include "lua_libs.h"
#define MAXMOUSESENSITIVITY 100 // sensitivity steps
@ -116,7 +118,10 @@ void G_MapEventsToControls(event_t *ev)
{
case ev_keydown:
if (ev->key < NUMINPUTS)
{
if (!ignoregameinputs)
gamekeydown[ev->key] = 1;
}
#ifdef PARANOIA
else
{
@ -144,7 +149,7 @@ void G_MapEventsToControls(event_t *ev)
case ev_joystick: // buttons are virtual keys
i = ev->key;
if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on)
if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on || ignoregameinputs)
break;
if (ev->x != INT32_MAX) joyxmove[i] = ev->x;
if (ev->y != INT32_MAX) joyymove[i] = ev->y;
@ -152,7 +157,7 @@ void G_MapEventsToControls(event_t *ev)
case ev_joystick2: // buttons are virtual keys
i = ev->key;
if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on)
if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on || ignoregameinputs)
break;
if (ev->x != INT32_MAX) joy2xmove[i] = ev->x;
if (ev->y != INT32_MAX) joy2ymove[i] = ev->y;
@ -997,7 +1002,7 @@ static void setcontrol(INT32 (*gc)[2])
INT32 player = ((void*)gc == (void*)&gamecontrolbis ? 1 : 0);
boolean nestedoverride = false;
// Update me for 2.3
// TODO: 2.3: Delete the "use" alias
namectrl = (stricmp(COM_Argv(1), "use")) ? COM_Argv(1) : "spin";
for (numctrl = 0; numctrl < NUM_GAMECONTROLS && stricmp(namectrl, gamecontrolname[numctrl]);

View file

@ -1880,6 +1880,7 @@ static int lib_pMove(lua_State *L)
return 2;
}
// TODO: 2.3: Delete
static int lib_pTeleportMove(lua_State *L)
{
mobj_t *ptmthing = tmthing;
@ -2407,6 +2408,7 @@ static int lib_pMobjTouchingSectorSpecial(lua_State *L)
return 1;
}
// TODO: 2.3: Delete
static int lib_pThingOnSpecial3DFloor(lua_State *L)
{
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -4451,8 +4453,7 @@ int LUA_BaseLib(lua_State *L)
// Set metatable for string
lua_pushliteral(L, ""); // dummy string
lua_getmetatable(L, -1); // get string metatable
lua_pushcfunction(L,lib_concat); // push concatination function
lua_setfield(L,-2,"__add"); // ... store it as mathematical addition
LUA_SetCFunctionField(L, "__add", lib_concat);
lua_pop(L, 2); // pop metatable and dummy string
lua_newtable(L);

View file

@ -194,6 +194,7 @@ static int lib_comAddCommand(lua_State *L)
if (lua_gettop(L) >= 3)
{ // For the third argument, only take a boolean or a number.
lua_settop(L, 3);
// TODO: 2.3: Remove boolean option
if (lua_type(L, 3) == LUA_TBOOLEAN)
{
CONS_Alert(CONS_WARNING,
@ -658,10 +659,7 @@ static int cvar_get(lua_State *L)
int LUA_ConsoleLib(lua_State *L)
{
// Metatable for consvar_t
luaL_newmetatable(L, META_CVAR);
lua_pushcfunction(L, cvar_get);
lua_setfield(L, -2, "__index");
lua_pop(L,1);
LUA_RegisterUserdataMetatable(L, META_CVAR, cvar_get, NULL, NULL);
cvar_fields_ref = Lua_CreateFieldTable(L, cvar_opt);

View file

@ -1396,52 +1396,16 @@ int LUA_HudLib(lua_State *L)
luaL_register(L, NULL, lib_draw);
lib_draw_ref = luaL_ref(L, LUA_REGISTRYINDEX);
luaL_newmetatable(L, META_HUDINFO);
lua_pushcfunction(L, hudinfo_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, hudinfo_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, hudinfo_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getHudInfo);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_hudinfolen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "hudinfo");
luaL_newmetatable(L, META_COLORMAP);
lua_pushcfunction(L, colormap_get);
lua_setfield(L, -2, "__index");
lua_pop(L,1);
luaL_newmetatable(L, META_PATCH);
lua_pushcfunction(L, patch_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, patch_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L,1);
LUA_RegisterUserdataMetatable(L, META_HUDINFO, hudinfo_get, hudinfo_set, hudinfo_num);
LUA_RegisterUserdataMetatable(L, META_COLORMAP, colormap_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_PATCH, patch_get, patch_set, NULL);
LUA_RegisterUserdataMetatable(L, META_CAMERA, camera_get, camera_set, NULL);
patch_fields_ref = Lua_CreateFieldTable(L, patch_opt);
luaL_newmetatable(L, META_CAMERA);
lua_pushcfunction(L, camera_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, camera_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L,1);
camera_fields_ref = Lua_CreateFieldTable(L, camera_opt);
LUA_RegisterGlobalUserdata(L, "hudinfo", lib_getHudInfo, NULL, lib_hudinfolen);
luaL_register(L, "hud", lib_hud);
return 0;
}

View file

@ -318,6 +318,7 @@ static int PopPivotSubTable(spriteframepivot_t *pivot, lua_State *L, int stk, in
pivot[idx].x = (INT32)value;
else if (ikey == 2 || (key && fastcmp(key, "y")))
pivot[idx].y = (INT32)value;
// TODO: 2.3: Delete
else if (ikey == 3 || (key && fastcmp(key, "rotaxis")))
LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed.")
else if (ikey == -1 && (key != NULL))
@ -571,6 +572,7 @@ static int framepivot_get(lua_State *L)
lua_pushinteger(L, framepivot->x);
else if (fastcmp("y", field))
lua_pushinteger(L, framepivot->y);
// TODO: 2.3: Delete
else if (fastcmp("rotaxis", field))
{
LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed.");
@ -600,6 +602,7 @@ static int framepivot_set(lua_State *L)
framepivot->x = luaL_checkinteger(L, 3);
else if (fastcmp("y", field))
framepivot->y = luaL_checkinteger(L, 3);
// TODO: 2.3: delete
else if (fastcmp("rotaxis", field))
LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed.")
else
@ -1914,206 +1917,28 @@ int LUA_InfoLib(lua_State *L)
lua_newtable(L);
lua_setfield(L, LUA_REGISTRYINDEX, LREG_ACTIONS);
luaL_newmetatable(L, META_STATE);
lua_pushcfunction(L, state_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, state_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, state_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_MOBJINFO);
lua_pushcfunction(L, mobjinfo_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, mobjinfo_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, mobjinfo_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
LUA_RegisterUserdataMetatable(L, META_STATE, state_get, state_set, state_num);
LUA_RegisterUserdataMetatable(L, META_MOBJINFO, mobjinfo_get, mobjinfo_set, mobjinfo_num);
LUA_RegisterUserdataMetatable(L, META_SKINCOLOR, skincolor_get, skincolor_set, skincolor_num);
LUA_RegisterUserdataMetatable(L, META_COLORRAMP, colorramp_get, colorramp_set, colorramp_len);
LUA_RegisterUserdataMetatable(L, META_SFXINFO, sfxinfo_get, sfxinfo_set, sfxinfo_num);
LUA_RegisterUserdataMetatable(L, META_SPRITEINFO, spriteinfo_get, spriteinfo_set, spriteinfo_num);
LUA_RegisterUserdataMetatable(L, META_PIVOTLIST, pivotlist_get, pivotlist_set, pivotlist_num);
LUA_RegisterUserdataMetatable(L, META_FRAMEPIVOT, framepivot_get, framepivot_set, framepivot_num);
LUA_RegisterUserdataMetatable(L, META_LUABANKS, lib_getluabanks, lib_setluabanks, lib_luabankslen);
mobjinfo_fields_ref = Lua_CreateFieldTable(L, mobjinfo_opt);
luaL_newmetatable(L, META_SKINCOLOR);
lua_pushcfunction(L, skincolor_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, skincolor_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, skincolor_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_COLORRAMP);
lua_pushcfunction(L, colorramp_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, colorramp_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, colorramp_len);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
luaL_newmetatable(L, META_SFXINFO);
lua_pushcfunction(L, sfxinfo_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, sfxinfo_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, sfxinfo_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_SPRITEINFO);
lua_pushcfunction(L, spriteinfo_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, spriteinfo_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, spriteinfo_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_PIVOTLIST);
lua_pushcfunction(L, pivotlist_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, pivotlist_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, pivotlist_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_FRAMEPIVOT);
lua_pushcfunction(L, framepivot_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, framepivot_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, framepivot_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSprname);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_sprnamelen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "sprnames");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSpr2name);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_spr2namelen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "spr2names");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSpr2default);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setSpr2default);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_spr2namelen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "spr2defaults");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getState);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setState);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_statelen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "states");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getMobjInfo);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setMobjInfo);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_mobjinfolen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "mobjinfo");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSkinColor);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setSkinColor);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_skincolorslen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "skincolors");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSfxInfo);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setSfxInfo);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_sfxlen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_pushvalue(L, -1);
lua_setglobal(L, "S_sfx");
lua_setglobal(L, "sfxinfo");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSpriteInfo);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setSpriteInfo);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_spriteinfolen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "spriteinfo");
luaL_newmetatable(L, META_LUABANKS);
lua_pushcfunction(L, lib_getluabanks);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setluabanks);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_luabankslen);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
LUA_RegisterGlobalUserdata(L, "sprnames", lib_getSprname, NULL, lib_sprnamelen);
LUA_RegisterGlobalUserdata(L, "spr2names", lib_getSpr2name, NULL, lib_spr2namelen);
LUA_RegisterGlobalUserdata(L, "spr2defaults", lib_getSpr2default, lib_setSpr2default, lib_spr2namelen);
LUA_RegisterGlobalUserdata(L, "states", lib_getState, lib_setState, lib_statelen);
LUA_RegisterGlobalUserdata(L, "mobjinfo", lib_getMobjInfo, lib_setMobjInfo, lib_mobjinfolen);
LUA_RegisterGlobalUserdata(L, "skincolors", lib_getSkinColor, lib_setSkinColor, lib_skincolorslen);
LUA_RegisterGlobalUserdata(L, "spriteinfo", lib_getSpriteInfo, lib_setSpriteInfo, lib_spriteinfolen);
LUA_RegisterGlobalUserdata(L, "sfxinfo", lib_getSfxInfo, lib_setSfxInfo, lib_sfxlen);
// TODO: 2.3: Delete this alias
LUA_RegisterGlobalUserdata(L, "S_sfx", lib_getSfxInfo, lib_setSfxInfo, lib_sfxlen);
return 0;
}

View file

@ -20,6 +20,7 @@
#include "lua_libs.h"
boolean mousegrabbedbylua = true;
boolean ignoregameinputs = false;
///////////////
// FUNCTIONS //
@ -145,6 +146,51 @@ static luaL_Reg lib[] = {
{NULL, NULL}
};
///////////////
// VARIABLES //
///////////////
static int lib_get(lua_State *L)
{
const char *field = luaL_checkstring(L, 2);
if (fastcmp(field, "mouse"))
{
LUA_PushUserdata(L, &mouse, META_MOUSE);
return 1;
}
else if (fastcmp(field, "mouse2"))
{
LUA_PushUserdata(L, &mouse2, META_MOUSE);
return 1;
}
else if (fastcmp(field, "ignoregameinputs"))
{
lua_pushboolean(L, ignoregameinputs);
return 1;
}
else
{
return 0;
}
}
static int lib_set(lua_State *L)
{
const char *field = luaL_checkstring(L, 2);
if (fastcmp(field, "ignoregameinputs"))
{
ignoregameinputs = luaL_checkboolean(L, 3);
}
else
{
lua_rawset(L, 1);
}
return 0;
}
///////////////////
// gamekeydown[] //
///////////////////
@ -239,32 +285,18 @@ static int mouse_num(lua_State *L)
int LUA_InputLib(lua_State *L)
{
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getGameKeyDown);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setGameKeyDown);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_lenGameKeyDown);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "gamekeydown");
luaL_newmetatable(L, META_KEYEVENT);
lua_pushcfunction(L, keyevent_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_MOUSE);
lua_pushcfunction(L, mouse_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, mouse_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
LUA_RegisterUserdataMetatable(L, META_KEYEVENT, keyevent_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_MOUSE, mouse_get, NULL, mouse_num);
// Register the library, then add __index and __newindex
// metamethods to it to allow global variables
luaL_register(L, "input", lib);
LUA_CreateAndSetMetatable(L, lib_get, lib_set, NULL, false);
LUA_CreateAndSetUserdataField(L, -1, "gamekeydown", lib_getGameKeyDown, lib_setGameKeyDown, lib_lenGameKeyDown, false);
// TODO: 2.3: Delete this alias (moved to input library)
LUA_RegisterGlobalUserdata(L, "gamekeydown", lib_getGameKeyDown, lib_setGameKeyDown, lib_lenGameKeyDown);
lua_pop(L, 1);
return 0;
}

View file

@ -13,6 +13,7 @@
extern lua_State *gL;
extern boolean mousegrabbedbylua;
extern boolean ignoregameinputs;
#define MUTABLE_TAGS

View file

@ -1043,17 +1043,7 @@ static int line_get(lua_State *L)
lua_pushinteger(L, line->special);
return 1;
case line_tag:
// HELLO
// THIS IS LJ SONIC
// HOW IS YOUR DAY?
// BY THE WAY WHEN 2.3 OR 3.0 OR 4.0 OR SRB3 OR SRB4 OR WHATEVER IS OUT
// YOU SHOULD REMEMBER TO CHANGE THIS SO IT ALWAYS RETURNS A UNSIGNED VALUE
// HAVE A NICE DAY
//
//
//
//
// you are ugly
// TODO: 2.3: Always return a unsigned value
lua_pushinteger(L, Tag_FGet(&line->tags));
return 1;
case line_taglist:
@ -1108,6 +1098,7 @@ static int line_get(lua_State *L)
case line_polyobj:
LUA_PushUserdata(L, line->polyobj, META_POLYOBJ);
return 1;
// TODO: 2.3: Delete
case line_text:
{
if (udmf)
@ -1241,6 +1232,7 @@ static int side_get(lua_State *L)
case side_repeatcnt:
lua_pushinteger(L, side->repeatcnt);
return 1;
// TODO: 2.3: Delete
case side_text:
{
if (udmf)
@ -2843,170 +2835,36 @@ static int mapheaderinfo_get(lua_State *L)
int LUA_MapLib(lua_State *L)
{
luaL_newmetatable(L, META_SECTORLINES);
lua_pushcfunction(L, sectorlines_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, sectorlines_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_SECTOR);
lua_pushcfunction(L, sector_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, sector_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, sector_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
LUA_RegisterUserdataMetatable(L, META_SECTORLINES, sectorlines_get, NULL, sectorlines_num);
LUA_RegisterUserdataMetatable(L, META_SECTOR, sector_get, sector_set, sector_num);
LUA_RegisterUserdataMetatable(L, META_SUBSECTOR, subsector_get, NULL, subsector_num);
LUA_RegisterUserdataMetatable(L, META_LINE, line_get, NULL, line_num);
LUA_RegisterUserdataMetatable(L, META_LINEARGS, lineargs_get, NULL, lineargs_len);
LUA_RegisterUserdataMetatable(L, META_LINESTRINGARGS, linestringargs_get, NULL, linestringargs_len);
LUA_RegisterUserdataMetatable(L, META_SIDENUM, sidenum_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_SIDE, side_get, side_set, side_num);
LUA_RegisterUserdataMetatable(L, META_VERTEX, vertex_get, NULL, vertex_num);
LUA_RegisterUserdataMetatable(L, META_FFLOOR, ffloor_get, ffloor_set, NULL);
LUA_RegisterUserdataMetatable(L, META_BBOX, bbox_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_SLOPE, slope_get, slope_set, NULL);
LUA_RegisterUserdataMetatable(L, META_VECTOR2, vector2_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_VECTOR3, vector3_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_MAPHEADER, mapheaderinfo_get, NULL, NULL);
sector_fields_ref = Lua_CreateFieldTable(L, sector_opt);
luaL_newmetatable(L, META_SUBSECTOR);
lua_pushcfunction(L, subsector_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, subsector_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
subsector_fields_ref = Lua_CreateFieldTable(L, subsector_opt);
luaL_newmetatable(L, META_LINE);
lua_pushcfunction(L, line_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, line_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
line_fields_ref = Lua_CreateFieldTable(L, line_opt);
luaL_newmetatable(L, META_LINEARGS);
lua_pushcfunction(L, lineargs_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lineargs_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_LINESTRINGARGS);
lua_pushcfunction(L, linestringargs_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, linestringargs_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_SIDENUM);
lua_pushcfunction(L, sidenum_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_SIDE);
lua_pushcfunction(L, side_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, side_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, side_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
side_fields_ref = Lua_CreateFieldTable(L, side_opt);
luaL_newmetatable(L, META_VERTEX);
lua_pushcfunction(L, vertex_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, vertex_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
vertex_fields_ref = Lua_CreateFieldTable(L, vertex_opt);
luaL_newmetatable(L, META_FFLOOR);
lua_pushcfunction(L, ffloor_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, ffloor_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L, 1);
ffloor_fields_ref = Lua_CreateFieldTable(L, ffloor_opt);
#ifdef HAVE_LUA_SEGS
luaL_newmetatable(L, META_SEG);
lua_pushcfunction(L, seg_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, seg_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
seg_fields_ref = Lua_CreateFieldTable(L, seg_opt);
luaL_newmetatable(L, META_NODE);
lua_pushcfunction(L, node_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, node_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
node_fields_ref = Lua_CreateFieldTable(L, node_opt);
luaL_newmetatable(L, META_NODEBBOX);
//lua_pushcfunction(L, nodebbox_get);
//lua_setfield(L, -2, "__index");
lua_pushcfunction(L, nodebbox_call);
lua_setfield(L, -2, "__call");
lua_pop(L, 1);
luaL_newmetatable(L, META_NODECHILDREN);
lua_pushcfunction(L, nodechildren_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
#endif
luaL_newmetatable(L, META_BBOX);
lua_pushcfunction(L, bbox_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_SLOPE);
lua_pushcfunction(L, slope_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, slope_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L, 1);
slope_fields_ref = Lua_CreateFieldTable(L, slope_opt);
luaL_newmetatable(L, META_VECTOR2);
lua_pushcfunction(L, vector2_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_VECTOR3);
lua_pushcfunction(L, vector3_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_MAPHEADER);
lua_pushcfunction(L, mapheaderinfo_get);
lua_setfield(L, -2, "__index");
//lua_pushcfunction(L, mapheaderinfo_num);
//lua_setfield(L, -2, "__len");
lua_pop(L, 1);
mapheaderinfo_fields_ref = Lua_CreateFieldTable(L, mapheaderinfo_opt);
LUA_RegisterGlobalUserdata(L, "subsectors", lib_getSubsector, NULL, lib_numsubsectors);
LUA_RegisterGlobalUserdata(L, "sides", lib_getSide, NULL, lib_numsides);
LUA_RegisterGlobalUserdata(L, "vertexes", lib_getVertex, NULL, lib_numvertexes);
LUA_RegisterGlobalUserdata(L, "mapheaderinfo", lib_getMapheaderinfo, NULL, lib_nummapheaders);
LUA_PushTaggableObjectArray(L, "sectors",
lib_iterateSectors,
lib_getSector,
@ -3015,16 +2873,6 @@ int LUA_MapLib(lua_State *L)
&numsectors, &sectors,
sizeof (sector_t), META_SECTOR);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSubsector);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numsubsectors);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "subsectors");
LUA_PushTaggableObjectArray(L, "lines",
lib_iterateLines,
lib_getLine,
@ -3033,56 +2881,22 @@ int LUA_MapLib(lua_State *L)
&numlines, &lines,
sizeof (line_t), META_LINE);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSide);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numsides);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "sides");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getVertex);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numvertexes);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "vertexes");
#ifdef HAVE_LUA_SEGS
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSeg);
lua_setfield(L, -2, "__index");
LUA_RegisterUserdataMetatable(L, META_SEG, seg_get, NULL, seg_num);
LUA_RegisterUserdataMetatable(L, META_NODE, node_get, NULL, node_num);
LUA_RegisterUserdataMetatable(L, META_NODECHILDREN, nodechildren_get, NULL, NULL);
lua_pushcfunction(L, lib_numsegs);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "segs");
seg_fields_ref = Lua_CreateFieldTable(L, seg_opt);
node_fields_ref = Lua_CreateFieldTable(L, node_opt);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getNode);
lua_setfield(L, -2, "__index");
luaL_newmetatable(L, META_NODEBBOX);
//LUA_SetCFunctionField(L, "__index", nodebbox_get);
LUA_SetCFunctionField(L, "__call", nodebbox_call);
lua_pop(L, 1);
lua_pushcfunction(L, lib_numnodes);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "nodes");
LUA_RegisterGlobalUserdata(L, "segs", lib_getSeg, NULL, lib_numsegs);
LUA_RegisterGlobalUserdata(L, "nodes", lib_getNode, NULL, lib_numnodes);
#endif
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getMapheaderinfo);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_nummapheaders);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "mapheaderinfo");
return 0;
}

View file

@ -125,6 +125,7 @@ static int lib_fixeddiv(lua_State *L)
return 1;
}
// TODO: 2.3: Delete
static int lib_fixedrem(lua_State *L)
{
LUA_Deprecated(L, "FixedRem(a, b)", "a % b");

View file

@ -1163,43 +1163,12 @@ static int lib_nummapthings(lua_State *L)
int LUA_MobjLib(lua_State *L)
{
luaL_newmetatable(L, META_MOBJ);
lua_pushcfunction(L, mobj_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, mobj_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L,1);
LUA_RegisterUserdataMetatable(L, META_MOBJ, mobj_get, mobj_set, NULL);
LUA_RegisterUserdataMetatable(L, META_THINGARGS, thingargs_get, NULL, thingargs_len);
LUA_RegisterUserdataMetatable(L, META_THINGSTRINGARGS, thingstringargs_get, NULL, thingstringargs_len);
LUA_RegisterUserdataMetatable(L, META_MAPTHING, mapthing_get, mapthing_set, mapthing_num);
mobj_fields_ref = Lua_CreateFieldTable(L, mobj_opt);
luaL_newmetatable(L, META_THINGARGS);
lua_pushcfunction(L, thingargs_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, thingargs_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_THINGSTRINGARGS);
lua_pushcfunction(L, thingstringargs_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, thingstringargs_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_MAPTHING);
lua_pushcfunction(L, mapthing_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, mapthing_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, mapthing_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
mapthing_fields_ref = Lua_CreateFieldTable(L, mapthing_opt);
LUA_PushTaggableObjectArray(L, "mapthings",

View file

@ -407,7 +407,7 @@ static int player_get(lua_State *L)
case player_realmo:
LUA_PushUserdata(L, plr->mo, META_MOBJ);
break;
// Kept for backward-compatibility
// TODO: 2.3: Kept for backward-compatibility
// Should be fixed to work like "realmo" later
case player_mo:
if (plr->spectator)
@ -1523,48 +1523,13 @@ static int ticcmd_set(lua_State *L)
int LUA_PlayerLib(lua_State *L)
{
luaL_newmetatable(L, META_PLAYER);
lua_pushcfunction(L, player_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, player_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, player_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
LUA_RegisterUserdataMetatable(L, META_PLAYER, player_get, player_set, player_num);
LUA_RegisterUserdataMetatable(L, META_POWERS, power_get, power_set, power_len);
LUA_RegisterUserdataMetatable(L, META_TICCMD, ticcmd_get, ticcmd_set, NULL);
player_fields_ref = Lua_CreateFieldTable(L, player_opt);
luaL_newmetatable(L, META_POWERS);
lua_pushcfunction(L, power_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, power_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, power_len);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
luaL_newmetatable(L, META_TICCMD);
lua_pushcfunction(L, ticcmd_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, ticcmd_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L,1);
ticcmd_fields_ref = Lua_CreateFieldTable(L, ticcmd_opt);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getPlayer);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_lenPlayer);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "players");
LUA_RegisterGlobalUserdata(L, "players", lib_getPlayer, NULL, lib_lenPlayer);
return 0;
}

View file

@ -447,41 +447,10 @@ static int lib_numPolyObjects(lua_State *L)
int LUA_PolyObjLib(lua_State *L)
{
luaL_newmetatable(L, META_POLYOBJVERTICES);
lua_pushcfunction(L, polyobjvertices_get);
lua_setfield(L, -2, "__index");
LUA_RegisterUserdataMetatable(L, META_POLYOBJVERTICES, polyobjvertices_get, NULL, polyobjvertices_num);
LUA_RegisterUserdataMetatable(L, META_POLYOBJLINES, polyobjlines_get, NULL, polyobjlines_num);
LUA_RegisterUserdataMetatable(L, META_POLYOBJ, polyobj_get, polyobj_set, polyobj_num);
lua_pushcfunction(L, polyobjvertices_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_POLYOBJLINES);
lua_pushcfunction(L, polyobjlines_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, polyobjlines_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_POLYOBJ);
lua_pushcfunction(L, polyobj_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, polyobj_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, polyobj_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getPolyObject);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numPolyObjects);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "polyobjects");
LUA_RegisterGlobalUserdata(L, "polyobjects", lib_getPolyObject, NULL, lib_numPolyObjects);
return 0;
}

View file

@ -415,9 +415,11 @@ int LUA_PushGlobals(lua_State *L, const char *word)
} else if (fastcmp(word, "stagefailed")) {
lua_pushboolean(L, stagefailed);
return 1;
// TODO: 2.3: Deprecated (moved to the input library)
} else if (fastcmp(word, "mouse")) {
LUA_PushUserdata(L, &mouse, META_MOUSE);
return 1;
// TODO: 2.3: Deprecated (moved to the input library)
} else if (fastcmp(word, "mouse2")) {
LUA_PushUserdata(L, &mouse2, META_MOUSE);
return 1;
@ -576,8 +578,7 @@ static void LUA_ClearState(void)
// lock the global namespace
lua_getmetatable(L, LUA_GLOBALSINDEX);
lua_pushcfunction(L, setglobals);
lua_setfield(L, -2, "__newindex");
LUA_SetCFunctionField(L, "__newindex", setglobals);
lua_newtable(L);
lua_setfield(L, -2, "__metatable");
lua_pop(L, 1);
@ -1813,20 +1814,107 @@ void LUA_PushTaggableObjectArray
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, iterator);
lua_setfield(L, -2, "iterate");
LUA_SetCFunctionField(L, "iterate", iterator);
LUA_InsertTaggroupIterator(L, garray,
max_elements, element_array, sizeof_element, meta);
lua_createtable(L, 0, 1);
lua_pushcfunction(L, indexer);
lua_setfield(L, -2, "__index");
LUA_SetCFunctionField(L, "__index", indexer);
lua_setmetatable(L, -2);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, counter);
lua_setfield(L, -2, "__len");
LUA_SetCFunctionField(L, "__len", counter);
lua_setmetatable(L, -2);
lua_setglobal(L, field);
}
static void SetBasicMetamethods(
lua_State *L,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len
)
{
if (get)
LUA_SetCFunctionField(L, "__index", get);
if (set)
LUA_SetCFunctionField(L, "__newindex", set);
if (len)
LUA_SetCFunctionField(L, "__len", len);
}
void LUA_SetCFunctionField(lua_State *L, const char *name, lua_CFunction value)
{
lua_pushcfunction(L, value);
lua_setfield(L, -2, name);
}
void LUA_RegisterUserdataMetatable(
lua_State *L,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len
)
{
luaL_newmetatable(L, name);
SetBasicMetamethods(L, get, set, len);
lua_pop(L, 1);
}
// If keep is true, leaves the metatable on the stack.
// Otherwise, the stack size remains unchanged.
void LUA_CreateAndSetMetatable(
lua_State *L,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len,
boolean keep
)
{
lua_newtable(L);
SetBasicMetamethods(L, get, set, len);
lua_pushvalue(L, -1);
lua_setmetatable(L, -3);
if (!keep)
lua_pop(L, 1);
}
// If keep is true, leaves the userdata and metatable on the stack.
// Otherwise, the stack size remains unchanged.
void LUA_CreateAndSetUserdataField(
lua_State *L,
int index,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len,
boolean keep
)
{
if (index < 0 && index > LUA_REGISTRYINDEX)
index -= 3;
lua_newuserdata(L, 0);
LUA_CreateAndSetMetatable(L, get, set, len, true);
lua_pushvalue(L, -2);
lua_setfield(L, index, name);
if (!keep)
lua_pop(L, 2);
}
void LUA_RegisterGlobalUserdata(
lua_State *L,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len
)
{
LUA_CreateAndSetUserdataField(L, LUA_GLOBALSINDEX, name, get, set, len, false);
}

View file

@ -73,6 +73,42 @@ void LUA_PushTaggableObjectArray
size_t sizeof_element,
const char *meta);
void LUA_SetCFunctionField(lua_State *L, const char *name, lua_CFunction value);
void LUA_RegisterUserdataMetatable(
lua_State *L,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len
);
void LUA_CreateAndSetMetatable(
lua_State *L,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len,
boolean keep
);
void LUA_CreateAndSetUserdataField(
lua_State *L,
int index,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len,
boolean keep
);
void LUA_RegisterGlobalUserdata(
lua_State *L,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len
);
void LUA_InsertTaggroupIterator
( lua_State *L,
taggroup_t *garray[],

View file

@ -373,49 +373,14 @@ static int sprite_get(lua_State *L)
int LUA_SkinLib(lua_State *L)
{
luaL_newmetatable(L, META_SKIN);
lua_pushcfunction(L, skin_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, skin_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, skin_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
LUA_RegisterUserdataMetatable(L, META_SKIN, skin_get, skin_set, skin_num);
LUA_RegisterUserdataMetatable(L, META_SOUNDSID, soundsid_get, NULL, soundsid_num);
LUA_RegisterUserdataMetatable(L, META_SKINSPRITES, lib_getSkinSprite, NULL, lib_numSkinsSprites);
LUA_RegisterUserdataMetatable(L, META_SKINSPRITESLIST, sprite_get, NULL, NULL);
skin_fields_ref = Lua_CreateFieldTable(L, skin_opt);
luaL_newmetatable(L, META_SOUNDSID);
lua_pushcfunction(L, soundsid_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, soundsid_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
luaL_newmetatable(L, META_SKINSPRITES);
lua_pushcfunction(L, lib_getSkinSprite);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numSkinsSprites);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
luaL_newmetatable(L, META_SKINSPRITESLIST);
lua_pushcfunction(L, sprite_get);
lua_setfield(L, -2, "__index");
lua_pop(L,1);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSkin);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numSkins);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "skins");
LUA_RegisterGlobalUserdata(L, "skins", lib_getSkin, NULL, lib_numSkins);
return 0;
}

View file

@ -372,8 +372,7 @@ void LUA_InsertTaggroupIterator
lua_pushcclosure(L, lib_numTaggroupElements, 2);
lua_setfield(L, -2, "__len");
lua_pushcfunction(L, element_iterator);
lua_setfield(L, -2, "__call");
LUA_SetCFunctionField(L, "__call", element_iterator);
lua_pushcclosure(L, lib_getTaggroup, 1);
lua_setfield(L, -2, "tagged");
}
@ -414,11 +413,9 @@ set_taglist_metatable(lua_State *L, const char *meta)
lua_setfenv(L, -2);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, taglist_len);
lua_setfield(L, -2, "__len");
LUA_SetCFunctionField(L, "__len", taglist_len);
lua_pushcfunction(L, taglist_equal);
lua_setfield(L, -2, "__eq");
LUA_SetCFunctionField(L, "__eq", taglist_equal);
#ifdef MUTABLE_TAGS
return luaL_ref(L, LUA_REGISTRYINDEX);
#endif
@ -426,17 +423,11 @@ set_taglist_metatable(lua_State *L, const char *meta)
int LUA_TagLib(lua_State *L)
{
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
LUA_CreateAndSetUserdataField(L, LUA_GLOBALSINDEX, "tags", NULL, NULL, lib_numTags, true);
lua_createtable(L, 0, 1);
lua_pushcfunction(L, lib_iterateTags);
lua_setfield(L, -2, "iterate");
LUA_SetCFunctionField(L, "iterate", lib_iterateTags);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numTags);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "tags");
lua_pop(L, 2);
open_taglist(L);

View file

@ -127,8 +127,7 @@ static int lib_startIterate(lua_State *L)
int LUA_ThinkerLib(lua_State *L)
{
luaL_newmetatable(L, META_ITERATIONSTATE);
lua_pushcfunction(L, iterationState_gc);
lua_setfield(L, -2, "__gc");
LUA_SetCFunctionField(L, "__gc", iterationState_gc);
lua_pop(L, 1);
lua_createtable(L, 0, 1);

View file

@ -13321,7 +13321,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
return true;
}
// Pre-UDMF backwards compatibility stuff. Remove for 2.3
// TODO: 2.3: Delete (Pre-UDMF backwards compatibility stuff)
static void P_SetAmbush(mapthing_t *mthing, mobj_t *mobj)
{
if (mobj->type == MT_NIGHTSBUMPER

View file

@ -18,7 +18,7 @@
#pragma interface
#endif
#define NEWSKINSAVES (INT16_MAX) // Purely for backwards compatibility, remove this for 2.3
#define NEWSKINSAVES (INT16_MAX) // TODO: 2.3: Delete (Purely for backwards compatibility)
// Persistent storage/archiving.
// These are the load / save game routines.

View file

@ -6132,6 +6132,7 @@ static void P_ConvertBinarySectorTypes(void)
case 14: //Non-ramp sector
sectors[i].specialflags |= SSF_NOSTEPDOWN;
break;
// TODO: 2.3: Delete
case 15: //Bouncy FOF
CONS_Alert(CONS_WARNING, M_GetText("Deprecated bouncy FOF sector type detected. Please use linedef type 76 instead.\n"));
break;
@ -6166,12 +6167,14 @@ static void P_ConvertBinarySectorTypes(void)
sectors[i].flags |= MSF_TRIGGERLINE_PLANE;
sectors[i].triggerer = TO_PLAYER;
break;
// TODO: 2.3: Delete
case 6: //Trigger linedef executor (Emerald check)
CONS_Alert(CONS_WARNING, M_GetText("Deprecated emerald check sector type detected. Please use linedef types 337-339 instead.\n"));
sectors[i].triggertag = tag;
sectors[i].flags &= ~MSF_TRIGGERLINE_PLANE;
sectors[i].triggerer = TO_PLAYEREMERALDS;
break;
// TODO: 2.3: Delete
case 7: //Trigger linedef executor (NiGHTS mare)
CONS_Alert(CONS_WARNING, M_GetText("Deprecated NiGHTS mare sector type detected. Please use linedef types 340-342 instead.\n"));
sectors[i].triggertag = tag;
@ -6181,9 +6184,11 @@ static void P_ConvertBinarySectorTypes(void)
case 8: //Check for linedef executor on FOFs
sectors[i].flags |= MSF_TRIGGERLINE_MOBJ;
break;
// TODO: 2.3: Delete
case 10: //Special stage time/spheres requirements
CONS_Alert(CONS_WARNING, M_GetText("Deprecated sector type for special stage requirements detected. Please use the SpecialStageTime and SpecialStageSpheres level header options instead.\n"));
break;
// TODO: 2.3: Delete
case 11: //Custom global gravity
CONS_Alert(CONS_WARNING, M_GetText("Deprecated sector type for global gravity detected. Please use the Gravity level header option instead.\n"));
break;

View file

@ -4178,6 +4178,7 @@ sector_t *P_MobjTouchingSectorSpecial(mobj_t *mo, INT32 section, INT32 number)
return NULL;
}
// TODO: 2.3: Delete
// Deprecated in favor of P_MobjTouchingSectorSpecial
// Kept for Lua backwards compatibility only
sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo)
@ -6229,6 +6230,7 @@ void P_SpawnSpecials(boolean fromnetsave)
sector->flags |= MSF_TRIGGERSPECIAL_TOUCH;
}
// TODO: 2.3: Delete everything below
// Process deprecated binary sector specials
if (udmf || !sector->special)
continue;

View file

@ -2773,6 +2773,7 @@ static void P_CheckBouncySectors(player_t *player)
if (!(rover->fofflags & FOF_EXISTS))
continue; // FOFs should not be bouncy if they don't even "exist"
// TODO: 2.3: Delete
// Handle deprecated bouncy FOF sector type
if (!udmf && GETSECSPECIAL(rover->master->frontsector->special, 1) == 15)
{