mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Allow access to players userdata outside levels.
In exchange for preventing access to any mobj_t userdata outside levels, including player's own mobj_t.
This commit is contained in:
parent
727b5e460b
commit
3c71434a02
2 changed files with 2 additions and 2 deletions
|
|
@ -160,6 +160,7 @@ static const char *const mobj_opt[] = {
|
||||||
|
|
||||||
static int mobj_get(lua_State *L)
|
static int mobj_get(lua_State *L)
|
||||||
{
|
{
|
||||||
|
INLEVEL
|
||||||
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||||
enum mobj_e field = Lua_optoption(L, 2, NULL, mobj_opt);
|
enum mobj_e field = Lua_optoption(L, 2, NULL, mobj_opt);
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
|
|
@ -405,6 +406,7 @@ static int mobj_get(lua_State *L)
|
||||||
#define NOSETPOS luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " should not be set directly. Use " LUA_QL("P_Move") ", " LUA_QL("P_TryMove") ", or " LUA_QL("P_TeleportMove") " instead.", mobj_opt[field])
|
#define NOSETPOS luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " should not be set directly. Use " LUA_QL("P_Move") ", " LUA_QL("P_TryMove") ", or " LUA_QL("P_TeleportMove") " instead.", mobj_opt[field])
|
||||||
static int mobj_set(lua_State *L)
|
static int mobj_set(lua_State *L)
|
||||||
{
|
{
|
||||||
|
INLEVEL
|
||||||
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||||
enum mobj_e field = Lua_optoption(L, 2, mobj_opt[0], mobj_opt);
|
enum mobj_e field = Lua_optoption(L, 2, mobj_opt[0], mobj_opt);
|
||||||
lua_settop(L, 3);
|
lua_settop(L, 3);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
static int lib_iteratePlayers(lua_State *L)
|
static int lib_iteratePlayers(lua_State *L)
|
||||||
{
|
{
|
||||||
INT32 i = -1;
|
INT32 i = -1;
|
||||||
INLEVEL
|
|
||||||
if (lua_gettop(L) < 2)
|
if (lua_gettop(L) < 2)
|
||||||
{
|
{
|
||||||
//return luaL_error(L, "Don't call players.iterate() directly, use it as 'for player in players.iterate do <block> end'.");
|
//return luaL_error(L, "Don't call players.iterate() directly, use it as 'for player in players.iterate do <block> end'.");
|
||||||
|
|
@ -52,7 +51,6 @@ static int lib_getPlayer(lua_State *L)
|
||||||
{
|
{
|
||||||
const char *field;
|
const char *field;
|
||||||
// i -> players[i]
|
// i -> players[i]
|
||||||
INLEVEL
|
|
||||||
if (lua_type(L, 2) == LUA_TNUMBER)
|
if (lua_type(L, 2) == LUA_TNUMBER)
|
||||||
{
|
{
|
||||||
lua_Integer i = luaL_checkinteger(L, 2);
|
lua_Integer i = luaL_checkinteger(L, 2);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue