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/websocket/websocket_multiplayer_peer.cpp | |
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/websocket/websocket_multiplayer_peer.cpp')
-rw-r--r-- | modules/websocket/websocket_multiplayer_peer.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index e0462c74a1..fa2fe891a5 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -70,8 +70,9 @@ int WebSocketMultiplayerPeer::_gen_unique_id() const { void WebSocketMultiplayerPeer::_clear() { _peer_map.clear(); - if (_current_packet.data != nullptr) + if (_current_packet.data != nullptr) { memfree(_current_packet.data); + } for (List<Packet>::Element *E = _incoming_packets.front(); E; E = E->next()) { memfree(E->get().data); @@ -193,8 +194,9 @@ void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) { for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) { int32_t id = E->key(); - if (p_peer_id == id) + if (p_peer_id == id) { continue; // Skip the newwly added peer (already confirmed) + } // Send new peer to others _send_sys(get_peer(id), SYS_ADD, p_peer_id); @@ -206,8 +208,9 @@ void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) { void WebSocketMultiplayerPeer::_send_del(int32_t p_peer_id) { for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) { int32_t id = E->key(); - if (p_peer_id != id) + if (p_peer_id != id) { _send_sys(get_peer(id), SYS_DEL, p_peer_id); + } } } @@ -228,15 +231,17 @@ Error WebSocketMultiplayerPeer::_server_relay(int32_t p_from, int32_t p_to, cons } else if (p_to == 0) { for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) { - if (E->key() != p_from) + if (E->key() != p_from) { E->get()->put_packet(p_buffer, p_buffer_size); + } } return OK; // Sent to all but sender } else if (p_to < 0) { for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) { - if (E->key() != p_from && E->key() != -p_to) + if (E->key() != p_from && E->key() != -p_to) { E->get()->put_packet(p_buffer, p_buffer_size); + } } return OK; // Sent to all but sender and excluded @@ -286,8 +291,9 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u } else if (to < 0) { // All but one, for us if not excluded - if (_peer_id != -(int32_t)p_peer_id) + if (_peer_id != -(int32_t)p_peer_id) { _store_pkt(from, to, in_buffer, data_size); + } } // Relay if needed (i.e. "to" includes a peer that is not the server) _server_relay(from, to, in_buffer, size); @@ -308,8 +314,9 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u case SYS_ADD: // Add peer _peer_map[id] = Ref<WebSocketPeer>(); emit_signal("peer_connected", id); - if (id == 1) // We just connected to the server + if (id == 1) { // We just connected to the server emit_signal("connection_succeeded"); + } break; case SYS_DEL: // Remove peer |