diff --git a/CMakeLists.txt b/CMakeLists.txt index e45a6a55af..36a3bb3e7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ project(dolphin-emu) option(USE_EGL "Enables EGL OpenGL Interface" OFF) option(TRY_X11 "Enables X11 Support" ON) +option(USE_SHARED_ENET "Use shared libenet if found rather than Dolphin's soon-to-compatibly-diverge version" OFF) option(USE_UPNP "Enables UPnP port mapping support" ON) option(DISABLE_WX "Disable wxWidgets (use Qt or CLI interface)" OFF) option(ENABLE_QT "Enable Qt (use the experimental Qt interface)" OFF) @@ -246,12 +247,6 @@ if(APPLE) set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};/usr") endif() - # Some of our code contains Objective C constructs. - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c -stdlib=libc++") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -stdlib=libc++") - # Avoid mistaking an object file for a source file on the link command line. - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -x none") - # Identify the target system: # Ask for 64-bit binary. set(TARGET_FLAGS "-arch x86_64") @@ -395,7 +390,7 @@ if(NOT ANDROID) message("ALSA NOT found, disabling ALSA sound backend") endif(ALSA_FOUND) - check_lib(AO ao QUIET) + check_lib(AO ao ao QUIET) if(AO_FOUND) add_definitions(-DHAVE_AO=1) message("ao found, enabling ao sound backend") @@ -404,7 +399,7 @@ if(NOT ANDROID) message("ao NOT found, disabling ao sound backend") endif(AO_FOUND) - check_lib(BLUEZ bluez QUIET) + check_lib(BLUEZ bluez bluez QUIET) if(BLUEZ_FOUND) add_definitions(-DHAVE_BLUEZ=1) message("bluez found, enabling bluetooth support") @@ -413,7 +408,7 @@ if(NOT ANDROID) message("bluez NOT found, disabling bluetooth support") endif(BLUEZ_FOUND) - check_lib(PULSEAUDIO libpulse QUIET) + check_lib(PULSEAUDIO libpulse pulse QUIET) if(PULSEAUDIO_FOUND) add_definitions(-DHAVE_PULSEAUDIO=1) message("PulseAudio found, enabling PulseAudio sound backend") @@ -467,7 +462,7 @@ if(NOT ANDROID) endif() if(USE_X11) - check_lib(XRANDR Xrandr) + check_lib(XRANDR xrandr Xrandr) if(XRANDR_FOUND) add_definitions(-DHAVE_XRANDR=1) else() @@ -507,8 +502,8 @@ if(NOT ANDROID) endif(PORTAUDIO) if(OPROFILING) - check_lib(OPROFILE opagent opagent.h) - check_lib(BFD bfd bfd.h) + check_lib(OPROFILE "(no .pc for opagent)" opagent opagent.h) + check_lib(BFD "(no .pc for bfd)" bfd bfd.h) if(OPROFILE_FOUND AND BFD_FOUND) message("oprofile found, enabling profiling support") add_definitions(-DUSE_OPROFILE=1) @@ -541,11 +536,27 @@ include_directories(Source/Core) add_subdirectory(Externals/Bochs_disasm) include_directories(Externals/Bochs_disasm) -if(NOT APPLE AND NOT ANDROID) - check_lib(ENET enet enet/enet.h QUIET) +if(NOT ANDROID AND USE_SHARED_ENET) + check_lib(ENET libenet enet enet/enet.h QUIET) + include(CheckSymbolExists) + if (ENET_FOUND) + set(CMAKE_REQUIRED_INCLUDES ${ENET_INCLUDE_DIRS}) + # hack: LDFLAGS already contains -lenet but all flags but the first are + # dropped; ugh, cmake + set(CMAKE_REQUIRED_FLAGS ${ENET_LDFLAGS}) + set(CMAKE_REQUIRED_LIBRARIES ${ENET_LIBRARIES}) + CHECK_SYMBOL_EXISTS(enet_socket_get_address enet/enet.h ENET_HAVE_SGA) + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + if (NOT ENET_HAVE_SGA) + # enet is too old + set(ENET_FOUND FALSE) + endif() + endif() endif() if (ENET_FOUND) - message("Using shared enet") + message("Using shared enet") else() message("Using static enet from Externals") include_directories(Externals/enet/include) @@ -576,7 +587,7 @@ else(ZLIB_FOUND) endif(ZLIB_FOUND) if(NOT APPLE AND NOT ANDROID) - check_lib(LZO lzo2 lzo/lzo1x.h QUIET) + check_lib(LZO "(no .pc for lzo2)" lzo2 lzo/lzo1x.h QUIET) endif() if(LZO_FOUND) message("Using shared lzo") @@ -589,7 +600,7 @@ endif() list(APPEND LIBS ${LZO}) if(NOT APPLE AND NOT ANDROID) - check_lib(PNG png png.h QUIET) + check_lib(PNG libpng png png.h QUIET) endif() if (PNG_FOUND) message("Using shared libpng") @@ -602,7 +613,7 @@ endif() if(OPENAL_FOUND) if(NOT APPLE) - check_lib(SOUNDTOUCH SoundTouch soundtouch/SoundTouch.h QUIET) + check_lib(SOUNDTOUCH soundtouch SoundTouch soundtouch/SoundTouch.h QUIET) endif() if (SOUNDTOUCH_FOUND) message("Using shared soundtouch") @@ -687,7 +698,7 @@ else() endif() if(NOT APPLE AND NOT ANDROID) - check_lib(SOIL SOIL SOIL/SOIL.h QUIET) + check_lib(SOIL "(no .pc for SOIL)" SOIL SOIL/SOIL.h QUIET) endif() if(SOIL_FOUND) message("Using shared SOIL") @@ -746,7 +757,7 @@ if(NOT DISABLE_WX AND NOT ANDROID) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_EQUAL 2.8.2 OR "${DIST_NAME}" STREQUAL "natty") - check_lib(GTK2 gtk+-2.0 gtk.h REQUIRED) + check_lib(GTK2 gtk+-2.0 gtk+-2.0 gtk.h REQUIRED) else() include(FindGTK2) if(GTK2_FOUND) @@ -772,8 +783,8 @@ if(NOT DISABLE_WX AND NOT ANDROID) add_definitions(-D__WXGTK__) # Check for required libs - check_lib(GTHREAD2 gthread-2.0 glib/gthread.h REQUIRED) - check_lib(PANGOCAIRO pangocairo pango/pangocairo.h REQUIRED) + check_lib(GTHREAD2 gthread-2.0 gthread-2.0 glib/gthread.h REQUIRED) + check_lib(PANGOCAIRO pangocairo pangocairo pango/pangocairo.h REQUIRED) elseif(WIN32) add_definitions(-D__WXMSW__) else() @@ -844,6 +855,15 @@ add_definitions(-std=gnu++0x) # but some dependencies require them (LLVM, libav). add_definitions(-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS) +# Do this at the last minute because try_compile ignores linker flags. Yay... +if(APPLE) + # Some of our code contains Objective C constructs. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c -stdlib=libc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -stdlib=libc++") + # Avoid mistaking an object file for a source file on the link command line. + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -x none") +endif() + add_subdirectory(Source) @@ -889,4 +909,3 @@ list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}") # CPack must be included after the CPACK_* variables are set in order for those # variables to take effect. Include(CPack) - diff --git a/CMakeTests/CheckLib.cmake b/CMakeTests/CheckLib.cmake index aa8b95b047..caa0d621cd 100644 --- a/CMakeTests/CheckLib.cmake +++ b/CMakeTests/CheckLib.cmake @@ -6,7 +6,7 @@ macro(_internal_message msg) endif() endmacro() -macro(check_lib var lib) +macro(check_lib var pc lib) set(_is_required 0) set(_is_quiet 0) set(_arg_list ${ARGN}) @@ -22,8 +22,7 @@ macro(check_lib var lib) endforeach() if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND) - string(TOLOWER ${lib} lower_lib) - pkg_search_module(${var} QUIET ${lower_lib}) + pkg_search_module(${var} QUIET ${pc}) endif() if(${var}_FOUND) diff --git a/Externals/enet/CMakeLists.txt b/Externals/enet/CMakeLists.txt index 671f59dad9..1fe2f1bbf3 100644 --- a/Externals/enet/CMakeLists.txt +++ b/Externals/enet/CMakeLists.txt @@ -8,6 +8,8 @@ include(CheckStructHasMember) include(CheckTypeSize) check_function_exists("fcntl" HAS_FCNTL) check_function_exists("poll" HAS_POLL) +check_function_exists("getaddrinfo" HAS_GETADDRINFO) +check_function_exists("getnameinfo" HAS_GETNAMEINFO) check_function_exists("gethostbyname_r" HAS_GETHOSTBYNAME_R) check_function_exists("gethostbyaddr_r" HAS_GETHOSTBYADDR_R) check_function_exists("inet_pton" HAS_INET_PTON) @@ -16,13 +18,19 @@ check_struct_has_member("struct msghdr" "msg_flags" "sys/types.h;sys/socket.h" H set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h" "sys/socket.h") check_type_size("socklen_t" HAS_SOCKLEN_T BUILTIN_TYPES_ONLY) unset(CMAKE_EXTRA_INCLUDE_FILES) - + if(HAS_FCNTL) add_definitions(-DHAS_FCNTL=1) endif() if(HAS_POLL) add_definitions(-DHAS_POLL=1) endif() +if(HAS_GETNAMEINFO) + add_definitions(-DHAS_GETNAMEINFO=1) +endif() +if(HAS_GETADDRINFO) + add_definitions(-DHAS_GETADDRINFO=1) +endif() if(HAS_GETHOSTBYNAME_R) add_definitions(-DHAS_GETHOSTBYNAME_R=1) endif() @@ -41,9 +49,9 @@ endif() if(HAS_SOCKLEN_T) add_definitions(-DHAS_SOCKLEN_T=1) endif() - + include_directories(${PROJECT_SOURCE_DIR}/include) - + add_library(enet STATIC callbacks.c compress.c diff --git a/Externals/enet/ChangeLog b/Externals/enet/ChangeLog index 727f853cb5..663c7b731c 100644 --- a/Externals/enet/ChangeLog +++ b/Externals/enet/ChangeLog @@ -1,3 +1,11 @@ +* use getaddrinfo and getnameinfo where available + +ENet 1.3.13 (April 30, 2015): + +* miscellaneous bug fixes +* added premake and cmake support +* miscellaneous documentation cleanups + ENet 1.3.12 (April 24, 2014): * added maximumPacketSize and maximumWaitingData fields to ENetHost to limit the amount of diff --git a/Externals/enet/Doxyfile b/Externals/enet/Doxyfile index e62ffbc596..597ef1af1c 100644 --- a/Externals/enet/Doxyfile +++ b/Externals/enet/Doxyfile @@ -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.12 +PROJECT_NUMBER = v1.3.13 # 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 diff --git a/Externals/enet/Makefile.am b/Externals/enet/Makefile.am index 1e44cfb991..e839463c41 100644 --- a/Externals/enet/Makefile.am +++ b/Externals/enet/Makefile.am @@ -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:0:0 +libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:1:0 AM_CPPFLAGS = -I$(top_srcdir)/include ACLOCAL_AMFLAGS = -Im4 diff --git a/Externals/enet/configure.ac b/Externals/enet/configure.ac index a5a06cf7a9..a4206dbcc3 100644 --- a/Externals/enet/configure.ac +++ b/Externals/enet/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libenet], [1.3.12]) +AC_INIT([libenet], [1.3.13]) AC_CONFIG_SRCDIR([include/enet/enet.h]) AM_INIT_AUTOMAKE([foreign]) @@ -7,6 +7,8 @@ AC_CONFIG_MACRO_DIR([m4]) AC_PROG_CC AC_PROG_LIBTOOL +AC_CHECK_FUNC(getaddrinfo, [AC_DEFINE(HAS_GETADDRINFO)]) +AC_CHECK_FUNC(getnameinfo, [AC_DEFINE(HAS_GETNAMEINFO)]) AC_CHECK_FUNC(gethostbyaddr_r, [AC_DEFINE(HAS_GETHOSTBYADDR_R)]) AC_CHECK_FUNC(gethostbyname_r, [AC_DEFINE(HAS_GETHOSTBYNAME_R)]) AC_CHECK_FUNC(poll, [AC_DEFINE(HAS_POLL)]) diff --git a/Externals/enet/docs/mainpage.dox b/Externals/enet/docs/mainpage.dox index 2c73989f24..7fbbee1d54 100644 --- a/Externals/enet/docs/mainpage.dox +++ b/Externals/enet/docs/mainpage.dox @@ -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.12) can be downloaded here. +The most recent stable release (1.3.13) can be downloaded here. The last release that is protocol compatible with the 1.2 series or earlier (1.2.5) can be downloaded here. You can find the most recent ENet source at the github repository. diff --git a/Externals/enet/enet.dsp b/Externals/enet/enet.dsp index dce4537e5c..285c020cb2 100644 --- a/Externals/enet/enet.dsp +++ b/Externals/enet/enet.dsp @@ -1,168 +1,168 @@ -# Microsoft Developer Studio Project File - Name="enet" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=enet - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "enet.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "enet.mak" CFG="enet - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "enet - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "enet - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "enet - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /W3 /O2 /I "include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "enet - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /MTd /W3 /ZI /Od /I "include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "enet - Win32 Release" -# Name "enet - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\host.c -# End Source File -# Begin Source File - -SOURCE=.\list.c -# End Source File -# Begin Source File - -SOURCE=.\callbacks.c -# End Source File -# Begin Source File - -SOURCE=.\compress.c -# End Source File -# Begin Source File - -SOURCE=.\packet.c -# End Source File -# Begin Source File - -SOURCE=.\peer.c -# End Source File -# Begin Source File - -SOURCE=.\protocol.c -# End Source File -# Begin Source File - -SOURCE=.\unix.c -# End Source File -# Begin Source File - -SOURCE=.\win32.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\include\enet\enet.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\list.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\callbacks.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\protocol.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\time.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\types.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\unix.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\utility.h -# End Source File -# Begin Source File - -SOURCE=.\include\enet\win32.h -# End Source File -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="enet" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=enet - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "enet.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "enet.mak" CFG="enet - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "enet - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "enet - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "enet - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /O2 /I "include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "enet - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /G6 /MTd /W3 /ZI /Od /I "include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "enet - Win32 Release" +# Name "enet - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\host.c +# End Source File +# Begin Source File + +SOURCE=.\list.c +# End Source File +# Begin Source File + +SOURCE=.\callbacks.c +# End Source File +# Begin Source File + +SOURCE=.\compress.c +# End Source File +# Begin Source File + +SOURCE=.\packet.c +# End Source File +# Begin Source File + +SOURCE=.\peer.c +# End Source File +# Begin Source File + +SOURCE=.\protocol.c +# End Source File +# Begin Source File + +SOURCE=.\unix.c +# End Source File +# Begin Source File + +SOURCE=.\win32.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\include\enet\enet.h +# End Source File +# Begin Source File + +SOURCE=.\include\enet\list.h +# End Source File +# Begin Source File + +SOURCE=.\include\enet\callbacks.h +# End Source File +# Begin Source File + +SOURCE=.\include\enet\protocol.h +# End Source File +# Begin Source File + +SOURCE=.\include\enet\time.h +# End Source File +# Begin Source File + +SOURCE=.\include\enet\types.h +# End Source File +# Begin Source File + +SOURCE=.\include\enet\unix.h +# End Source File +# Begin Source File + +SOURCE=.\include\enet\utility.h +# End Source File +# Begin Source File + +SOURCE=.\include\enet\win32.h +# End Source File +# End Group +# End Target +# End Project diff --git a/Externals/enet/include/enet/enet.h b/Externals/enet/include/enet/enet.h index a6f9c0be54..5e21ee8ea9 100644 --- a/Externals/enet/include/enet/enet.h +++ b/Externals/enet/include/enet/enet.h @@ -13,19 +13,19 @@ extern "C" #include #ifdef _WIN32 -#include "win32.h" +#include "enet/win32.h" #else -#include "unix.h" +#include "enet/unix.h" #endif -#include "types.h" -#include "protocol.h" -#include "list.h" -#include "callbacks.h" +#include "enet/types.h" +#include "enet/protocol.h" +#include "enet/list.h" +#include "enet/callbacks.h" #define ENET_VERSION_MAJOR 1 #define ENET_VERSION_MINOR 3 -#define ENET_VERSION_PATCH 12 +#define ENET_VERSION_PATCH 13 #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) diff --git a/Externals/enet/include/enet/protocol.h b/Externals/enet/include/enet/protocol.h index 5a2970e188..f8c73d8a66 100644 --- a/Externals/enet/include/enet/protocol.h +++ b/Externals/enet/include/enet/protocol.h @@ -5,7 +5,7 @@ #ifndef __ENET_PROTOCOL_H__ #define __ENET_PROTOCOL_H__ -#include "types.h" +#include "enet/types.h" enum { diff --git a/Externals/enet/protocol.c b/Externals/enet/protocol.c index 3a7dd3680c..29d648732d 100644 --- a/Externals/enet/protocol.c +++ b/Externals/enet/protocol.c @@ -764,6 +764,10 @@ enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const EN if (peer -> incomingBandwidth == 0 && host -> outgoingBandwidth == 0) peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; + else + if (peer -> incomingBandwidth == 0 || host -> outgoingBandwidth == 0) + peer -> windowSize = (ENET_MAX (peer -> incomingBandwidth, host -> outgoingBandwidth) / + ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; else peer -> windowSize = (ENET_MIN (peer -> incomingBandwidth, host -> outgoingBandwidth) / ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; @@ -1486,7 +1490,7 @@ enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer) ! (outgoingCommand -> reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) && (channel -> reliableWindows [(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE || channel -> usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) | - (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOW_SIZE - reliableWindow))))) + (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOWS - reliableWindow))))) windowWrap = 1; if (windowWrap) { diff --git a/Externals/enet/unix.c b/Externals/enet/unix.c index 19ee76f34e..90e55b146b 100644 --- a/Externals/enet/unix.c +++ b/Externals/enet/unix.c @@ -38,6 +38,12 @@ #ifndef HAS_SOCKLEN_T #define HAS_SOCKLEN_T 1 #endif +#ifndef HAS_GETADDRINFO +#define HAS_GETADDRINFO 1 +#endif +#ifndef HAS_GETNAMEINFO +#define HAS_GETNAMEINFO 1 +#endif #endif #ifdef HAS_FCNTL @@ -98,6 +104,32 @@ enet_time_set (enet_uint32 newTimeBase) int enet_address_set_host (ENetAddress * address, const char * name) { +#ifdef HAS_GETADDRINFO + struct addrinfo hints, * resultList = NULL, * result = NULL; + + memset (& hints, 0, sizeof (hints)); + hints.ai_family = AF_INET; + + if (getaddrinfo (name, NULL, NULL, & resultList) != 0) + return -1; + + for (result = resultList; result != NULL; result = result -> ai_next) + { + if (result -> ai_family == AF_INET && result -> ai_addr != NULL && result -> ai_addrlen >= sizeof (struct sockaddr_in)) + { + struct sockaddr_in * sin = (struct sockaddr_in *) result -> ai_addr; + + address -> host = sin -> sin_addr.s_addr; + + freeaddrinfo (resultList); + + return 0; + } + } + + if (resultList != NULL) + freeaddrinfo (resultList); +#else struct hostent * hostEntry = NULL; #ifdef HAS_GETHOSTBYNAME_R struct hostent hostData; @@ -113,19 +145,20 @@ enet_address_set_host (ENetAddress * address, const char * name) hostEntry = gethostbyname (name); #endif - if (hostEntry == NULL || - hostEntry -> h_addrtype != AF_INET) + if (hostEntry != NULL && hostEntry -> h_addrtype == AF_INET) { -#ifdef HAS_INET_PTON - if (! inet_pton (AF_INET, name, & address -> host)) -#else - if (! inet_aton (name, (struct in_addr *) & address -> host)) -#endif - return -1; + address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0]; + return 0; } +#endif - address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0]; +#ifdef HAS_INET_PTON + if (! inet_pton (AF_INET, name, & address -> host)) +#else + if (! inet_aton (name, (struct in_addr *) & address -> host)) +#endif + return -1; return 0; } @@ -153,6 +186,26 @@ enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameL int enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength) { +#ifdef HAS_GETNAMEINFO + struct sockaddr_in sin; + int err; + + memset (& sin, 0, sizeof (struct sockaddr_in)); + + sin.sin_family = AF_INET; + sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); + sin.sin_addr.s_addr = address -> host; + + err = getnameinfo ((struct sockaddr *) & sin, sizeof (sin), name, nameLength, NULL, 0, NI_NAMEREQD); + if (! err) + { + if (name != NULL && nameLength > 0 && ! memchr (name, '\0', nameLength)) + return -1; + return 0; + } + if (err != EAI_NONAME) + return 0; +#else struct in_addr in; struct hostent * hostEntry = NULL; #ifdef HAS_GETHOSTBYADDR_R @@ -173,17 +226,17 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET); #endif - if (hostEntry == NULL) - return enet_address_get_host_ip (address, name, nameLength); - else + if (hostEntry != NULL) { size_t hostLen = strlen (hostEntry -> h_name); if (hostLen >= nameLength) return -1; memcpy (name, hostEntry -> h_name, hostLen + 1); + return 0; } +#endif - return 0; + return enet_address_get_host_ip (address, name, nameLength); } int