summaryrefslogtreecommitdiffstats
path: root/scene/multiplayer/multiplayer_spawner.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-02-15 18:06:48 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-02-15 18:44:55 +0100
commit0f5455230c8955be0c6533574bd3d5b6f50792b6 (patch)
tree2167f70782174feda2541c163d264c62402b50be /scene/multiplayer/multiplayer_spawner.cpp
parent171021145d49ffdda9110869d35ee63a946af9f8 (diff)
downloadredot-engine-0f5455230c8955be0c6533574bd3d5b6f50792b6.tar.gz
Use `switch` consistently in `_notification` (`scene` folder)
Diffstat (limited to 'scene/multiplayer/multiplayer_spawner.cpp')
-rw-r--r--scene/multiplayer/multiplayer_spawner.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/scene/multiplayer/multiplayer_spawner.cpp b/scene/multiplayer/multiplayer_spawner.cpp
index 4f2a9d9e83..25ab27f3e7 100644
--- a/scene/multiplayer/multiplayer_spawner.cpp
+++ b/scene/multiplayer/multiplayer_spawner.cpp
@@ -84,22 +84,26 @@ void MultiplayerSpawner::_update_spawn_node() {
}
void MultiplayerSpawner::_notification(int p_what) {
- if (p_what == NOTIFICATION_POST_ENTER_TREE) {
- _update_spawn_node();
- } else if (p_what == NOTIFICATION_EXIT_TREE) {
- _update_spawn_node();
- const ObjectID *oid = nullptr;
- while ((oid = tracked_nodes.next(oid))) {
- Node *node = Object::cast_to<Node>(ObjectDB::get_instance(*oid));
- ERR_CONTINUE(!node);
- node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &MultiplayerSpawner::_node_exit));
- // This is unlikely, but might still crash the engine.
- if (node->is_connected(SceneStringNames::get_singleton()->ready, callable_mp(this, &MultiplayerSpawner::_node_ready))) {
- node->disconnect(SceneStringNames::get_singleton()->ready, callable_mp(this, &MultiplayerSpawner::_node_ready));
+ switch (p_what) {
+ case NOTIFICATION_POST_ENTER_TREE: {
+ _update_spawn_node();
+ } break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ _update_spawn_node();
+ const ObjectID *oid = nullptr;
+ while ((oid = tracked_nodes.next(oid))) {
+ Node *node = Object::cast_to<Node>(ObjectDB::get_instance(*oid));
+ ERR_CONTINUE(!node);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &MultiplayerSpawner::_node_exit));
+ // This is unlikely, but might still crash the engine.
+ if (node->is_connected(SceneStringNames::get_singleton()->ready, callable_mp(this, &MultiplayerSpawner::_node_ready))) {
+ node->disconnect(SceneStringNames::get_singleton()->ready, callable_mp(this, &MultiplayerSpawner::_node_ready));
+ }
+ get_multiplayer()->despawn(node, this);
}
- get_multiplayer()->despawn(node, this);
- }
- tracked_nodes.clear();
+ tracked_nodes.clear();
+ } break;
}
}