diff options
author | Willem Jan Palenstijn | 2017-01-28 18:47:11 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2017-01-28 18:47:11 +0100 |
commit | c3d533a72bedb469c42a3a8ee52830ac696a5533 (patch) | |
tree | c6d74354a57751935cf694ce21231dd9858618a3 /engines | |
parent | 0a5e36d689d19d11129a5ecd243342be0a8a8b81 (diff) | |
download | scummvm-rg350-c3d533a72bedb469c42a3a8ee52830ac696a5533.tar.gz scummvm-rg350-c3d533a72bedb469c42a3a8ee52830ac696a5533.tar.bz2 scummvm-rg350-c3d533a72bedb469c42a3a8ee52830ac696a5533.zip |
SWORD25: Use direct integer index into indexTbl
This matches the behaviour of the Pluto rewrite Eris, and avoids
casting the integer indices to void *.
I verified this code by running this method in parallel with the current
lightuserdata/void* approach and asserting the retrieved objects were
identical when loading a savegame.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sword25/util/lua_unpersist.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/engines/sword25/util/lua_unpersist.cpp b/engines/sword25/util/lua_unpersist.cpp index 678ddb52db..9c304503b9 100644 --- a/engines/sword25/util/lua_unpersist.cpp +++ b/engines/sword25/util/lua_unpersist.cpp @@ -116,16 +116,13 @@ static void registerObjectInIndexTable(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... obj // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 2); - - lua_pushlightuserdata(info->luaState, (void *)index); - // >>>>> permTbl indexTbl ...... obj index + lua_checkstack(info->luaState, 1); - lua_pushvalue(info->luaState, -2); - // >>>>> permTbl indexTbl ...... obj index obj + lua_pushvalue(info->luaState, -1); + // >>>>> permTbl indexTbl ...... obj obj // Push the k/v pair into the indexTbl - lua_settable(info->luaState, 2); + lua_rawseti(info->luaState, 2, index); // >>>>> permTbl indexTbl ...... obj } @@ -198,10 +195,7 @@ static void unpersist(UnSerializationInfo *info) { } else { // Fetch the object from the indexTbl - lua_pushlightuserdata(info->luaState, (void *)index); - // >>>>> permTbl indexTbl ...... index - - lua_gettable(info->luaState, 2); + lua_rawgeti(info->luaState, 2, index); // >>>>> permTbl indexTbl ...... ?obj? assert(!lua_isnil(info->luaState, -1)); |