diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:41:43 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 21:57:34 +0200 |
commit | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (patch) | |
tree | 198d4ff7665d89307f6ca2469fa38620a9eb1672 /modules/webrtc | |
parent | 07bc4e2f96f8f47991339654ff4ab16acc19d44f (diff) |
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
Diffstat (limited to 'modules/webrtc')
-rw-r--r-- | modules/webrtc/webrtc_multiplayer.cpp | 32 | ||||
-rw-r--r-- | modules/webrtc/webrtc_multiplayer.h | 3 | ||||
-rw-r--r-- | modules/webrtc/webrtc_peer_connection.cpp | 3 |
3 files changed, 25 insertions, 13 deletions
diff --git a/modules/webrtc/webrtc_multiplayer.cpp b/modules/webrtc/webrtc_multiplayer.cpp index 72115628ed..e0c0cad68c 100644 --- a/modules/webrtc/webrtc_multiplayer.cpp +++ b/modules/webrtc/webrtc_multiplayer.cpp @@ -65,8 +65,9 @@ bool WebRTCMultiplayer::is_server() const { } void WebRTCMultiplayer::poll() { - if (peer_map.size() == 0) + if (peer_map.size() == 0) { return; + } List<int> remove; List<int> add; @@ -113,15 +114,17 @@ void WebRTCMultiplayer::poll() { // Remove disconnected peers for (List<int>::Element *E = remove.front(); E; E = E->next()) { remove_peer(E->get()); - if (next_packet_peer == E->get()) + if (next_packet_peer == E->get()) { next_packet_peer = 0; + } } // Signal newly connected peers for (List<int>::Element *E = add.front(); E; E = E->next()) { // Already connected to server: simply notify new peer. // NOTE: Mesh is always connected. - if (connection_status == CONNECTION_CONNECTED) + if (connection_status == CONNECTION_CONNECTED) { emit_signal("peer_connected", E->get()); + } // Server emulation mode suppresses peer_conencted until server connects. if (server_compat && E->get() == TARGET_PEER_SERVER) { @@ -131,21 +134,24 @@ void WebRTCMultiplayer::poll() { emit_signal("connection_succeeded"); // Notify of all previously connected peers for (Map<int, Ref<ConnectedPeer>>::Element *F = peer_map.front(); F; F = F->next()) { - if (F->key() != 1 && F->get()->connected) + if (F->key() != 1 && F->get()->connected) { emit_signal("peer_connected", F->key()); + } } break; // Because we already notified of all newly added peers. } } // Fetch next packet - if (next_packet_peer == 0) + if (next_packet_peer == 0) { _find_next_peer(); + } } void WebRTCMultiplayer::_find_next_peer() { Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.find(next_packet_peer); - if (E) + if (E) { E = E->next(); + } // After last. while (E) { for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) { @@ -165,8 +171,9 @@ void WebRTCMultiplayer::_find_next_peer() { return; } } - if (E->key() == (int)next_packet_peer) + if (E->key() == (int)next_packet_peer) { break; + } E = E->next(); } // No packet found @@ -191,10 +198,11 @@ Error WebRTCMultiplayer::initialize(int p_self_id, bool p_server_compat) { server_compat = p_server_compat; // Mesh and server are always connected - if (!server_compat || p_self_id == 1) + if (!server_compat || p_self_id == 1) { connection_status = CONNECTION_CONNECTED; - else + } else { connection_status = CONNECTION_CONNECTING; + } return OK; } @@ -332,8 +340,9 @@ Error WebRTCMultiplayer::put_packet(const uint8_t *p_buffer, int p_buffer_size) for (Map<int, Ref<ConnectedPeer>>::Element *F = peer_map.front(); F; F = F->next()) { // Exclude packet. If target_peer == 0 then don't exclude any packets - if (target_peer != 0 && F->key() == exclude) + if (target_peer != 0 && F->key() == exclude) { continue; + } ERR_CONTINUE(F->value()->channels.size() <= ch || !F->value()->channels[ch].is_valid()); F->value()->channels[ch]->put_packet(p_buffer, p_buffer_size); @@ -343,8 +352,9 @@ Error WebRTCMultiplayer::put_packet(const uint8_t *p_buffer, int p_buffer_size) } int WebRTCMultiplayer::get_available_packet_count() const { - if (next_packet_peer == 0) + if (next_packet_peer == 0) { return 0; // To be sure next call to get_packet works if size > 0 . + } int size = 0; for (Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.front(); E; E = E->next()) { for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) { diff --git a/modules/webrtc/webrtc_multiplayer.h b/modules/webrtc/webrtc_multiplayer.h index 876e2c6fe9..906b90a1b6 100644 --- a/modules/webrtc/webrtc_multiplayer.h +++ b/modules/webrtc/webrtc_multiplayer.h @@ -56,8 +56,9 @@ private: ConnectedPeer() { connected = false; - for (int i = 0; i < CH_RESERVED_MAX; i++) + for (int i = 0; i < CH_RESERVED_MAX; i++) { channels.push_front(Ref<WebRTCDataChannel>()); + } } }; diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp index f71dcc956c..670924bca2 100644 --- a/modules/webrtc/webrtc_peer_connection.cpp +++ b/modules/webrtc/webrtc_peer_connection.cpp @@ -37,8 +37,9 @@ Ref<WebRTCPeerConnection> WebRTCPeerConnection::create_ref() { } WebRTCPeerConnection *WebRTCPeerConnection::create() { - if (!_create) + if (!_create) { return nullptr; + } return _create(); } |