diff transmission code tested!!!

This commit is contained in:
2021-09-10 17:06:07 -04:00
parent aedd8ca43a
commit 6fbe700107
10 changed files with 1354 additions and 1131 deletions

View File

@@ -272,7 +272,7 @@ static void set_transmitted_value(LuaStack &LS, LuaSlot tangibles, LuaSlot ntmap
LS.rawgeti(target, tangibles, id);
if (LS.isnil(target)) {
World *w = World::fetch_global_pointer(LS.state());
w->tangible_make(LS.state(), id, true);
w->tangible_make(LS.state(), id, "nowhere", true);
lua_replace(LS.state(), target.index());
}
return;
@@ -306,6 +306,25 @@ static void patch_table(LuaStack &LS0, LuaSlot tangibles, LuaSlot ntmap, LuaSlot
LS.result();
}
void World::patch_numbered_tables(StreamBuffer *sb) {
lua_State *L = state();
LuaVar tangibles, ntmap, tab;
LuaStack LS(L, tangibles, ntmap, tab);
LS.rawget(tangibles, LuaRegistry, "tangibles");
LS.rawget(ntmap, LuaRegistry, "ntmap");
assert(LS.istable(tangibles));
assert(LS.istable(ntmap));
int nmodified = sb->read_int32();
for (int i = 0; i < nmodified; i++) {
int index = sb->read_int32();
LS.rawgeti(tab, ntmap, index);
assert(LS.istable(tab));
patch_table(LS, tangibles, ntmap, tab, sb);
}
LS.result();
}
void World::diff_numbered_tables(lua_State *master, StreamBuffer *sb) {
lua_State *synch = state();
LuaVar sntmap, mntmap, stnmap, mtnmap, stab, mtab;
@@ -345,6 +364,24 @@ void World::diff_numbered_tables(lua_State *master, StreamBuffer *sb) {
MLS.result();
}
void World::patch_tangible_databases(StreamBuffer *sb) {
lua_State *L = state();
LuaVar tangibles, ntmap, tab;
LuaStack LS(L, tangibles, ntmap, tab);
LS.rawget(tangibles, LuaRegistry, "tangibles");
LS.rawget(ntmap, LuaRegistry, "ntmap");
assert(LS.istable(tangibles));
assert(LS.istable(ntmap));
int nmodified = sb->read_int32();
for (int i = 0; i < nmodified; i++) {
int64_t id = sb->read_int64();
LS.rawgeti(tab, tangibles, id);
assert(LS.istable(tab));
patch_table(LS, tangibles, ntmap, tab, sb);
}
LS.result();
}
void World::diff_tangible_databases(const IdVector &basis, lua_State *master, StreamBuffer *sb) {
lua_State *synch = state();
@@ -379,44 +416,6 @@ void World::diff_tangible_databases(const IdVector &basis, lua_State *master, St
MLS.result();
}
void World::patch_numbered_tables(StreamBuffer *sb) {
lua_State *L = state();
LuaVar tangibles, ntmap, tab;
LuaStack LS(L, tangibles, ntmap, tab);
LS.rawget(tangibles, LuaRegistry, "tangibles");
LS.rawget(ntmap, LuaRegistry, "ntmap");
assert(LS.istable(tangibles));
assert(LS.istable(ntmap));
int nmodified = sb->read_int32();
for (int i = 0; i < nmodified; i++) {
int index = sb->read_int32();
LS.rawgeti(tab, ntmap, index);
assert(LS.istable(tab));
patch_table(LS, tangibles, ntmap, tab, sb);
}
LS.result();
}
void World::patch_tangible_databases(StreamBuffer *sb) {
lua_State *L = state();
LuaVar tangibles, ntmap, tab;
LuaStack LS(L, tangibles, ntmap, tab);
LS.rawget(tangibles, LuaRegistry, "tangibles");
LS.rawget(ntmap, LuaRegistry, "ntmap");
assert(LS.istable(tangibles));
assert(LS.istable(ntmap));
int nmodified = sb->read_int32();
for (int i = 0; i < nmodified; i++) {
int64_t id = sb->read_int64();
LS.rawgeti(tab, tangibles, id);
assert(LS.istable(tab));
patch_table(LS, tangibles, ntmap, tab, sb);
}
LS.result();
}
LuaDefine(table_diffcompare, "c") {
LuaArg mtnmap, mtab, mstnmap, mstab, stnmap, stab;
LuaRet dbgstring;