Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11719 from AdmiralCurtiss/enet-update
Update ENet to 8ae0e85298fafdb20777b4eb4241218f52f775b0
  • Loading branch information
delroth committed Apr 4, 2023
2 parents b63b574 + 1e1041f commit c71a4c2
Show file tree
Hide file tree
Showing 24 changed files with 549 additions and 399 deletions.
52 changes: 39 additions & 13 deletions Externals/enet/CMakeLists.txt
Expand Up @@ -8,7 +8,7 @@ include(CheckStructHasMember)
include(CheckTypeSize)

if(HAIKU)
set(CMAKE_REQUIRED_LIBRARIES network)
set(CMAKE_REQUIRED_LIBRARIES network)
endif(HAIKU)

check_function_exists("fcntl" HAS_FCNTL)
Expand All @@ -25,7 +25,7 @@ check_type_size("socklen_t" HAS_SOCKLEN_T BUILTIN_TYPES_ONLY)
unset(CMAKE_EXTRA_INCLUDE_FILES)

if(HAIKU)
unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_LIBRARIES)
endif()

if(HAS_FCNTL)
Expand Down Expand Up @@ -61,18 +61,44 @@ endif()

include_directories(${PROJECT_SOURCE_DIR}/include)

set(INCLUDE_FILES_PREFIX include/enet)
set(INCLUDE_FILES
${INCLUDE_FILES_PREFIX}/callbacks.h
${INCLUDE_FILES_PREFIX}/enet.h
${INCLUDE_FILES_PREFIX}/list.h
${INCLUDE_FILES_PREFIX}/protocol.h
${INCLUDE_FILES_PREFIX}/time.h
${INCLUDE_FILES_PREFIX}/types.h
${INCLUDE_FILES_PREFIX}/unix.h
${INCLUDE_FILES_PREFIX}/utility.h
${INCLUDE_FILES_PREFIX}/win32.h
)

set(SOURCE_FILES
callbacks.c
compress.c
host.c
list.c
packet.c
peer.c
protocol.c
unix.c
win32.c)

source_group(include FILES ${INCLUDE_FILES})
source_group(source FILES ${SOURCE_FILES})

add_library(enet STATIC
callbacks.c
compress.c
host.c
list.c
packet.c
peer.c
protocol.c
unix.c
win32.c
)
${INCLUDE_FILES}
${SOURCE_FILES}
)

dolphin_disable_warnings_msvc(enet)

if (MINGW)
target_link_libraries(enet winmm ws2_32)
endif()

if(HAIKU)
target_link_libraries(enet network)
target_link_libraries(enet network)
endif(HAIKU)
21 changes: 21 additions & 0 deletions Externals/enet/ChangeLog
@@ -1,4 +1,25 @@
ENet 1.3.17 (November 15, 2020):

* fixes for sender getting too far ahead of receiver that can cause instability with reliable packets

ENet 1.3.16 (September 8, 2020):

* fix bug in unreliable fragment queuing
* use single output queue for reliable and unreliable packets for saner ordering
* revert experimental throttle changes that were less stable than prior algorithm

ENet 1.3.15 (April 20, 2020):

* quicker RTT initialization
* use fractional precision for RTT calculations
* fixes for packet throttle with low RTT variance
* miscellaneous socket bug fixes

ENet 1.3.14 (January 27, 2019):

* bug fix for enet_peer_disconnect_later()
* use getaddrinfo and getnameinfo where available
* miscellaneous cleanups

ENet 1.3.13 (April 30, 2015):

Expand Down
2 changes: 1 addition & 1 deletion Externals/enet/Doxyfile
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "ENet"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = v1.3.13
PROJECT_NUMBER = v1.3.17

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion Externals/enet/LICENSE
@@ -1,4 +1,4 @@
Copyright (c) 2002-2015 Lee Salzman
Copyright (c) 2002-2020 Lee Salzman

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion Externals/enet/Makefile.am
Expand Up @@ -16,7 +16,7 @@ enetinclude_HEADERS = \
lib_LTLIBRARIES = libenet.la
libenet_la_SOURCES = callbacks.c compress.c host.c list.c packet.c peer.c protocol.c unix.c win32.c
# see info '(libtool) Updating version info' before making a release
libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:1:0
libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:5:0
AM_CPPFLAGS = -I$(top_srcdir)/include

