summaryrefslogtreecommitdiff
path: root/modules/multiplayer
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-09-30 17:44:19 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-09-30 17:44:19 +0200
commit539d21318f3a3a676993187c7f6647cba39dba96 (patch)
treec8407add409c9be0436e24e7120252d682a7ebf5 /modules/multiplayer
parent6f75b0d79be521cf0d64ec8968c0a465e365a038 (diff)
parenta6c201fa76a2037dd8a7dadb48a824167f0726f9 (diff)
Merge pull request #65970 from GuilhermeGSousa/synchronizer-auth-change
Add warning for synchronizer authority mismatch
Diffstat (limited to 'modules/multiplayer')
-rw-r--r--modules/multiplayer/scene_replication_interface.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/multiplayer/scene_replication_interface.cpp b/modules/multiplayer/scene_replication_interface.cpp
index 6e3dbfab47..53d8e82dfc 100644
--- a/modules/multiplayer/scene_replication_interface.cpp
+++ b/modules/multiplayer/scene_replication_interface.cpp
@@ -125,9 +125,12 @@ Error SceneReplicationInterface::on_replication_start(Object *p_obj, Variant p_c
MultiplayerSynchronizer *sync = Object::cast_to<MultiplayerSynchronizer>(p_config.get_validated_object());
ERR_FAIL_COND_V(!sync, ERR_INVALID_PARAMETER);
+ const ObjectID oid = node->get_instance_id();
+ MultiplayerSpawner *spawner = rep_state->get_spawner(oid);
+ ERR_FAIL_COND_V_MSG(spawner && spawner->get_multiplayer_authority() != sync->get_multiplayer_authority(), ERR_INVALID_PARAMETER, "The authority of the MultiplayerSynchronizer \"" + String(sync->get_path()) + "\" differs from the authority of its \"root_node\" spawner and will not sync. Change the \"root_node\" of the MultiplayerSynchronizer to be a child of the scene root instead.");
+
// Add to synchronizer list and setup visibility.
rep_state->config_add_sync(node, sync);
- const ObjectID oid = node->get_instance_id();
sync->connect("visibility_changed", callable_mp(this, &SceneReplicationInterface::_visibility_changed).bind(oid));
if (multiplayer->has_multiplayer_peer() && sync->is_multiplayer_authority()) {
_update_sync_visibility(0, oid);