summaryrefslogtreecommitdiff
path: root/modules/webrtc
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-03-04 17:58:40 +0100
committerGitHub <noreply@github.com>2022-03-04 17:58:40 +0100
commit0453e7e11507f14b918cc0847ecf88cc93b363f0 (patch)
tree5f35e450d27a6ab822412e02d41713852eff7b7d /modules/webrtc
parent79bbe572449ef64a4e1bdd3ffeb729e2882eb12c (diff)
parent1769f805473142138a5c27570970fe0385897481 (diff)
Merge pull request #58752 from akien-mga/webrtc-fix-put_packet-error
Diffstat (limited to 'modules/webrtc')
-rw-r--r--modules/webrtc/webrtc_multiplayer_peer.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp
index bc3c0d9265..0bc42b104c 100644
--- a/modules/webrtc/webrtc_multiplayer_peer.cpp
+++ b/modules/webrtc/webrtc_multiplayer_peer.cpp
@@ -353,10 +353,8 @@ Error WebRTCMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_si
ch += CH_RESERVED_MAX - 1;
}
- Map<int, Ref<ConnectedPeer>>::Element *E = nullptr;
-
if (target_peer > 0) {
- E = peer_map.find(target_peer);
+ Map<int, Ref<ConnectedPeer>>::Element *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()));
@@ -372,7 +370,7 @@ Error WebRTCMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_si
continue;
}
- ERR_CONTINUE_MSG(F.value->channels.size() <= ch, vformat("Unable to send packet on channel %d, max channels: %d", ch, E->value()->channels.size()));
+ ERR_CONTINUE_MSG(F.value->channels.size() <= ch, vformat("Unable to send packet on channel %d, max channels: %d", ch, F.value->channels.size()));
ERR_CONTINUE(F.value->channels[ch].is_null());
F.value->channels[ch]->put_packet(p_buffer, p_buffer_size);
}