diff options
Diffstat (limited to 'modules/webrtc')
-rw-r--r-- | modules/webrtc/webrtc_multiplayer_peer.cpp | 36 | ||||
-rw-r--r-- | modules/webrtc/webrtc_multiplayer_peer.h | 2 |
2 files changed, 19 insertions, 19 deletions
diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp index 0bc42b104c..6f68b84ad3 100644 --- a/modules/webrtc/webrtc_multiplayer_peer.cpp +++ b/modules/webrtc/webrtc_multiplayer_peer.cpp @@ -140,41 +140,41 @@ void WebRTCMultiplayerPeer::poll() { } void WebRTCMultiplayerPeer::_find_next_peer() { - Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.find(next_packet_peer); + HashMap<int, Ref<ConnectedPeer>>::Iterator E = peer_map.find(next_packet_peer); if (E) { - E = E->next(); + ++E; } // After last. while (E) { - if (!E->get()->connected) { - E = E->next(); + if (!E->value->connected) { + ++E; continue; } - for (const Ref<WebRTCDataChannel> &F : E->get()->channels) { + for (const Ref<WebRTCDataChannel> &F : E->value->channels) { if (F->get_available_packet_count()) { - next_packet_peer = E->key(); + next_packet_peer = E->key; return; } } - E = E->next(); + ++E; } - E = peer_map.front(); + E = peer_map.begin(); // Before last while (E) { - if (!E->get()->connected) { - E = E->next(); + if (!E->value->connected) { + ++E; continue; } - for (const Ref<WebRTCDataChannel> &F : E->get()->channels) { + for (const Ref<WebRTCDataChannel> &F : E->value->channels) { if (F->get_available_packet_count()) { - next_packet_peer = E->key(); + next_packet_peer = E->key; return; } } - if (E->key() == (int)next_packet_peer) { + if (E->key == (int)next_packet_peer) { break; } - E = E->next(); + ++E; } // No packet found next_packet_peer = 0; @@ -354,12 +354,12 @@ Error WebRTCMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_si } if (target_peer > 0) { - Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.find(target_peer); + HashMap<int, Ref<ConnectedPeer>>::Iterator E = peer_map.find(target_peer); ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, "Invalid target peer: " + itos(target_peer) + "."); - ERR_FAIL_COND_V_MSG(E->value()->channels.size() <= ch, ERR_INVALID_PARAMETER, vformat("Unable to send packet on channel %d, max channels: %d", ch, E->value()->channels.size())); - ERR_FAIL_COND_V(E->value()->channels[ch].is_null(), ERR_BUG); - return E->value()->channels[ch]->put_packet(p_buffer, p_buffer_size); + ERR_FAIL_COND_V_MSG(E->value->channels.size() <= ch, ERR_INVALID_PARAMETER, vformat("Unable to send packet on channel %d, max channels: %d", ch, E->value->channels.size())); + ERR_FAIL_COND_V(E->value->channels[ch].is_null(), ERR_BUG); + return E->value->channels[ch]->put_packet(p_buffer, p_buffer_size); } else { int exclude = -target_peer; diff --git a/modules/webrtc/webrtc_multiplayer_peer.h b/modules/webrtc/webrtc_multiplayer_peer.h index 6675c67867..97550a3e9d 100644 --- a/modules/webrtc/webrtc_multiplayer_peer.h +++ b/modules/webrtc/webrtc_multiplayer_peer.h @@ -69,7 +69,7 @@ private: int next_packet_peer = 0; bool server_compat = false; - Map<int, Ref<ConnectedPeer>> peer_map; + HashMap<int, Ref<ConnectedPeer>> peer_map; List<Dictionary> channels_config; void _peer_to_dict(Ref<ConnectedPeer> p_connected_peer, Dictionary &r_dict); |