diff_tables and patch_table are working and tested

This commit is contained in:
2021-08-31 20:03:33 -04:00
parent 82f1f69c25
commit 013992400e
10 changed files with 261 additions and 87 deletions

View File

@@ -285,9 +285,9 @@ private:
static void diff_visible_animations(const TanVector &mvis, const TanVector &svis, StreamBuffer *sb);
void patch_visible_animations(StreamBuffer *sb);
// Compare the general tables.
// Compare the numbered general tables.
//
void diff_lua_tables(lua_State *master, StreamBuffer *sb);
void diff_numbered_tables(lua_State *master, StreamBuffer *sb);
// Compare the tangible databases.
//
@@ -298,36 +298,55 @@ public:
//
// Numbering and pairing of lua tables.
//
// The following routines pair up tables in the synchronous
// model with tables in the master model, by assigning matching
// table numbers. This is not one subroutine but several, because
// some of the steps happen on the server, some on the client,
// and so forth.
//
// The goal of these routines is to build these data structures:
//
// Table-to-number mapping is stored in registry.tnmap
// Number-to-table mapping is stored in registry.ntmap
//
///////////////////////////////////////////////////////////
// numbering of tables.
// In the synchronous models, number tables recursively.
//
// Returns the total number of tables numbered.
// This is a simple recursive traversal, which numbers tables.
// This creates the initial ntmap in the synchronous models.
//
int number_lua_tables(const IdVector &basis);
// Deletes registry.tnmap and registry.ntmap
// Pair tables in the master model to tables in the synch model.
//
void unnumber_lua_tables();
// Number tables in the master model to match already-numbered tables in the synch model.
// Recursively walk the master and synchronous model in parallel,
// copying table numbers from the synchronous ntmap into the master's ntmap.
//
void pair_lua_tables(const IdVector &basis, lua_State *master);
// Pairs every not-yet-paired master table to a virtually-created table in the synch model.
// Number previously unpaired tables in the master model.
//
// Returns the number of new tables that need to be created in the synch model.
// This finds every not-yet-numbered table in the master model,
// and appends these tables to the master's ntmap. Once they're
// in the ntmap, they can be paired by simply creating new tables
// in the synchronous model.
//
int pair_new_tables(const IdVector &basis, lua_State *master);
int number_remaining_tables(const IdVector &basis, lua_State *master);
// This is followup for pair_new_tables: actually create the new tables that
// were virtually created in the pair_new_tables step.
// Create new tables in the synchronous models.
//
// Creates new tables in the synchronous model and appends these
// new tables to the synchronous model's ntmap.
//
void create_new_tables(int n);
// Delete the table numbering.
//
// This simply removes registry.tnmap and registry.ntmap
//
void unnumber_lua_tables();
private:
// Type of model
util::WorldType world_type_;