Path: blob/master/thirdparty/enet/patches/0001-godot-socket.patch
9903 views
diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h1index 3001018763..ccd8382c23 1006442--- a/thirdparty/enet/enet/enet.h3+++ b/thirdparty/enet/enet/enet.h4@@ -10,13 +10,17 @@ extern "C"5{6#endif78+#include <stdint.h>9#include <stdlib.h>1011+#if 012#ifdef _WIN3213#include "enet/win32.h"14#else15#include "enet/unix.h"16#endif17+#endif18+#include "enet/enet_godot.h"1920#include "enet/types.h"21#include "enet/protocol.h"22@@ -87,11 +91,13 @@ typedef enum _ENetSocketShutdown23* but not for enet_host_create. Once a server responds to a broadcast, the24* address is updated from ENET_HOST_BROADCAST to the server's actual IP address.25*/26+#if 027typedef struct _ENetAddress28{29enet_uint32 host;30enet_uint16 port;31} ENetAddress;32+#endif3334/**35* Packet flag bit constants.36@@ -608,6 +614,8 @@ ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t,3738extern size_t enet_protocol_command_size (enet_uint8);3940+#include "enet/enet_godot_ext.h"41+42#ifdef __cplusplus43}44#endif45diff --git a/thirdparty/enet/host.c b/thirdparty/enet/host.c46index fff946a392..adb3533cf1 10064447--- a/thirdparty/enet/host.c48+++ b/thirdparty/enet/host.c49@@ -87,7 +87,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL50host -> commandCount = 0;51host -> bufferCount = 0;52host -> checksum = NULL;53- host -> receivedAddress.host = ENET_HOST_ANY;54+ memset(host -> receivedAddress.host, 0, 16);55host -> receivedAddress.port = 0;56host -> receivedData = NULL;57host -> receivedDataLength = 0;58diff --git a/thirdparty/enet/protocol.c b/thirdparty/enet/protocol.c59index 843a719af3..5f18700599 10064460--- a/thirdparty/enet/protocol.c61+++ b/thirdparty/enet/protocol.c62@@ -318,7 +318,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet63}64else65if (currentPeer -> state != ENET_PEER_STATE_CONNECTING &&66- currentPeer -> address.host == host -> receivedAddress.host)67+ enet_host_equal(currentPeer -> address.host, host -> receivedAddress.host))68{69if (currentPeer -> address.port == host -> receivedAddress.port &&70currentPeer -> connectID == command -> connect.connectID)71@@ -1043,9 +1043,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)7273if (peer -> state == ENET_PEER_STATE_DISCONNECTED ||74peer -> state == ENET_PEER_STATE_ZOMBIE ||75- ((host -> receivedAddress.host != peer -> address.host ||76- host -> receivedAddress.port != peer -> address.port) &&77- peer -> address.host != ENET_HOST_BROADCAST) ||78+ (!enet_host_equal(host -> receivedAddress.host, peer -> address.host) ||79+ host -> receivedAddress.port != peer -> address.port) ||80(peer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID &&81sessionID != peer -> incomingSessionID))82return 0;83@@ -1090,7 +1089,7 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)8485if (peer != NULL)86{87- peer -> address.host = host -> receivedAddress.host;88+ enet_address_set_ip(&(peer -> address), host -> receivedAddress.host, 16);89peer -> address.port = host -> receivedAddress.port;90peer -> incomingDataTotal += host -> receivedDataLength;91}929394