Skip to content

Commit

Permalink
Merge pull request #35408 from Faless/ws/fix_packet_count
Browse files Browse the repository at this point in the history
Fix MultiplayerAPI crash when peer implementation misbehave.
  • Loading branch information
akien-mga committed Jan 21, 2020
2 parents 24960e2 + 50f1b03 commit 79aaafc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/io/multiplayer_api.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion modules/websocket/websocket_multiplayer_peer.cpp
Expand Up @@ -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();
}
Expand Down

0 comments on commit 79aaafc

Please sign in to comment.