diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2022-07-31 23:14:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-31 23:14:33 +0200 |
commit | faff5e10a52a4f229b02ce274aba25bd552c97b9 (patch) | |
tree | 89bcfa814010e20cdc77bb87ec2840005c7cf44f /modules/multiplayer/scene_replication_interface.cpp | |
parent | 214d0b20b0690721e5eaaca0b73e17fac35f0a14 (diff) | |
parent | b7c5aeca8a996176873a31e9c52950823d14aaae (diff) | |
download | redot-engine-faff5e10a52a4f229b02ce274aba25bd552c97b9.tar.gz |
Merge pull request #63599 from nathanfranke/mp-docs
Document multiplayer replication classes, small changes to MultiplayerSpawner
Diffstat (limited to 'modules/multiplayer/scene_replication_interface.cpp')
-rw-r--r-- | modules/multiplayer/scene_replication_interface.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/multiplayer/scene_replication_interface.cpp b/modules/multiplayer/scene_replication_interface.cpp index c89270fbe8..6e3dbfab47 100644 --- a/modules/multiplayer/scene_replication_interface.cpp +++ b/modules/multiplayer/scene_replication_interface.cpp @@ -396,6 +396,8 @@ Error SceneReplicationInterface::on_spawn_receive(int p_from, const uint8_t *p_b pending_buffer_size = state_len; } parent->add_child(node); + spawner->emit_signal(SNAME("spawned"), node); + pending_spawn = ObjectID(); pending_buffer = nullptr; pending_buffer_size = 0; @@ -411,10 +413,17 @@ Error SceneReplicationInterface::on_despawn_receive(int p_from, const uint8_t *p Error err = rep_state->peer_del_remote(p_from, net_id, &node); ERR_FAIL_COND_V(err != OK, err); ERR_FAIL_COND_V(!node, ERR_BUG); + + MultiplayerSpawner *spawner = rep_state->get_spawner(node->get_instance_id()); + ERR_FAIL_COND_V(!spawner, ERR_DOES_NOT_EXIST); + ERR_FAIL_COND_V(p_from != spawner->get_multiplayer_authority(), ERR_UNAUTHORIZED); + if (node->get_parent() != nullptr) { node->get_parent()->remove_child(node); } node->queue_delete(); + spawner->emit_signal(SNAME("despawned"), node); + return OK; } |