Fix MultiplayerAPI crash when peer impl misbehave.

Also fix WebSocketMultiplayer::get_available_packet_count() return value
when peer is not configured to use the multiplayer API.
This commit is contained in:
Fabio Alessandrelli 2020-01-21 20:46:32 +01:00
parent 4d052e51a2
commit 50f1b035b8
2 changed files with 2 additions and 1 deletions

View File

@ -111,6 +111,7 @@ void MultiplayerAPI::poll() {
Error err = network_peer->get_packet(&packet, len);
if (err != OK) {
ERR_PRINT("Error getting packet!");
break; // Something is wrong!
}
rpc_sender_id = sender;

View File

@ -98,7 +98,7 @@ void WebSocketMultiplayerPeer::_bind_methods() {
//
int WebSocketMultiplayerPeer::get_available_packet_count() const {
ERR_FAIL_COND_V_MSG(!_is_multiplayer, ERR_UNCONFIGURED, "Please use get_peer(ID).get_available_packet_count to get available packet count from peers when not using the MultiplayerAPI.");
ERR_FAIL_COND_V_MSG(!_is_multiplayer, 0, "Please use get_peer(ID).get_available_packet_count to get available packet count from peers when not using the MultiplayerAPI.");
return _incoming_packets.size();
}