diff --git a/pokerth_game.pro b/pokerth_game.pro index 1d8e5d6d..e00fe47b 100644 --- a/pokerth_game.pro +++ b/pokerth_game.pro @@ -209,15 +209,20 @@ TRANSLATIONS = \ win32{ DEPENDPATH += src/net/win32/ src/core/win32 INCLUDEPATH += ../boost/ ../SDL/include ../SDL_mixer + INCLUDEPATH += ../SDL/include/SDL ../SDL_mixer/include LIBPATH += ../boost/stage/lib - debug { - LIBPATH += Debug/lib ../SDL/VisualC/SDL/Debug ../SDL/VisualC/SDLmain/Debug ../SDL_mixer/VisualC/Debug - } - !debug { + + release { LIBPATH += Release/lib ../SDL/VisualC/SDL/Release ../SDL/VisualC/SDLmain/Release ../SDL_mixer/VisualC/Release } - LIBS += pokerth_lib.lib - LIBS += gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib ole32.lib uuid.lib user32.lib msimg32.lib shell32.lib kernel32.lib ws2_32.lib advapi32.lib sdl.lib sdlmain.lib sdl_mixer.lib + !release { + LIBPATH += Debug/lib ../SDL/VisualC/SDL/Debug ../SDL/VisualC/SDLmain/Debug ../SDL_mixer/VisualC/Debug + } + LIBPATH += ../SDL/lib ../SDL_mixer/lib + + LIBS += -lpokerth_lib + LIBS += -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lole32 -luuid -luser32 -lmsimg32 -lshell32 -lkernel32 -lws2_32 -ladvapi32 -lsdl -lsdlmain -lsdl_mixer + LIBS += -lboost_thread-mgw34-mt-1_34_1 RC_FILE = pokerth.rc } !win32{ diff --git a/pokerth_server.pro b/pokerth_server.pro index 1bcee1aa..4ec60bd9 100644 --- a/pokerth_server.pro +++ b/pokerth_server.pro @@ -96,14 +96,17 @@ win32{ DEPENDPATH += src/net/win32/ src/core/win32 INCLUDEPATH += ../boost/ LIBPATH += ../boost/stage/lib - debug { - LIBPATH += Debug/lib - } - !debug { + + release { LIBPATH += Release/lib } - LIBS += pokerth_lib.lib - LIBS += gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib ole32.lib uuid.lib user32.lib msimg32.lib shell32.lib kernel32.lib ws2_32.lib advapi32.lib + !release { + LIBPATH += Debug/lib + } + + LIBS += -lpokerth_lib + LIBS += -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lole32 -luuid -luser32 -lmsimg32 -lshell32 -lkernel32 -lws2_32 -ladvapi32 + LIBS += -lboost_thread-mgw34-mt-1_34_1 } !win32{ DEPENDPATH += src/net/linux/ src/core/linux diff --git a/src/gui/qt/sound/sdlplayer.cpp b/src/gui/qt/sound/sdlplayer.cpp index 0e09f951..557e881e 100644 --- a/src/gui/qt/sound/sdlplayer.cpp +++ b/src/gui/qt/sound/sdlplayer.cpp @@ -11,6 +11,16 @@ // #include "sdlplayer.h" +// Include SDL here and not in headers to prevent +// conflicts with QT includes. +#if (defined _WIN32) || (defined __APPLE__) + #include + #include +#else + #include + #include +#endif + #include using namespace std; @@ -35,10 +45,10 @@ void SDLPlayer::initAudio() { if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { - audio_rate = 44100; - audio_format = AUDIO_S16; /* 16-bit stereo */ - audio_channels = 2; - audio_buffers = 4096; + int audio_rate = 44100; + Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */ + int audio_channels = 2; + int audio_buffers = 4096; sound = NULL; if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) == 0) { diff --git a/src/gui/qt/sound/sdlplayer.h b/src/gui/qt/sound/sdlplayer.h index dc724cba..5a4d6093 100644 --- a/src/gui/qt/sound/sdlplayer.h +++ b/src/gui/qt/sound/sdlplayer.h @@ -14,23 +14,12 @@ #ifndef SDLPLAYER_H #define SDLPLAYER_H -#ifdef _WIN32 - #include - #include -#else - #ifdef __APPLE__ - #include - #include - #else - #include - #include - #endif -#endif - #include #include "configfile.h" #include "qthelper.h" +struct Mix_Chunk; + /** @author FThauer FHammer */ @@ -49,12 +38,8 @@ public: private: - int audio_rate; - Uint16 audio_format; - int audio_channels; - int audio_buffers; Mix_Chunk *sound; - Uint8 *soundData; + unsigned char *soundData; int currentChannel; bool audioEnabled; diff --git a/src/net/common/socket_helper_cmn.cpp b/src/net/common/socket_helper_cmn.cpp index 33afb0e6..230298a4 100644 --- a/src/net/common/socket_helper_cmn.cpp +++ b/src/net/common/socket_helper_cmn.cpp @@ -44,35 +44,3 @@ socket_set_port(unsigned port, int addrFamily, struct sockaddr *addr, int addrLe return retVal; } -bool -internal_socket_resolve(const char *str, const char *port, int addrFamily, int sockType, int protocol, struct sockaddr *addr, int addrLen) -{ - bool retVal = false; - - if (str && *str != 0) - { - struct addrinfo aiHints; - struct addrinfo *aiList = NULL; - - memset(&aiHints, 0, sizeof(aiHints)); - aiHints.ai_family = addrFamily; - aiHints.ai_socktype = sockType; - aiHints.ai_protocol = protocol; - - // Try to resolve the name. - // Will (hopefully) use UTF-8 if called on Linux. - bool success = (getaddrinfo(str, port, &aiHints, &aiList) == 0); - - if (success && aiList) - { - if ((int)aiList->ai_addrlen <= addrLen) - { - memcpy(addr, aiList->ai_addr, aiList->ai_addrlen); - retVal = true; - } - freeaddrinfo(aiList); - } - } - return retVal; -} - diff --git a/src/net/genericsocket.h b/src/net/genericsocket.h index 164e14da..0c8a06bf 100644 --- a/src/net/genericsocket.h +++ b/src/net/genericsocket.h @@ -23,7 +23,6 @@ #ifdef _WIN32 #include #include -#include #else #include #include diff --git a/src/net/linux/socket_helper.cpp b/src/net/linux/socket_helper.cpp index 317df944..32275abe 100644 --- a/src/net/linux/socket_helper.cpp +++ b/src/net/linux/socket_helper.cpp @@ -37,6 +37,32 @@ socket_string_to_addr(const char *str, int addrFamily, struct sockaddr * addr, i bool socket_resolve(const char *str, const char *port, int addrFamily, int sockType, int protocol, struct sockaddr *addr, int addrLen) { - return internal_socket_resolve(str, port, addrFamily, sockType, protocol, addr, addrLen); + bool retVal = false; + + if (str && *str != 0) + { + struct addrinfo aiHints; + struct addrinfo *aiList = NULL; + + memset(&aiHints, 0, sizeof(aiHints)); + aiHints.ai_family = addrFamily; + aiHints.ai_socktype = sockType; + aiHints.ai_protocol = protocol; + + // Try to resolve the name. + // Will (hopefully) use UTF-8 if called on Linux. + bool success = (getaddrinfo(str, port, &aiHints, &aiList) == 0); + + if (success && aiList) + { + if ((int)aiList->ai_addrlen <= addrLen) + { + memcpy(addr, aiList->ai_addr, aiList->ai_addrlen); + retVal = true; + } + freeaddrinfo(aiList); + } + } + return retVal; } diff --git a/src/net/socket_helper.h b/src/net/socket_helper.h index aef409c0..8a9c3617 100644 --- a/src/net/socket_helper.h +++ b/src/net/socket_helper.h @@ -35,10 +35,17 @@ #define SOCKET_ERR_NOTCONN WSAENOTCONN #define SOCKET_ERR_NOTSOCK WSAENOTSOCK -typedef unsigned __int16 u_int16_t; -typedef unsigned __int32 u_int32_t; -typedef __int16 int16_t; -typedef __int32 int32_t; +#ifdef __GNUC__ /* mingw provides stdint.h */ + #include + typedef uint16_t u_int16_t; + typedef uint32_t u_int32_t; +#else + typedef unsigned __int16 u_int16_t; + typedef unsigned __int32 u_int32_t; + typedef __int16 int16_t; + typedef __int32 int32_t; +#endif + typedef unsigned char u_char; #else @@ -87,10 +94,5 @@ bool socket_resolve(const char *str, const char *port, int addrFamily, int sockT */ bool socket_set_port(unsigned port, int addrFamily, struct sockaddr *addr, int addrLen); -/** - * Internal function (common for all OSs). - */ -bool internal_socket_resolve(const char *str, const char *port, int addrFamily, int sockType, int protocol, struct sockaddr *addr, int addrLen); - #endif diff --git a/src/net/win32/socket_helper.cpp b/src/net/win32/socket_helper.cpp index 85943621..b3f79ad5 100644 --- a/src/net/win32/socket_helper.cpp +++ b/src/net/win32/socket_helper.cpp @@ -28,9 +28,8 @@ using namespace std; -typedef int (WSAAPI * getaddrinfow_ptr_t)(const wchar_t *nodename, const wchar_t* servname, - const ADDRINFOW *hints, PADDRINFOW *res); -typedef void (WSAAPI * freeaddrinfow_ptr_t)(PADDRINFOW ai); +typedef int (WSAAPI * getaddrinfo_ptr_t) (const char *, const char* , const struct addrinfo *, struct addrinfo **); +typedef void (WSAAPI * freeaddrinfo_ptr_t) (struct addrinfo*); static wstring utf8ToWchar(const char *str) @@ -78,7 +77,7 @@ bool socket_resolve(const char *str, const char *port, int addrFamily, int sockType, int protocol, struct sockaddr *addr, int addrLen) { bool retVal = false; - bool useUnicodeCall = false; + bool useGetaddrinfo = false; if (str && *str != 0) { @@ -86,28 +85,25 @@ socket_resolve(const char *str, const char *port, int addrFamily, int sockType, if (hWsock) { - // Determine functions at runtime, because some windows systems do not - // support the unicode version of getaddrinfo. - getaddrinfow_ptr_t getaddrinfow_ptr = (getaddrinfow_ptr_t)::GetProcAddress(hWsock, "GetAddrInfoW"); - freeaddrinfow_ptr_t freeaddrinfow_ptr = (freeaddrinfow_ptr_t)::GetProcAddress(hWsock, "FreeAddrInfoW"); + // Determine functions at runtime, because windows systems < XP do not + // support getaddrinfo. + getaddrinfo_ptr_t getaddrinfo_ptr = (getaddrinfo_ptr_t)::GetProcAddress(hWsock, "getaddrinfo"); + freeaddrinfo_ptr_t freeaddrinfo_ptr = (freeaddrinfo_ptr_t)::GetProcAddress(hWsock, "freeaddrinfo"); - if (getaddrinfow_ptr && freeaddrinfow_ptr) + if (getaddrinfo_ptr && freeaddrinfo_ptr) { - useUnicodeCall = true; + useGetaddrinfo = true; - // convert str from UTF-8 to UTF-16 (Win32 byte order) - wstring wstr(utf8ToWchar(str)); - wstring wport(utf8ToWchar(port)); - ADDRINFOW aiHints; - ADDRINFOW *aiList = NULL; + struct addrinfo aiHints; + struct addrinfo *aiList = NULL; memset(&aiHints, 0, sizeof(aiHints)); aiHints.ai_family = addrFamily; aiHints.ai_socktype = sockType; aiHints.ai_protocol = protocol; - // resolve the name (unicode). - bool success = (getaddrinfow_ptr(wstr.c_str(), wport.c_str(), &aiHints, &aiList) == 0); + // Try to resolve the name. + bool success = (getaddrinfo_ptr(str, port, &aiHints, &aiList) == 0); if (success && aiList) { @@ -116,15 +112,22 @@ socket_resolve(const char *str, const char *port, int addrFamily, int sockType, memcpy(addr, aiList->ai_addr, aiList->ai_addrlen); retVal = true; } - freeaddrinfow_ptr(aiList); + freeaddrinfo_ptr(aiList); } } ::FreeLibrary(hWsock); } - // If we cannot use the unicode function (OS older than XP SP 2), - // we call the "classic" getaddrinfo. - if (!useUnicodeCall) - retVal = internal_socket_resolve(str, port, addrFamily, sockType, protocol, addr, addrLen); + // If we cannot use getaddrinfo (OS older than XP), + // we call the "classic" gethostbyname. + if (!useGetaddrinfo && protocol == AF_INET) + { + struct hostent *host = gethostbyname(str); + if (host && host->h_addr_list) + { + memcpy(addr, host->h_addr_list, host->h_length); + retVal = true; + } + } } return retVal; }