ACLOCAL_AMFLAGS = -Im4
2 changes: 1 addition & 1 deletion Externals/enet/README
@@ -1,4 +1,4 @@
Please visit the ENet homepage at http://enet.bespin.org for installation
Please visit the ENet homepage at http://sauerbraten.org/enet/ for installation
and usage instructions.

If you obtained this package from github, the quick description on how to build
Expand Down
2 changes: 1 addition & 1 deletion Externals/enet/configure.ac
@@ -1,4 +1,4 @@
AC_INIT([libenet], [1.3.13])
AC_INIT([libenet], [1.3.17])
AC_CONFIG_SRCDIR([include/enet/enet.h])
AM_INIT_AUTOMAKE([foreign])

Expand Down
2 changes: 1 addition & 1 deletion Externals/enet/docs/license.dox
@@ -1,7 +1,7 @@
/**
@page License License

Copyright (c) 2002-2015 Lee Salzman
Copyright (c) 2002-2020 Lee Salzman

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
4 changes: 2 additions & 2 deletions Externals/enet/docs/mainpage.dox
Expand Up @@ -36,7 +36,7 @@ portable, and easily embeddable.
You can retrieve the source to ENet by downloading it in either .tar.gz form
or accessing the github distribution directly.

The most recent stable release (1.3.13) can be downloaded <a class="el" href="download/enet-1.3.13.tar.gz">here</a>.
The most recent stable release (1.3.17) can be downloaded <a class="el" href="download/enet-1.3.17.tar.gz">here</a>.
The last release that is protocol compatible with the 1.2 series or earlier (1.2.5) can be downloaded <a class="el" href="download/enet-1.2.5.tar.gz">here</a>.

You can find the most recent ENet source at <a class="el" href="https://github.com/lsalzman/enet">the github repository</a>.
Expand All @@ -53,7 +53,7 @@ The <a class="el" href="http://lists.cubik.org/mailman/listinfo/enet-discuss">en
/**
@page IRCChannel IRC Channel

Join the \#enet channel on the <a class="el" href="http://freenode.net">freenode IRC network (irc.freenode.net)</a> for real-time discussion about the ENet library.
Join the \#enet channel on the <a class="el" href="https://libera.chat">Libera Chat IRC network (irc.libera.chat)</a> for real-time discussion about the ENet library.

*/

4 changes: 2 additions & 2 deletions Externals/enet/docs/tutorial.dox
Expand Up @@ -102,8 +102,8 @@ may be simultaneously open.
client = enet_host_create (NULL /* create a client host */,
1 /* only allow 1 outgoing connection */,
2 /* allow up 2 channels to be used, 0 and 1 */,
57600 / 8 /* 56K modem with 56 Kbps downstream bandwidth */,
14400 / 8 /* 56K modem with 14 Kbps upstream bandwidth */);
0 /* assume any amount of incoming bandwidth */,
0 /* assume any amount of outgoing bandwidth */);

if (client == NULL)
{
Expand Down
19 changes: 15 additions & 4 deletions Externals/enet/host.c
Expand Up @@ -96,6 +96,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
host -> totalSentPackets = 0;
host -> totalReceivedData = 0;
host -> totalReceivedPackets = 0;
host -> totalQueued = 0;

host -> connectedPeers = 0;
host -> bandwidthLimitedPeers = 0;
Expand Down Expand Up @@ -123,9 +124,8 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL

enet_list_clear (& currentPeer -> acknowledgements);
enet_list_clear (& currentPeer -> sentReliableCommands);
enet_list_clear (& currentPeer -> sentUnreliableCommands);
enet_list_clear (& currentPeer -> outgoingReliableCommands);
enet_list_clear (& currentPeer -> outgoingUnreliableCommands);
enet_list_clear (& currentPeer -> outgoingCommands);
enet_list_clear (& currentPeer -> outgoingSendReliableCommands);
enet_list_clear (& currentPeer -> dispatchedCommands);

enet_peer_reset (currentPeer);
Expand Down Expand Up @@ -161,6 +161,16 @@ enet_host_destroy (ENetHost * host)
enet_free (host);
}

