Merge pull request #55953 from Faless/net/3.x_webrtc_mp_connect_fix

This commit is contained in:
Rémi Verschelde 2021-12-15 12:38:17 +01:00 committed by GitHub
commit cefba46d49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -154,6 +154,10 @@ void WebRTCMultiplayer::_find_next_peer() {
}
// After last.
while (E) {
if (!E->get()->connected) {
E = E->next();
continue;
}
for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) {
if (F->get()->get_available_packet_count()) {
next_packet_peer = E->key();
@ -165,6 +169,10 @@ void WebRTCMultiplayer::_find_next_peer() {
E = peer_map.front();
// Before last
while (E) {
if (!E->get()->connected) {
E = E->next();
continue;
}
for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) {
if (F->get()->get_available_packet_count()) {
next_packet_peer = E->key();
@ -357,6 +365,9 @@ int WebRTCMultiplayer::get_available_packet_count() const {
}
int size = 0;
for (Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.front(); E; E = E->next()) {
if (!E->get()->connected) {
continue;
}
for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) {
size += F->get()->get_available_packet_count();
}