Get rid of more LuaOldStack
This commit is contained in:
@@ -224,7 +224,7 @@ void World::patch_tanclass(StreamBuffer *sb, DebugCollector *dbc) {
|
||||
DebugBlock dbb(dbc, "patch_tanclass");
|
||||
lua_State *L = state();
|
||||
LuaVar tangibles, tab, meta, sclass;
|
||||
LuaOldStack LS(L, tangibles, tab, meta, sclass);
|
||||
LuaExtStack LS(L, tangibles, tab, meta, sclass);
|
||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||
|
||||
int nmodified = sb->read_int32();
|
||||
@@ -242,45 +242,44 @@ void World::patch_tanclass(StreamBuffer *sb, DebugCollector *dbc) {
|
||||
LS.rawset(meta, "__index", sclass);
|
||||
}
|
||||
}
|
||||
LS.result();
|
||||
}
|
||||
|
||||
void World::diff_tanclass(int64_t actor_id, World *master, StreamBuffer *xsb) {
|
||||
StreamBuffer tsb;
|
||||
|
||||
LuaVar stangibles, mtangibles, stab, mtab, smeta, mmeta, sclass, mclass;
|
||||
LuaOldStack SLS(state(), stangibles, stab, smeta, sclass);
|
||||
LuaOldStack MLS(master->state(), mtangibles, mtab, mmeta, mclass);
|
||||
SLS.rawget(stangibles, LuaRegistry, "tangibles");
|
||||
MLS.rawget(mtangibles, LuaRegistry, "tangibles");
|
||||
{
|
||||
LuaVar stangibles, mtangibles, stab, mtab, smeta, mmeta, sclass, mclass;
|
||||
LuaExtStack SLS(state(), stangibles, stab, smeta, sclass);
|
||||
LuaExtStack MLS(master->state(), mtangibles, mtab, mmeta, mclass);
|
||||
SLS.rawget(stangibles, LuaRegistry, "tangibles");
|
||||
MLS.rawget(mtangibles, LuaRegistry, "tangibles");
|
||||
|
||||
// Calculate the set of close tangibles.
|
||||
// TODO: we've already calculated this in an earlier function. This is
|
||||
// wasteful.
|
||||
util::IdVector closetans =
|
||||
master->get_near(actor_id, RadiusClose, true, false, true);
|
||||
// Calculate the set of close tangibles.
|
||||
// TODO: we've already calculated this in an earlier function. This is
|
||||
// wasteful.
|
||||
util::IdVector closetans =
|
||||
master->get_near(actor_id, RadiusClose, true, false, true);
|
||||
|
||||
tsb.write_int32(0);
|
||||
int write_count_after = tsb.total_writes();
|
||||
int nmodified = 0;
|
||||
for (int64_t id : closetans) {
|
||||
MLS.rawget(mtab, mtangibles, id);
|
||||
SLS.rawget(stab, stangibles, id);
|
||||
MLS.getmetatable(mmeta, mtab);
|
||||
SLS.getmetatable(smeta, stab);
|
||||
MLS.rawget(mclass, mmeta, "__index");
|
||||
SLS.rawget(sclass, smeta, "__index");
|
||||
eng::string mname = MLS.classname(mclass);
|
||||
eng::string sname = SLS.classname(sclass);
|
||||
if (mname != sname) {
|
||||
tsb.write_int64(id);
|
||||
tsb.write_string(mname);
|
||||
nmodified += 1;
|
||||
tsb.write_int32(0);
|
||||
int write_count_after = tsb.total_writes();
|
||||
int nmodified = 0;
|
||||
for (int64_t id : closetans) {
|
||||
MLS.rawget(mtab, mtangibles, id);
|
||||
SLS.rawget(stab, stangibles, id);
|
||||
MLS.getmetatable(mmeta, mtab);
|
||||
SLS.getmetatable(smeta, stab);
|
||||
MLS.rawget(mclass, mmeta, "__index");
|
||||
SLS.rawget(sclass, smeta, "__index");
|
||||
eng::string mname = MLS.classname(mclass);
|
||||
eng::string sname = SLS.classname(sclass);
|
||||
if (mname != sname) {
|
||||
tsb.write_int64(id);
|
||||
tsb.write_string(mname);
|
||||
nmodified += 1;
|
||||
}
|
||||
}
|
||||
tsb.overwrite_int32(write_count_after, nmodified);
|
||||
}
|
||||
tsb.overwrite_int32(write_count_after, nmodified);
|
||||
SLS.result();
|
||||
MLS.result();
|
||||
|
||||
// Forward to client, and apply to server-synchronous.
|
||||
tsb.copy_into(xsb);
|
||||
|
||||
Reference in New Issue
Block a user