From fb043e99710b522299728536d196d0185cca405c Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Wed, 17 Nov 2021 15:06:10 -0500 Subject: [PATCH] Fix bug pertaining to rawgeti not supporting int64 --- luprex/core/cpp/luastack.hpp | 6 +++--- luprex/core/cpp/util.cpp | 2 +- luprex/core/cpp/world-difftab.cpp | 9 +++++++-- luprex/core/cpp/world-diffxmit.cpp | 7 +++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/luprex/core/cpp/luastack.hpp b/luprex/core/cpp/luastack.hpp index f3405f76..41f601ee 100644 --- a/luprex/core/cpp/luastack.hpp +++ b/luprex/core/cpp/luastack.hpp @@ -429,11 +429,11 @@ public: } template - void rawgeti(RT &target, LuaSlot tab, lua_Integer key) const { + void rawgeti(RT &target, LuaSlot tab, int key) const { lua_rawgeti(L_, tab, key); pop_any_value(target); } - + template void rawset(LuaSlot tab, KT key, VT value) const { push_any_value(key); @@ -442,7 +442,7 @@ public: } template - void rawseti(LuaSlot tab, lua_Integer key, VT value) const { + void rawseti(LuaSlot tab, int key, VT value) const { push_any_value(value); lua_rawseti(L_, tab, key); } diff --git a/luprex/core/cpp/util.cpp b/luprex/core/cpp/util.cpp index be8d8807..d8d44739 100644 --- a/luprex/core/cpp/util.cpp +++ b/luprex/core/cpp/util.cpp @@ -146,7 +146,7 @@ std::string join(const StringVec &strs, const std::string &sep) { if (strs.empty()) return ""; std::ostringstream oss; oss << strs[0]; - for (int i = 1; i < strs.size(); i++) { + for (int i = 1; i < int(strs.size()); i++) { oss << sep << strs[i]; } return oss.str(); diff --git a/luprex/core/cpp/world-difftab.cpp b/luprex/core/cpp/world-difftab.cpp index 191ea029..7a4caf1a 100644 --- a/luprex/core/cpp/world-difftab.cpp +++ b/luprex/core/cpp/world-difftab.cpp @@ -22,6 +22,7 @@ #include "streambuffer.hpp" #include "table.hpp" #include "world.hpp" +#include // Given a table and an tnmap, return the table number of the table. // Returns zero if the table doesn't have a table number. @@ -179,6 +180,8 @@ static bool diff_tables(LuaStack &SLS0, LuaSlot stnmap, LuaSlot stab, LuaVar skey, mkey, sval, mval, mnil; LuaStack SLS(SLS0.state(), skey, sval); LuaStack MLS(MLS0.state(), mkey, mval, mnil); + assert(MLS.istable(mtab)); + assert(SLS.istable(stab)); MLS.set(mnil, LuaNil); int nupdates = 0; @@ -399,8 +402,10 @@ void World::diff_tangible_databases(const IdVector &basis, lua_State *master, St int s_top = lua_gettop(synch); int m_top = lua_gettop(master); for (int64_t id : basis) { - MLS.rawgeti(mtab, mtangibles, id); - SLS.rawgeti(stab, stangibles, id); + MLS.rawget(mtab, mtangibles, id); + SLS.rawget(stab, stangibles, id); + assert(MLS.istable(mtab)); + assert(SLS.istable(stab)); int tw = sb->total_writes(); sb->write_int64(id); nmodified += 1; diff --git a/luprex/core/cpp/world-diffxmit.cpp b/luprex/core/cpp/world-diffxmit.cpp index ca94e5b3..2eba6b12 100644 --- a/luprex/core/cpp/world-diffxmit.cpp +++ b/luprex/core/cpp/world-diffxmit.cpp @@ -195,7 +195,6 @@ void World::diff_luatabs(int64_t actor_id, World *master, StreamBuffer *xsb) { assert(tsb.read_int32() == ncreate); patch_tangible_databases(&tsb); patch_numbered_tables(&tsb); - unnumber_lua_tables(); assert(tsb.empty()); // Unnumber tables in both models. @@ -212,7 +211,7 @@ void World::patch_tanclass(StreamBuffer *sb) { int nmodified = sb->read_int32(); for (int i = 0; i < nmodified; i++) { int64_t id = sb->read_int64(); - LS.rawgeti(tab, tangibles, id); + LS.rawget(tab, tangibles, id); assert(LS.istable(tab)); LS.getmetatable(meta, tab); std::string name = sb->read_string(); @@ -243,8 +242,8 @@ void World::diff_tanclass(int64_t actor_id, World *master, StreamBuffer *xsb) { int write_count_after = tsb.total_writes(); int nmodified = 0; for (int64_t id : closetans) { - MLS.rawgeti(mtab, mtangibles, id); - SLS.rawgeti(stab, stangibles, id); + MLS.rawget(mtab, mtangibles, id); + SLS.rawget(stab, stangibles, id); MLS.getmetatable(mmeta, mtab); SLS.getmetatable(smeta, stab); MLS.rawget(mclass, mmeta, "__index");