From a295b047f002017195468c8604ef2f2d3b9a45ed Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Mon, 3 Jun 2024 17:03:17 +0300 Subject: [PATCH] Fix compilation on Windows --- netcon/includes/con_dll.h | 6 ++++-- netcon/inetfile/Chttpget.cpp | 7 ++++++- netcon/mtclient/CMakeLists.txt | 6 +++--- netcon/mtclient/chat_api.cpp | 2 +- netcon/mtclient/mtclient.cpp | 5 +++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/netcon/includes/con_dll.h b/netcon/includes/con_dll.h index b62b013c..7960b494 100644 --- a/netcon/includes/con_dll.h +++ b/netcon/includes/con_dll.h @@ -620,7 +620,7 @@ typedef void (*dp_EndGame_fp)(); dp_EndGame_fp DLLdp_EndGame; #endif -typedef int (*nw_Asyncgethostbyname_fp)(uint32_t *ip, int command, char *hostname); +typedef int (*nw_Asyncgethostbyname_fp)(uint32_t *ip, int command, const char *hostname); nw_Asyncgethostbyname_fp DLLnw_Asyncgethostbyname; typedef int (*nw_ReccomendPPS_fp)(); @@ -640,7 +640,9 @@ MultiLoadSettings_fp DLLMultiLoadSettings; typedef void *(*NetworkReceiveCallback)(uint8_t *data, int len, network_address *from); -typedef int (*nw_RegisterCallback_fp)(void *nfp, uint8_t id); +typedef void (*HandleGamePacket_fp)(uint8_t *data, int len, network_address *from); + +typedef int (*nw_RegisterCallback_fp)(HandleGamePacket_fp, uint8_t id); nw_RegisterCallback_fp DLLnw_RegisterCallback; typedef NetworkReceiveCallback (*nw_UnRegisterCallback_fp)(uint8_t id); diff --git a/netcon/inetfile/Chttpget.cpp b/netcon/inetfile/Chttpget.cpp index d7331368..fa7f770b 100644 --- a/netcon/inetfile/Chttpget.cpp +++ b/netcon/inetfile/Chttpget.cpp @@ -211,7 +211,12 @@ void ChttpGet::PrepSocket(char *URL) { return; } - make_nonblocking(m_DataSock); +#ifdef WIN32 + unsigned long arg = 1; + ioctlsocket(m_DataSock, FIONBIO, &arg); +#else // WIN32 + fcntl(m_DataSock, F_SETFL, fcntl(m_DataSock, F_GETFL, 0) | O_NONBLOCK); +#endif char *pURL = URL; if (strnicmp(URL, "http:", 5) == 0) { diff --git a/netcon/mtclient/CMakeLists.txt b/netcon/mtclient/CMakeLists.txt index 050b8b09..de21f251 100644 --- a/netcon/mtclient/CMakeLists.txt +++ b/netcon/mtclient/CMakeLists.txt @@ -13,9 +13,9 @@ set_target_properties(Parallax_Online PROPERTIES OUTPUT_NAME "Parallax Online") target_link_libraries(Parallax_Online PRIVATE ddio inetfile -# $<$: -# ws2_32 -# > + $<$: + ws2_32 + > ) add_custom_target(Parallax_Online_Hog diff --git a/netcon/mtclient/chat_api.cpp b/netcon/mtclient/chat_api.cpp index 3bf0373c..2bcace18 100644 --- a/netcon/mtclient/chat_api.cpp +++ b/netcon/mtclient/chat_api.cpp @@ -161,7 +161,7 @@ int ConnectToChatServer(const char *serveraddr, int16_t chat_port, char *nicknam #ifdef WIN32 unsigned long arg = 1; - ioctlsocket(sock, FIONBIO, &arg); + ioctlsocket(Chatsock, FIONBIO, &arg); #else // WIN32 fcntl(Chatsock, F_SETFL, fcntl(Chatsock, F_GETFL, 0) | O_NONBLOCK); #endif diff --git a/netcon/mtclient/mtclient.cpp b/netcon/mtclient/mtclient.cpp index 37e48b80..081a08d6 100644 --- a/netcon/mtclient/mtclient.cpp +++ b/netcon/mtclient/mtclient.cpp @@ -907,7 +907,8 @@ int LoginMasterTracker() { break; case 4: #ifdef WIN32 - ShellExecute(NULL, "open", MTADDNEWURL, NULL, NULL, SW_SHOW); + // TODO: reacivate for site opening + // ShellExecute(NULL, "open", MTADDNEWURL, NULL, NULL, SW_SHOW); #endif break; case UID_OK: { @@ -2334,7 +2335,7 @@ int MTVersionCheck() { // Specify the correct path DLLddio_MakePath(fulldllpath, DLLLocalD3Dir, "mtav.dll", NULL); - if (!DLLmod_LoadModule(&MTAVDLLHandle, fulldllpath)) { + if (!DLLmod_LoadModule(&MTAVDLLHandle, fulldllpath, MODF_LAZY)) { DLLmprintf(0, "Unable to load Mastertracker Auto version update DLL (mtav.dll)\n"); // Try restoring a backup of the DLL DLLddio_MakePath(szolddll, DLLLocalD3Dir, "mtav.dll", NULL);