Redesign of animation queue for unreal, add get_tangibles_near to drivenengine

This commit is contained in:
2023-07-24 17:19:25 -04:00
parent 4da86e6f89
commit 87aa47b96d
19 changed files with 1406 additions and 980 deletions

View File

@@ -3,9 +3,10 @@
#include "serializelua.hpp"
util::IdVector World::get_visible_union(int64_t actor_id, World *master) {
return util::sort_union_id_vectors(
master->get_near(actor_id, RadiusVisibility, true, false, false),
get_near(actor_id, RadiusVisibility, true, false, false));
util::IdVector v1, v2;
master->get_near(actor_id, RadiusVisibility, true, false, false, &v1);
get_near(actor_id, RadiusVisibility, true, false, false, &v2);
return util::sort_union_id_vectors(v1, v2);
}
int64_t World::patch_actor(StreamBuffer *sb, DebugCollector *dbc) {
@@ -14,7 +15,7 @@ int64_t World::patch_actor(StreamBuffer *sb, DebugCollector *dbc) {
Tangible *s_actor = tangible_get(actor_id);
if (s_actor == nullptr) {
DebugLine(dbc) << "create new actor " << actor_id;
s_actor = tangible_make(actor_id, "");
s_actor = tangible_make(actor_id);
s_actor->id_player_pool_.deserialize(sb);
s_actor->anim_queue_.deserialize(sb);
s_actor->print_buffer_.deserialize(sb);
@@ -61,7 +62,7 @@ void World::patch_visible(StreamBuffer *sb, DebugCollector *dbc) {
for (int i = 0; i < count; i++) {
int64_t id = sb->read_int64();
DebugLine(dbc) << "patch_visible create tan " << id;
Tangible *t = tangible_make(id, "");
Tangible *t = tangible_make(id);
t->anim_queue_.deserialize(sb);
t->update_plane_item();
}
@@ -162,7 +163,6 @@ void World::diff_visible(const util::IdVector &visible, World *master,
s_tan = tangible_get(m_tan->id());
assert(s_tan != nullptr);
}
s_tan->anim_queue_.update_version(m_tan->anim_queue_);
}
}
}
@@ -172,8 +172,8 @@ void World::patch_luatabs(StreamBuffer *sb, DebugCollector *dbc) {
int64_t actor_id = sb->read_int64();
util::HashValue closehash = sb->read_hashvalue();
int ncreate = sb->read_int32();
util::IdVector closetans =
get_near(actor_id, RadiusClose, true, false, true);
util::IdVector closetans;
get_near(actor_id, RadiusClose, true, false, true, &closetans);
assert(closehash == util::hash_id_vector(closetans));
number_lua_tables(closetans);
create_new_tables(ncreate);
@@ -188,22 +188,23 @@ void World::diff_luatabs(int64_t actor_id, World *master, StreamBuffer *xsb) {
StreamBuffer tsb;
// Calculate the set of close tangibles.
util::IdVector closetans =
master->get_near(actor_id, RadiusClose, true, false, true);
assert(get_near(actor_id, RadiusClose, true, false, true) == closetans);
util::HashValue closehash = util::hash_id_vector(closetans);
util::IdVector mclosetans, sclosetans;
master->get_near(actor_id, RadiusClose, true, false, true, &mclosetans);
get_near(actor_id, RadiusClose, true, false, true, &sclosetans);
assert(mclosetans == sclosetans);
util::HashValue closehash = util::hash_id_vector(mclosetans);
// Number and pair tables in the synchronous and master model.
number_lua_tables(closetans);
pair_lua_tables(closetans, master->state());
int ncreate = number_remaining_tables(closetans, master->state());
number_lua_tables(mclosetans);
pair_lua_tables(mclosetans, master->state());
int ncreate = number_remaining_tables(mclosetans, master->state());
create_new_tables(ncreate);
// Difference transmit.
tsb.write_int64(actor_id);
tsb.write_hashvalue(closehash);
tsb.write_int32(ncreate);
diff_tangible_databases(closetans, master->state(), &tsb);
diff_tangible_databases(mclosetans, master->state(), &tsb);
diff_numbered_tables(master->state(), &tsb);
// Forward to client, and apply to server-synchronous.
@@ -257,8 +258,8 @@ void World::diff_tanclass(int64_t actor_id, World *master, StreamBuffer *xsb) {
// 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);
util::IdVector closetans;
master->get_near(actor_id, RadiusClose, true, false, true, &closetans);
tsb.write_int32(0);
int write_count_after = tsb.total_writes();