mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-30 21:20:54 +00:00
Avoid running setter metamethods when not appropriate to do so
This commit is contained in:
parent
c4d7fe7c5a
commit
5f4d6c4545
1 changed files with 15 additions and 5 deletions
|
@ -362,6 +362,11 @@ static int lib_setSpriteInfo(lua_State *L)
|
|||
{
|
||||
spriteinfo_t *info;
|
||||
|
||||
if (!lua_lumploading)
|
||||
return luaL_error(L, "Do not alter spriteinfo_t from within a hook or coroutine!");
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter spriteinfo_t in HUD rendering code!");
|
||||
|
||||
lua_remove(L, 1);
|
||||
{
|
||||
UINT32 i = luaL_checkinteger(L, 1);
|
||||
|
@ -373,11 +378,6 @@ static int lib_setSpriteInfo(lua_State *L)
|
|||
lua_remove(L, 1); // pop sprite num, don't need it any more.
|
||||
lua_settop(L, 1); // cut the stack here. the only thing left now is the table of data we're assigning to the spriteinfo.
|
||||
|
||||
if (!lua_lumploading)
|
||||
return luaL_error(L, "Do not alter spriteinfo_t from within a hook or coroutine!");
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter spriteinfo_t in HUD rendering code!");
|
||||
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 1)) {
|
||||
lua_Integer i = 0;
|
||||
|
@ -527,6 +527,11 @@ static int pivotlist_set(lua_State *L)
|
|||
const char *field = luaL_checkstring(L, 2);
|
||||
UINT8 frame;
|
||||
|
||||
if (!lua_lumploading)
|
||||
return luaL_error(L, "Do not alter spriteframepivot_t from within a hook or coroutine!");
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter spriteframepivot_t in HUD rendering code!");
|
||||
|
||||
I_Assert(pivotlist != NULL);
|
||||
|
||||
frame = R_Char2Frame(field[0]);
|
||||
|
@ -574,6 +579,11 @@ static int framepivot_set(lua_State *L)
|
|||
spriteframepivot_t *framepivot = *((spriteframepivot_t **)luaL_checkudata(L, 1, META_FRAMEPIVOT));
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
|
||||
if (!lua_lumploading)
|
||||
return luaL_error(L, "Do not alter spriteframepivot_t from within a hook or coroutine!");
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter spriteframepivot_t in HUD rendering code!");
|
||||
|
||||
I_Assert(framepivot != NULL);
|
||||
|
||||
if (fastcmp("x", field))
|
||||
|
|
Loading…
Reference in a new issue