Skip to content
0.2.0-dev Download ZIP
92 lines ·3.3 KB Raw
1diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h
2index 3001018763..ccd8382c23 100644
3--- a/thirdparty/enet/enet/enet.h
4+++ b/thirdparty/enet/enet/enet.h
5@@ -10,13 +10,17 @@ extern "C"
6 {
7 #endif
8
9+#include <stdint.h>
10 #include <stdlib.h>
11
12+#if 0
13 #ifdef _WIN32
14 #include "enet/win32.h"
15 #else
16 #include "enet/unix.h"
17 #endif
18+#endif
19+#include "enet/enet_godot.h"
20
21 #include "enet/types.h"
22 #include "enet/protocol.h"
23@@ -87,11 +91,13 @@ typedef enum _ENetSocketShutdown
24 * but not for enet_host_create. Once a server responds to a broadcast, the
25 * address is updated from ENET_HOST_BROADCAST to the server's actual IP address.
26 */
27+#if 0
28 typedef struct _ENetAddress
29 {
30 enet_uint32 host;
31 enet_uint16 port;
32 } ENetAddress;
33+#endif
34
35 /**
36 * Packet flag bit constants.
37@@ -608,6 +614,8 @@ ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t,
38
39 extern size_t enet_protocol_command_size (enet_uint8);
40
41+#include "enet/enet_godot_ext.h"
42+
43 #ifdef __cplusplus
44 }
45 #endif
46diff --git a/thirdparty/enet/host.c b/thirdparty/enet/host.c
47index fff946a392..adb3533cf1 100644
48--- a/thirdparty/enet/host.c
49+++ b/thirdparty/enet/host.c
50@@ -87,7 +87,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
51 host -> commandCount = 0;
52 host -> bufferCount = 0;
53 host -> checksum = NULL;
54- host -> receivedAddress.host = ENET_HOST_ANY;
55+ memset(host -> receivedAddress.host, 0, 16);
56 host -> receivedAddress.port = 0;
57 host -> receivedData = NULL;
58 host -> receivedDataLength = 0;
59diff --git a/thirdparty/enet/protocol.c b/thirdparty/enet/protocol.c
60index 843a719af3..5f18700599 100644
61--- a/thirdparty/enet/protocol.c
62+++ b/thirdparty/enet/protocol.c
63@@ -318,7 +318,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
64 }
65 else
66 if (currentPeer -> state != ENET_PEER_STATE_CONNECTING &&
67- currentPeer -> address.host == host -> receivedAddress.host)
68+ enet_host_equal(currentPeer -> address.host, host -> receivedAddress.host))
69 {
70 if (currentPeer -> address.port == host -> receivedAddress.port &&
71 currentPeer -> connectID == command -> connect.connectID)
72@@ -1043,9 +1043,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
73
74 if (peer -> state == ENET_PEER_STATE_DISCONNECTED ||
75 peer -> state == ENET_PEER_STATE_ZOMBIE ||
76- ((host -> receivedAddress.host != peer -> address.host ||
77- host -> receivedAddress.port != peer -> address.port) &&
78- peer -> address.host != ENET_HOST_BROADCAST) ||
79+ (!enet_host_equal(host -> receivedAddress.host, peer -> address.host) ||
80+ host -> receivedAddress.port != peer -> address.port) ||
81 (peer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID &&
82 sessionID != peer -> incomingSessionID))
83 return 0;
84@@ -1090,7 +1089,7 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
85
86 if (peer != NULL)
87 {
88- peer -> address.host = host -> receivedAddress.host;
89+ enet_address_set_ip(&(peer -> address), host -> receivedAddress.host, 16);
90 peer -> address.port = host -> receivedAddress.port;
91 peer -> incomingDataTotal += host -> receivedDataLength;
92 }