enet_uint32
enet_host_random (ENetHost * host)
{
/* Mulberry32 by Tommy Ettinger */
enet_uint32 n = (host -> randomSeed += 0x6D2B79F5U);
n = (n ^ (n >> 15)) * (n | 1U);
n ^= n + (n ^ (n >> 7)) * (n | 61U);
return n ^ (n >> 14);
}

/** Initiates a connection to a foreign host.
@param host host seeking the connection
@param address destination for the connection
Expand Down Expand Up @@ -200,7 +210,8 @@ enet_host_connect (ENetHost * host, const ENetAddress * address, size_t channelC
currentPeer -> channelCount = channelCount;
currentPeer -> state = ENET_PEER_STATE_CONNECTING;
currentPeer -> address = * address;
currentPeer -> connectID = ++ host -> randomSeed;
currentPeer -> connectID = enet_host_random (host);
currentPeer -> mtu = host -> mtu;

if (host -> outgoingBandwidth == 0)
currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE;
Expand Down
48 changes: 36 additions & 12 deletions Externals/enet/include/enet/enet.h
Expand Up @@ -25,7 +25,7 @@ extern "C"

#define ENET_VERSION_MAJOR 1
#define ENET_VERSION_MINOR 3
#define ENET_VERSION_PATCH 13
#define ENET_VERSION_PATCH 17
#define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
#define ENET_VERSION_GET_MAJOR(version) (((version)>>16)&0xFF)
#define ENET_VERSION_GET_MINOR(version) (((version)>>8)&0xFF)
Expand Down Expand Up @@ -62,7 +62,8 @@ typedef enum _ENetSocketOption
ENET_SOCKOPT_RCVTIMEO = 6,
ENET_SOCKOPT_SNDTIMEO = 7,
ENET_SOCKOPT_ERROR = 8,
ENET_SOCKOPT_NODELAY = 9
ENET_SOCKOPT_NODELAY = 9,
ENET_SOCKOPT_TTL = 10
} ENetSocketOption;

typedef enum _ENetSocketShutdown
Expand Down Expand Up @@ -138,7 +139,11 @@ typedef void (ENET_CALLBACK * ENetPacketFreeCallback) (struct _ENetPacket *);
* (not supported for reliable packets)
*
* ENET_PACKET_FLAG_NO_ALLOCATE - packet will not allocate data, and user must supply it instead
*
* ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT - packet will be fragmented using unreliable
* (instead of reliable) sends if it exceeds the MTU
*
* ENET_PACKET_FLAG_SENT - whether the packet has been sent from all queues it has been entered into
@sa ENetPacketFlag
*/
typedef struct _ENetPacket
Expand All @@ -165,7 +170,7 @@ typedef struct _ENetOutgoingCommand
enet_uint16 unreliableSequenceNumber;
enet_uint32 sentTime;
enet_uint32 roundTripTimeout;
enet_uint32 roundTripTimeoutLimit;
enet_uint32 queueTime;
enet_uint32 fragmentOffset;
enet_uint16 fragmentLength;
enet_uint16 sendAttempts;
Expand Down Expand Up @@ -246,6 +251,12 @@ typedef struct _ENetChannel
ENetList incomingUnreliableCommands;
} ENetChannel;

typedef enum _ENetPeerFlag
{
ENET_PEER_FLAG_NEEDS_DISPATCH = (1 << 0),
ENET_PEER_FLAG_CONTINUE_SENDING = (1 << 1)
} ENetPeerFlag;

/**
* An ENet peer which data packets may be sent or received from.
*
Expand Down Expand Up @@ -303,11 +314,11 @@ typedef struct _ENetPeer
enet_uint16 outgoingReliableSequenceNumber;
ENetList acknowledgements;
ENetList sentReliableCommands;
ENetList sentUnreliableCommands;
ENetList outgoingReliableCommands;
ENetList outgoingUnreliableCommands;
ENetList outgoingSendReliableCommands;
ENetList outgoingCommands;
ENetList dispatchedCommands;
int needsDispatch;
enet_uint16 flags;
enet_uint16 reserved;
enet_uint16 incomingUnsequencedGroup;
enet_uint16 outgoingUnsequencedGroup;
enet_uint32 unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32];
Expand Down Expand Up @@ -366,7 +377,7 @@ typedef struct _ENetHost
size_t channelLimit; /**< maximum number of channels allowed for connected peers */
enet_uint32 serviceTime;
ENetList dispatchQueue;
int continueSending;
enet_uint32 totalQueued;
size_t packetSize;
enet_uint16 headerFlags;
ENetProtocol commands [ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS];
Expand Down Expand Up @@ -405,7 +416,7 @@ typedef enum _ENetEventType
ENET_EVENT_TYPE_CONNECT = 1,

