mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
LUA mapthing_t checks
add check that LUA can't access fields that don't exist in mapthing_t
This commit is contained in:
parent
cb3deaaaac
commit
4ae7a0e093
3 changed files with 19 additions and 7 deletions
|
@ -482,7 +482,7 @@ static int spriteinfo_set(lua_State *L)
|
|||
}
|
||||
}
|
||||
else
|
||||
return luaL_error(L, va("Field %s does not exist in spriteinfo_t", field));
|
||||
return luaL_error(L, "Field %s does not exist in spriteinfo_t", field);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ static int framepivot_get(lua_State *L)
|
|||
lua_pushinteger(L, 0);
|
||||
}
|
||||
else
|
||||
return luaL_error(L, va("Field %s does not exist in spriteframepivot_t", field));
|
||||
return luaL_error(L, "Field %s does not exist in spriteframepivot_t", field);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -603,7 +603,7 @@ static int framepivot_set(lua_State *L)
|
|||
else if (fastcmp("rotaxis", field))
|
||||
LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed.")
|
||||
else
|
||||
return luaL_error(L, va("Field %s does not exist in spriteframepivot_t", field));
|
||||
return luaL_error(L, "Field %s does not exist in spriteframepivot_t", field);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -973,6 +973,9 @@ static int mapthing_get(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (field == (enum mapthing_e)-1)
|
||||
return LUA_ErrInvalid(L, "fields");
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case mapthing_valid:
|
||||
|
@ -1031,7 +1034,7 @@ static int mapthing_get(lua_State *L)
|
|||
break;
|
||||
default:
|
||||
if (devparm)
|
||||
return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field);
|
||||
return luaL_error(L, "%s %s", LUA_QL("mapthing_t"), va("has no field named: %ui", field));
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -1048,6 +1051,9 @@ static int mapthing_set(lua_State *L)
|
|||
if (!mt)
|
||||
return luaL_error(L, "accessed mapthing_t doesn't exist anymore.");
|
||||
|
||||
if (field == (enum mapthing_e)-1)
|
||||
return LUA_ErrInvalid(L, "fields");
|
||||
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter mapthing_t in HUD rendering code!");
|
||||
if (hook_cmd_running)
|
||||
|
@ -1105,7 +1111,7 @@ static int mapthing_set(lua_State *L)
|
|||
mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
|
||||
break;
|
||||
default:
|
||||
return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field);
|
||||
return luaL_error(L, "%s %s", LUA_QL("mapthing_t"), va("has no field named: %ui", field));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1431,8 +1431,8 @@ static int power_len(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#define NOFIELD luaL_error(L, LUA_QL("ticcmd_t") " has no field named " LUA_QS, field)
|
||||
#define NOSET luaL_error(L, LUA_QL("ticcmd_t") " field " LUA_QS " should not be set directly.", ticcmd_opt[field])
|
||||
#define NOFIELD luaL_error(L, "%s %s", LUA_QL("ticcmd_t"), va("has no field named %ui", field))
|
||||
#define NOSET luaL_error(L, LUA_QL("ticcmd_t") " field %s should not be set directly.", ticcmd_opt[field])
|
||||
|
||||
enum ticcmd_e
|
||||
{
|
||||
|
@ -1463,6 +1463,9 @@ static int ticcmd_get(lua_State *L)
|
|||
if (!cmd)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
|
||||
if (field == (enum ticcmd_e)-1)
|
||||
return LUA_ErrInvalid(L, "fields");
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case ticcmd_forwardmove:
|
||||
|
@ -1497,6 +1500,9 @@ static int ticcmd_set(lua_State *L)
|
|||
if (!cmd)
|
||||
return LUA_ErrInvalid(L, "ticcmd_t");
|
||||
|
||||
if (field == (enum ticcmd_e)-1)
|
||||
return LUA_ErrInvalid(L, "fields");
|
||||
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter player_t in HUD rendering code!");
|
||||
|
||||
|
|
Loading…
Reference in a new issue