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