From 7de28be76479796691730dcdc8c121543c5c9681 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 31 Aug 2018 03:22:41 +0200 Subject: ENet wrapper properly detect disconnect on poll Now PacketPeerUDP.get_available_packet_count() return -1 if the socket is in error state. --- thirdparty/enet/godot.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'thirdparty/enet') diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp index 7813b70286..177848f96b 100644 --- a/thirdparty/enet/godot.cpp +++ b/thirdparty/enet/godot.cpp @@ -168,8 +168,9 @@ int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buf PacketPeerUDP *sock = (PacketPeerUDP *)socket; - if (sock->get_available_packet_count() == 0) { - return 0; + int pc = sock->get_available_packet_count(); + if (pc < 1) { + return pc; } const uint8_t *buffer; -- cgit v1.2.3