Skip to content

Commit

Permalink
Merge pull request #90244 from akien-mga/enet-2024-03
Browse files Browse the repository at this point in the history
enet: Sync with upstream commit c44b7d0
  • Loading branch information
akien-mga committed Apr 5, 2024
2 parents febb11f + 360a1a4 commit 1765f08
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ commits.
## enet

- Upstream: https://github.com/lsalzman/enet
- Version: git (ea4607a90dbfbcf4da2669ea998585253d8e70b1, 2023)
- Version: git (c44b7d0f7ff21edb702745e4c019d0537928c373, 2024)
- License: MIT

Files extracted from upstream source:
Expand Down
16 changes: 8 additions & 8 deletions thirdparty/enet/patches/godot_socket.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h
index fc45cbd0c9..77f8004b80 100644
index 4a207041b3..5232f8a869 100644
--- a/thirdparty/enet/enet/enet.h
+++ b/thirdparty/enet/enet/enet.h
@@ -10,13 +10,19 @@ extern "C"
Expand All @@ -22,7 +22,7 @@ index fc45cbd0c9..77f8004b80 100644

#include "enet/types.h"
#include "enet/protocol.h"
@@ -86,11 +92,15 @@ typedef enum _ENetSocketShutdown
@@ -87,11 +93,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.
*/
Expand All @@ -38,7 +38,7 @@ index fc45cbd0c9..77f8004b80 100644

/**
* Packet flag bit constants.
@@ -604,6 +614,10 @@ ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t,
@@ -608,6 +618,10 @@ ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t,

extern size_t enet_protocol_command_size (enet_uint8);

Expand All @@ -50,7 +50,7 @@ index fc45cbd0c9..77f8004b80 100644
}
#endif
diff --git a/thirdparty/enet/host.c b/thirdparty/enet/host.c
index 3b2180f7fd..21ab27e247 100644
index fff946a392..adb3533cf1 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
Expand All @@ -63,10 +63,10 @@ index 3b2180f7fd..21ab27e247 100644
host -> receivedData = NULL;
host -> receivedDataLength = 0;
diff --git a/thirdparty/enet/protocol.c b/thirdparty/enet/protocol.c
index 9d654f1d96..d7fe80f117 100644
index 843a719af3..5f18700599 100644
--- a/thirdparty/enet/protocol.c
+++ b/thirdparty/enet/protocol.c
@@ -309,7 +309,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
@@ -318,7 +318,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
}
else
if (currentPeer -> state != ENET_PEER_STATE_CONNECTING &&
Expand All @@ -75,7 +75,7 @@ index 9d654f1d96..d7fe80f117 100644
{
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)
@@ -1043,9 +1043,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)

if (peer -> state == ENET_PEER_STATE_DISCONNECTED ||
peer -> state == ENET_PEER_STATE_ZOMBIE ||
Expand All @@ -87,7 +87,7 @@ index 9d654f1d96..d7fe80f117 100644
(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)
@@ -1090,7 +1089,7 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)

if (peer != NULL)
{
Expand Down
16 changes: 11 additions & 5 deletions thirdparty/enet/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,11 +1071,14 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)

if (host -> checksum != NULL)
{
enet_uint32 * checksum = (enet_uint32 *) & host -> receivedData [headerSize - sizeof (enet_uint32)],
desiredChecksum = * checksum;
enet_uint32 * checksum = (enet_uint32 *) & host -> receivedData [headerSize - sizeof (enet_uint32)];
enet_uint32 desiredChecksum, newChecksum;
ENetBuffer buffer;
/* Checksum may be an unaligned pointer, use memcpy to avoid undefined behaviour. */
memcpy (& desiredChecksum, checksum, sizeof (enet_uint32));

* checksum = peer != NULL ? peer -> connectID : 0;
newChecksum = peer != NULL ? peer -> connectID : 0;
memcpy (checksum, & newChecksum, sizeof (enet_uint32));

buffer.data = host -> receivedData;
buffer.dataLength = host -> receivedDataLength;
Expand Down Expand Up @@ -1703,9 +1706,12 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch
if (host -> checksum != NULL)
{
enet_uint32 * checksum = (enet_uint32 *) & headerData [host -> buffers -> dataLength];
* checksum = currentPeer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID ? currentPeer -> connectID : 0;
enet_uint32 newChecksum = currentPeer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID ? currentPeer -> connectID : 0;
/* Checksum may be unaligned, use memcpy to avoid undefined behaviour. */
memcpy(checksum, & newChecksum, sizeof (enet_uint32));
host -> buffers -> dataLength += sizeof (enet_uint32);
* checksum = host -> checksum (host -> buffers, host -> bufferCount);
newChecksum = host -> checksum (host -> buffers, host -> bufferCount);
memcpy(checksum, & newChecksum, sizeof (enet_uint32));
}

if (shouldCompress > 0)
Expand Down

0 comments on commit 1765f08

Please sign in to comment.