Spooky hash, smarter animqueue diffs

This commit is contained in:
2021-07-18 17:48:39 -04:00
parent 4357fd647f
commit a39eb4a218
14 changed files with 645 additions and 197 deletions

View File

@@ -26,9 +26,16 @@ World *World::fetch_global_pointer(lua_State *L) {
World::~World() {
}
World::World() {
World::World(util::WorldType wt) {
// Master world model by default.
world_type_ = wt;
// Initialize the ID allocator in master mode.
id_global_pool_.init_master(10);
if (wt == util::WORLD_TYPE_MASTER) {
id_global_pool_.init_master();
} else {
id_global_pool_.init_synch();
}
// Prepare to manipulate the lua state.
LuaVar world;
@@ -47,11 +54,20 @@ World::World() {
source_db_.init(state());
source_db_.rebuild();
// Do standalone initializations.
if (world_type_ == util::WORLD_TYPE_STANDALONE) {
// Load the lua source from disk then rebuild the environment.
source_db_.update();
source_db_.rebuild();
// Run unit tests.
source_db_.run_unittests();
}
LS.result();
assert (lua_gettop(state()) == 0);
assert (stack_is_clear());
}
Tangible::Tangible(World *w, int64_t id) : world_(w), id_player_pool_(&w->id_global_pool_) {
Tangible::Tangible(World *w, int64_t id) : world_(w), anim_queue_(w->world_type_), id_player_pool_(&w->id_global_pool_) {
plane_item_.set_id(id);
plane_item_.track(&w->plane_map_);
}
@@ -72,18 +88,6 @@ void Tangible::deserialize(StreamBuffer *sb) {
update_plane_item();
}
void World::init_standalone() {
assert(stack_is_clear());
// Load the lua source from disk then rebuild the environment.
source_db_.update();
source_db_.rebuild();
// Run unit tests.
source_db_.run_unittests();
assert(stack_is_clear());
}
Tangible *World::tangible_get(int64_t id) {
auto iter = tangibles_.find(id);
@@ -203,7 +207,7 @@ int64_t World::create_login_actor() {
LS.getmetatable(mt, database);
LS.rawset(mt, "__index", classtab);
LS.result();
tan->id_player_pool_.enable_fifo();
tan->configure_id_pool_for_actor();
assert(stack_is_clear());
return tan->id();
}
@@ -597,7 +601,7 @@ LuaDefine(tangible_redirect, "c") {
w->redirects_[tan1->id()] = 0;
} else {
Tangible *tan2 = w->tangible_get(L, actor2.index());
tan2->be_an_actor();
tan2->configure_id_pool_for_actor();
w->redirects_[tan1->id()] = tan2->id();
}
if (bulldoze) {