diff options
| author | Alexander Gavrilov | 2012-04-01 17:59:47 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-04-01 17:59:47 +0400 |
| commit | 604c84953b21093c69e34c8c9b3851aa34fbc7ff (patch) | |
| tree | 67501c5724e820ce336a4b2d5db39d7390aafd45 /library/LuaWrapper.cpp | |
| parent | a3e526abdb01a07ba3679ec3e6b3e7a7028c6aec (diff) | |
| download | dfhack-604c84953b21093c69e34c8c9b3851aa34fbc7ff.tar.gz dfhack-604c84953b21093c69e34c8c9b3851aa34fbc7ff.tar.bz2 dfhack-604c84953b21093c69e34c8c9b3851aa34fbc7ff.tar.xz | |
Fix a bug: LookupTypeInfo cannot assume the result is userdata.
Diffstat (limited to 'library/LuaWrapper.cpp')
| -rw-r--r-- | library/LuaWrapper.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/library/LuaWrapper.cpp b/library/LuaWrapper.cpp index 5b2ff563..00d0ff64 100644 --- a/library/LuaWrapper.cpp +++ b/library/LuaWrapper.cpp @@ -120,7 +120,7 @@ bool LuaWrapper::LookupTypeInfo(lua_State *state, bool in_method) // stack: [info] - if (!lua_islightuserdata(state, -1)) + if (lua_isnil(state, -1)) { lua_pop(state, 1); return false; @@ -132,8 +132,7 @@ bool LuaWrapper::LookupTypeInfo(lua_State *state, bool in_method) void LuaWrapper::LookupInTable(lua_State *state, void *id, const char *tname) { lua_getfield(state, LUA_REGISTRYINDEX, tname); - lua_pushlightuserdata(state, id); - lua_rawget(state, -2); + lua_rawgetp(state, -1, id); lua_remove(state, -2); } @@ -142,9 +141,8 @@ void LuaWrapper::SaveInTable(lua_State *state, void *node, const char *tname) // stack: [info] lua_getfield(state, LUA_REGISTRYINDEX, tname); - lua_pushlightuserdata(state, node); - lua_pushvalue(state, -3); - lua_rawset(state, -3); + lua_pushvalue(state, -2); + lua_rawsetp(state, -2, node); lua_pushvalue(state, -2); lua_pushlightuserdata(state, node); |
