summaryrefslogtreecommitdiff
path: root/core/io/multiplayer_replicator.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-08-26 13:35:33 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-08-26 13:35:33 +0100
commit2d2855cd53a6818e258e8ddebc38049fd87726ee (patch)
treea6f9132dd04b0e00e6a55aa379b3308e10bd01ae /core/io/multiplayer_replicator.cpp
parentb05cb0fd7d7e4a195359d258fabe33d76976a7a9 (diff)
Data structure optimizations as per review.
Diffstat (limited to 'core/io/multiplayer_replicator.cpp')
-rw-r--r--core/io/multiplayer_replicator.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/io/multiplayer_replicator.cpp b/core/io/multiplayer_replicator.cpp
index 87c3cc4abc..1642aab136 100644
--- a/core/io/multiplayer_replicator.cpp
+++ b/core/io/multiplayer_replicator.cpp
@@ -341,8 +341,10 @@ void MultiplayerReplicator::process_sync(int p_from, const uint8_t *p_packet, in
if (cfg.on_sync_receive.is_valid()) {
Array objs;
if (tracked_objects.has(id)) {
+ objs.resize(tracked_objects[id].size());
+ int idx = 0;
for (const ObjectID &obj_id : tracked_objects[id]) {
- objs.push_back(ObjectDB::get_instance(obj_id));
+ objs[idx++] = ObjectDB::get_instance(obj_id);
}
}
PackedByteArray pba;
@@ -717,8 +719,10 @@ Error MultiplayerReplicator::sync_all(const ResourceUID::ID &p_scene_id, int p_p
if (cfg.on_sync_send.is_valid()) {
Array objs;
if (tracked_objects.has(p_scene_id)) {
+ objs.resize(tracked_objects[p_scene_id].size());
+ int idx = 0;
for (const ObjectID &obj_id : tracked_objects[p_scene_id]) {
- objs.push_back(ObjectDB::get_instance(obj_id));
+ objs[idx++] = ObjectDB::get_instance(obj_id);
}
}
Variant args[3] = { p_scene_id, objs, p_peer };