/** a peer has disconnected. This event is generated on a successful
* completion of a disconnect initiated by enet_pper_disconnect, if
* completion of a disconnect initiated by enet_peer_disconnect, if
* a peer has timed out, or if a connection request intialized by
* enet_host_connect has timed out. The peer field contains the peer
* which disconnected. The data field contains user supplied data
Expand Down Expand Up @@ -505,6 +516,17 @@ ENET_API int enet_socketset_select (ENetSocket, ENetSocketSet *, ENetSock
/** @defgroup Address ENet address functions
@{
*/

/** Attempts to parse the printable form of the IP address in the parameter hostName
and sets the host field in the address parameter if successful.
@param address destination to store the parsed IP address
@param hostName IP address to parse
@retval 0 on success
@retval < 0 on failure
@returns the address of the given hostName in address on success
*/
ENET_API int enet_address_set_host_ip (ENetAddress * address, const char * hostName);

/** Attempts to resolve the host named by the parameter hostName and sets
the host field in the address parameter if successful.
@param address destination to store resolved address
Expand Down Expand Up @@ -555,6 +577,7 @@ ENET_API void enet_host_channel_limit (ENetHost *, size_t);
ENET_API void enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32);
extern void enet_host_bandwidth_throttle (ENetHost *);
extern enet_uint32 enet_host_random_seed (void);
extern enet_uint32 enet_host_random (ENetHost *);

ENET_API int enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *);
ENET_API ENetPacket * enet_peer_receive (ENetPeer *, enet_uint8 * channelID);
Expand All @@ -568,12 +591,13 @@ ENET_API void enet_peer_disconnect_later (ENetPeer *, enet_uint32
ENET_API void enet_peer_throttle_configure (ENetPeer *, enet_uint32, enet_uint32, enet_uint32);
extern int enet_peer_throttle (ENetPeer *, enet_uint32);
extern void enet_peer_reset_queues (ENetPeer *);
extern int enet_peer_has_outgoing_commands (ENetPeer *);
extern void enet_peer_setup_outgoing_command (ENetPeer *, ENetOutgoingCommand *);
extern ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32, enet_uint16);
extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, const void *, size_t, enet_uint32, enet_uint32);
extern ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer *, const ENetProtocol *, enet_uint16);
extern void enet_peer_dispatch_incoming_unreliable_commands (ENetPeer *, ENetChannel *);
extern void enet_peer_dispatch_incoming_reliable_commands (ENetPeer *, ENetChannel *);
extern void enet_peer_dispatch_incoming_unreliable_commands (ENetPeer *, ENetChannel *, ENetIncomingCommand *);
extern void enet_peer_dispatch_incoming_reliable_commands (ENetPeer *, ENetChannel *, ENetIncomingCommand *);
extern void enet_peer_on_connect (ENetPeer *);
extern void enet_peer_on_disconnect (ENetPeer *);

Expand Down
1 change: 1 addition & 0 deletions Externals/enet/include/enet/unix.h
Expand Up @@ -9,6 +9,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>

Expand Down
1 change: 1 addition & 0 deletions Externals/enet/include/enet/utility.h
Expand Up @@ -7,6 +7,7 @@

#define ENET_MAX(x, y) ((x) > (y) ? (x) : (y))
#define ENET_MIN(x, y) ((x) < (y) ? (x) : (y))
#define ENET_DIFFERENCE(x, y) ((x) < (y) ? (y) - (x) : (x) - (y))

#endif /* __ENET_UTILITY_H__ */

2 changes: 2 additions & 0 deletions Externals/enet/include/enet/win32.h
Expand Up @@ -11,6 +11,8 @@
#pragma warning (disable: 4244) // 64bit to 32bit int
#pragma warning (disable: 4018) // signed/unsigned mismatch
#pragma warning (disable: 4146) // unary minus operator applied to unsigned type
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#endif
#endif

Expand Down

0 comments on commit c71a4c2

Please sign in to comment.