Fix bug pertaining to rawgeti not supporting int64
This commit is contained in:
@@ -429,11 +429,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename RT>
|
template<typename RT>
|
||||||
void rawgeti(RT &target, LuaSlot tab, lua_Integer key) const {
|
void rawgeti(RT &target, LuaSlot tab, int key) const {
|
||||||
lua_rawgeti(L_, tab, key);
|
lua_rawgeti(L_, tab, key);
|
||||||
pop_any_value(target);
|
pop_any_value(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename KT, typename VT>
|
template<typename KT, typename VT>
|
||||||
void rawset(LuaSlot tab, KT key, VT value) const {
|
void rawset(LuaSlot tab, KT key, VT value) const {
|
||||||
push_any_value(key);
|
push_any_value(key);
|
||||||
@@ -442,7 +442,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename VT>
|
template<typename VT>
|
||||||
void rawseti(LuaSlot tab, lua_Integer key, VT value) const {
|
void rawseti(LuaSlot tab, int key, VT value) const {
|
||||||
push_any_value(value);
|
push_any_value(value);
|
||||||
lua_rawseti(L_, tab, key);
|
lua_rawseti(L_, tab, key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ std::string join(const StringVec &strs, const std::string &sep) {
|
|||||||
if (strs.empty()) return "";
|
if (strs.empty()) return "";
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << strs[0];
|
oss << strs[0];
|
||||||
for (int i = 1; i < strs.size(); i++) {
|
for (int i = 1; i < int(strs.size()); i++) {
|
||||||
oss << sep << strs[i];
|
oss << sep << strs[i];
|
||||||
}
|
}
|
||||||
return oss.str();
|
return oss.str();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "streambuffer.hpp"
|
#include "streambuffer.hpp"
|
||||||
#include "table.hpp"
|
#include "table.hpp"
|
||||||
#include "world.hpp"
|
#include "world.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
// Given a table and an tnmap, return the table number of the table.
|
// Given a table and an tnmap, return the table number of the table.
|
||||||
// Returns zero if the table doesn't have a table number.
|
// 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;
|
LuaVar skey, mkey, sval, mval, mnil;
|
||||||
LuaStack SLS(SLS0.state(), skey, sval);
|
LuaStack SLS(SLS0.state(), skey, sval);
|
||||||
LuaStack MLS(MLS0.state(), mkey, mval, mnil);
|
LuaStack MLS(MLS0.state(), mkey, mval, mnil);
|
||||||
|
assert(MLS.istable(mtab));
|
||||||
|
assert(SLS.istable(stab));
|
||||||
MLS.set(mnil, LuaNil);
|
MLS.set(mnil, LuaNil);
|
||||||
int nupdates = 0;
|
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 s_top = lua_gettop(synch);
|
||||||
int m_top = lua_gettop(master);
|
int m_top = lua_gettop(master);
|
||||||
for (int64_t id : basis) {
|
for (int64_t id : basis) {
|
||||||
MLS.rawgeti(mtab, mtangibles, id);
|
MLS.rawget(mtab, mtangibles, id);
|
||||||
SLS.rawgeti(stab, stangibles, id);
|
SLS.rawget(stab, stangibles, id);
|
||||||
|
assert(MLS.istable(mtab));
|
||||||
|
assert(SLS.istable(stab));
|
||||||
int tw = sb->total_writes();
|
int tw = sb->total_writes();
|
||||||
sb->write_int64(id);
|
sb->write_int64(id);
|
||||||
nmodified += 1;
|
nmodified += 1;
|
||||||
|
|||||||
@@ -195,7 +195,6 @@ void World::diff_luatabs(int64_t actor_id, World *master, StreamBuffer *xsb) {
|
|||||||
assert(tsb.read_int32() == ncreate);
|
assert(tsb.read_int32() == ncreate);
|
||||||
patch_tangible_databases(&tsb);
|
patch_tangible_databases(&tsb);
|
||||||
patch_numbered_tables(&tsb);
|
patch_numbered_tables(&tsb);
|
||||||
unnumber_lua_tables();
|
|
||||||
assert(tsb.empty());
|
assert(tsb.empty());
|
||||||
|
|
||||||
// Unnumber tables in both models.
|
// Unnumber tables in both models.
|
||||||
@@ -212,7 +211,7 @@ void World::patch_tanclass(StreamBuffer *sb) {
|
|||||||
int nmodified = sb->read_int32();
|
int nmodified = sb->read_int32();
|
||||||
for (int i = 0; i < nmodified; i++) {
|
for (int i = 0; i < nmodified; i++) {
|
||||||
int64_t id = sb->read_int64();
|
int64_t id = sb->read_int64();
|
||||||
LS.rawgeti(tab, tangibles, id);
|
LS.rawget(tab, tangibles, id);
|
||||||
assert(LS.istable(tab));
|
assert(LS.istable(tab));
|
||||||
LS.getmetatable(meta, tab);
|
LS.getmetatable(meta, tab);
|
||||||
std::string name = sb->read_string();
|
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 write_count_after = tsb.total_writes();
|
||||||
int nmodified = 0;
|
int nmodified = 0;
|
||||||
for (int64_t id : closetans) {
|
for (int64_t id : closetans) {
|
||||||
MLS.rawgeti(mtab, mtangibles, id);
|
MLS.rawget(mtab, mtangibles, id);
|
||||||
SLS.rawgeti(stab, stangibles, id);
|
SLS.rawget(stab, stangibles, id);
|
||||||
MLS.getmetatable(mmeta, mtab);
|
MLS.getmetatable(mmeta, mtab);
|
||||||
SLS.getmetatable(smeta, stab);
|
SLS.getmetatable(smeta, stab);
|
||||||
MLS.rawget(mclass, mmeta, "__index");
|
MLS.rawget(mclass, mmeta, "__index");
|
||||||
|
|||||||
Reference in New Issue
Block a user