You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
[MP] Optimize internal SceneReplicationConfig access
Use direct pointer addressing to avoid unnecessary refs/unrefs
This commit is contained in:
@@ -252,9 +252,9 @@ Error SceneReplicationInterface::on_replication_start(Object *p_obj, Variant p_c
|
||||
|
||||
// Try to apply spawn state (before ready).
|
||||
if (pending_buffer_size > 0) {
|
||||
ERR_FAIL_COND_V(!node || sync->get_replication_config().is_null(), ERR_UNCONFIGURED);
|
||||
ERR_FAIL_COND_V(!node || !sync->get_replication_config_ptr(), ERR_UNCONFIGURED);
|
||||
int consumed = 0;
|
||||
const List<NodePath> props = sync->get_replication_config()->get_spawn_properties();
|
||||
const List<NodePath> props = sync->get_replication_config_ptr()->get_spawn_properties();
|
||||
Vector<Variant> vars;
|
||||
vars.resize(props.size());
|
||||
Error err = MultiplayerAPI::decode_and_decompress_variants(vars, pending_buffer, pending_buffer_size, consumed);
|
||||
@@ -498,8 +498,8 @@ Error SceneReplicationInterface::_make_spawn_packet(Node *p_node, MultiplayerSpa
|
||||
continue;
|
||||
}
|
||||
ERR_CONTINUE(!sync);
|
||||
ERR_FAIL_COND_V(sync->get_replication_config().is_null(), ERR_BUG);
|
||||
for (const NodePath &prop : sync->get_replication_config()->get_spawn_properties()) {
|
||||
ERR_FAIL_NULL_V(sync->get_replication_config_ptr(), ERR_BUG);
|
||||
for (const NodePath &prop : sync->get_replication_config_ptr()->get_spawn_properties()) {
|
||||
state_props.push_back(prop);
|
||||
}
|
||||
// Ensure the synchronizer has an ID.
|
||||
@@ -714,7 +714,7 @@ void SceneReplicationInterface::_send_delta(int p_peer, const HashSet<ObjectID>
|
||||
int ofs = 1;
|
||||
for (const ObjectID &oid : p_synchronizers) {
|
||||
MultiplayerSynchronizer *sync = get_id_as<MultiplayerSynchronizer>(oid);
|
||||
ERR_CONTINUE(!sync || !sync->get_replication_config().is_valid() || !_has_authority(sync));
|
||||
ERR_CONTINUE(!sync || !sync->get_replication_config_ptr() || !_has_authority(sync));
|
||||
uint32_t net_id;
|
||||
if (!_verify_synchronizer(p_peer, sync, net_id)) {
|
||||
continue;
|
||||
@@ -809,7 +809,7 @@ void SceneReplicationInterface::_send_sync(int p_peer, const HashSet<ObjectID> p
|
||||
// This is a lazy implementation, we could optimize much more here with by grouping by replication config.
|
||||
for (const ObjectID &oid : p_synchronizers) {
|
||||
MultiplayerSynchronizer *sync = get_id_as<MultiplayerSynchronizer>(oid);
|
||||
ERR_CONTINUE(!sync || !sync->get_replication_config().is_valid() || !_has_authority(sync));
|
||||
ERR_CONTINUE(!sync || !sync->get_replication_config_ptr() || !_has_authority(sync));
|
||||
if (!sync->update_outbound_sync_time(p_usec)) {
|
||||
continue; // nothing to sync.
|
||||
}
|
||||
@@ -824,7 +824,7 @@ void SceneReplicationInterface::_send_sync(int p_peer, const HashSet<ObjectID> p
|
||||
int size;
|
||||
Vector<Variant> vars;
|
||||
Vector<const Variant *> varp;
|
||||
const List<NodePath> props = sync->get_replication_config()->get_sync_properties();
|
||||
const List<NodePath> props = sync->get_replication_config_ptr()->get_sync_properties();
|
||||
Error err = MultiplayerSynchronizer::get_state(props, node, vars, varp);
|
||||
ERR_CONTINUE_MSG(err != OK, "Unable to retrieve sync state.");
|
||||
err = MultiplayerAPI::encode_and_compress_variants(varp.ptrw(), varp.size(), nullptr, size);
|
||||
@@ -883,7 +883,7 @@ Error SceneReplicationInterface::on_sync_receive(int p_from, const uint8_t *p_bu
|
||||
ofs += size;
|
||||
continue;
|
||||
}
|
||||
const List<NodePath> props = sync->get_replication_config()->get_sync_properties();
|
||||
const List<NodePath> props = sync->get_replication_config_ptr()->get_sync_properties();
|
||||
Vector<Variant> vars;
|
||||
vars.resize(props.size());
|
||||
int consumed;
|
||||
|
||||
Reference in New Issue
Block a user