Fix a bug in synchronous model similarity
This commit is contained in:
@@ -1,8 +1,46 @@
|
||||
#include "luastack.hpp"
|
||||
#include "globaldb.hpp"
|
||||
|
||||
LuaDefine(global_once, "string", "for a given string, returns true exactly once") {
|
||||
LuaArg name;
|
||||
LuaRet flag;
|
||||
LuaVar oncedb, val;
|
||||
LuaStack LS(L, name, flag, oncedb, val);
|
||||
|
||||
LuaDefine(global, "globalname", "get a table where global data can be stored") {
|
||||
// Get a pointer to the oncedb.
|
||||
LS.rawget(oncedb, LuaRegistry, "oncedb");
|
||||
if (!LS.istable(oncedb)) {
|
||||
LS.set(flag, false);
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LS.checkstring(name);
|
||||
LS.rawget(val, oncedb, name);
|
||||
if (!LS.isnil(val)) {
|
||||
LS.set(flag, false);
|
||||
return LS.result();
|
||||
}
|
||||
LS.rawset(oncedb, name, true);
|
||||
LS.set(flag, true);
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(global_clearonce, "name", "reset the specified once-flag") {
|
||||
LuaArg name;
|
||||
LuaVar oncedb;
|
||||
LuaStack LS(L, name, oncedb);
|
||||
|
||||
// Get a pointer to the oncedb.
|
||||
LS.rawget(oncedb, LuaRegistry, "oncedb");
|
||||
if (!LS.istable(oncedb)) {
|
||||
return LS.result();
|
||||
}
|
||||
LS.checkstring(name);
|
||||
LS.rawset(oncedb, name, LuaNil);
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(global_table, "globalname", "get a table where global data can be stored") {
|
||||
LuaArg globalname;
|
||||
LuaRet globaltab;
|
||||
LuaVar globaldb;
|
||||
|
||||
@@ -28,14 +28,6 @@
|
||||
|
||||
#include "luastack.hpp"
|
||||
|
||||
// The lua 'global' operator.
|
||||
//
|
||||
// Given a global name, returns a table for that global.
|
||||
//
|
||||
// If you haven't enabled the global DB using globaldb_enable, this
|
||||
// raises a donotpredict error.
|
||||
//
|
||||
int globaldb_global(lua_State *L);
|
||||
|
||||
#endif // GLOBALDB_HPP
|
||||
|
||||
|
||||
@@ -24,18 +24,15 @@ public:
|
||||
// Create the world model.
|
||||
world_.reset(new World(util::WORLD_TYPE_C_SYNC));
|
||||
|
||||
// Snapshot the initial state.
|
||||
world_->snapshot();
|
||||
|
||||
// Clear the unack command queue.
|
||||
unack_.clear();
|
||||
|
||||
// This is a temporary actor that will be used only until the server sends
|
||||
// us the first difference transmission. We do this only to establish
|
||||
// the invariant that there's always an actor. When the first difference
|
||||
// transmission arrives, this actor may be deleted, or it may just be
|
||||
// ignored, at the server's discretion.
|
||||
actor_id_ = world_->create_login_actor();
|
||||
|
||||
// Clear the unack command queue.
|
||||
unack_.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,9 +61,10 @@ World::World(util::WorldType wt) {
|
||||
// Create the tangibles table in the registry.
|
||||
LS.rawset(LuaRegistry, "tangibles", LuaNewTable);
|
||||
|
||||
// Create the globaldb in the registry.
|
||||
// Create the globaldb and oncedb in the registry.
|
||||
if (util::world_type_authoritative(wt)) {
|
||||
LS.rawset(LuaRegistry, "globaldb", LuaNewTable);
|
||||
LS.rawset(LuaRegistry, "oncedb", LuaNewTable);
|
||||
}
|
||||
|
||||
// Initialize the SourceDB. At this stage, the sourcedb is
|
||||
|
||||
@@ -169,6 +169,7 @@ void World::patch_luatabs(StreamBuffer *sb, DebugCollector *dbc) {
|
||||
util::HashValue closehash = sb->read_hashvalue();
|
||||
int ncreate = sb->read_int32();
|
||||
util::IdVector closetans = get_near(actor_id, RadiusClose, true, false);
|
||||
std::cerr << "Sync closetans=" << util::id_vector_debug_string(closetans) << std::endl;
|
||||
assert(closehash == util::hash_id_vector(closetans));
|
||||
number_lua_tables(closetans);
|
||||
create_new_tables(ncreate);
|
||||
@@ -183,6 +184,7 @@ void World::diff_luatabs(int64_t actor_id, World *master, StreamBuffer *xsb) {
|
||||
|
||||
// Calculate the set of close tangibles.
|
||||
util::IdVector closetans = master->get_near(actor_id, RadiusClose, true, false);
|
||||
std::cerr << "Master closetans=" << util::id_vector_debug_string(closetans) << std::endl;
|
||||
assert(get_near(actor_id, RadiusClose, true, false) == closetans);
|
||||
util::HashValue closehash = util::hash_id_vector(closetans);
|
||||
|
||||
@@ -281,6 +283,7 @@ void World::diff_tanclass(int64_t actor_id, World *master, StreamBuffer *xsb) {
|
||||
|
||||
void World::patch_source(StreamBuffer *sb, DebugCollector *dbc) {
|
||||
DebugBlock dbb(dbc, "patch_source");
|
||||
std::cerr << "Before PS ids=" << tangible_ids_debug_string() << std::endl;
|
||||
bool modified = source_db_.patch(sb, dbc);
|
||||
if (modified) {
|
||||
std::string errs = source_db_.rebuild();
|
||||
@@ -288,6 +291,7 @@ void World::patch_source(StreamBuffer *sb, DebugCollector *dbc) {
|
||||
// TODO: I don't currently have any good place to send the
|
||||
// error messages. This is a stopgap.
|
||||
std::cerr << errs;
|
||||
std::cerr << "After PS ids=" << tangible_ids_debug_string() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user