mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-29 12:40:58 +00:00
Throw an error if too many metatables are registered
This commit is contained in:
parent
1155d875d5
commit
e52cb7f6fa
1 changed files with 4 additions and 1 deletions
|
@ -250,12 +250,15 @@ static int lib_userdataType(lua_State *L)
|
|||
// Only callable during script loading
|
||||
static int lib_registerMetatable(lua_State *L)
|
||||
{
|
||||
static UINT32 nextid = 1;
|
||||
static UINT16 nextid = 1;
|
||||
|
||||
if (!lua_lumploading)
|
||||
return luaL_error(L, "This function cannot be called from within a hook or coroutine!");
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
|
||||
if (nextid == 0)
|
||||
luaL_error(L, "Too many metatables registered?! Please consider rewriting your script once you are sober again.\n");
|
||||
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LREG_METATABLES); // 2
|
||||
// registry.metatables[metatable] = nextid
|
||||
lua_pushvalue(L, 1); // 3
|
||||
|
|
Loading…
Reference in a new issue