diff --git a/dll/network.cpp b/dll/network.cpp index bd809eca..47cb5f58 100644 --- a/dll/network.cpp +++ b/dll/network.cpp @@ -249,7 +249,7 @@ static void run_at_startup() return; } #if defined(STEAM_WIN32) - WSADATA wsaData; + WSADATA wsaData{}; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NO_ERROR) { PRINT_DEBUG("Networking WSAStartup error"); return; @@ -257,8 +257,13 @@ static void run_at_startup() for (int i = 0; i < 10; ++i) { //hack: the game Full Mojo Rampage calls WSACleanup on startup so we call WSAStartup a few times so it doesn't get deallocated. - WSAStartup(MAKEWORD(2, 2), &wsaData); + WSADATA wsaData{}; + if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NO_ERROR) { + PRINT_DEBUG("Networking WSAStartup error"); + return; + } } + PRINT_DEBUG("Networking WSAStartup success!"); #else #endif diff --git a/dll/steam_http.cpp b/dll/steam_http.cpp index d78d9c9a..a88ae286 100644 --- a/dll/steam_http.cpp +++ b/dll/steam_http.cpp @@ -160,6 +160,30 @@ bool Steam_HTTP::SetHTTPRequestGetOrPostParameter( HTTPRequestHandle hRequest, c return true; } +static int curl_debug_trace( + CURL *handle, curl_infotype type, + char *data, size_t size, + void *clientp +) +{ + // https://curl.se/libcurl/c/CURLOPT_DEBUGFUNCTION.html + std::string text{}; + switch (type) { + case CURLINFO_TEXT: text = "Info: " + std::string(data, size); break; + case CURLINFO_HEADER_IN: text = "<= Recv header"; break; + case CURLINFO_HEADER_OUT: text = "=> Send header"; break; + case CURLINFO_DATA_IN: text = "<= Recv data"; break; + case CURLINFO_DATA_OUT: text = "=> Send data"; break; + case CURLINFO_SSL_DATA_OUT: text = "=> Send SSL data"; break; + case CURLINFO_SSL_DATA_IN: text = "<= Recv SSL data"; break; + + default: text = "[X] ERROR: unknown callback type"; break; + } + + PRINT_DEBUG("%s", text.c_str()); + return 0; +} + void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t *pCallHandle) { @@ -213,6 +237,11 @@ void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t send_callresult(); return; } + +#ifndef EMU_RELEASE_BUILD + curl_easy_setopt(chttp, CURLOPT_DEBUGFUNCTION, curl_debug_trace); + curl_easy_setopt(chttp, CURLOPT_VERBOSE, 1L); +#endif // headers std::vector headers{}; @@ -314,7 +343,7 @@ void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t fclose(hfile); headers.clear(); - PRINT_DEBUG("CURL error code for '%s' [%i] (OK == 0)", request->url.c_str(), (int)res_curl); + PRINT_DEBUG("CURL error code for '%s' [%i = '%s'] (OK == 0)", request->url.c_str(), (int)res_curl, curl_easy_strerror(res_curl)); unsigned int file_size = file_size_(request->target_filepath); if (file_size) { diff --git a/premake5-deps.lua b/premake5-deps.lua index b4bff7d9..d7b75bdb 100644 --- a/premake5-deps.lua +++ b/premake5-deps.lua @@ -535,8 +535,9 @@ local wild_zlib_64 = { if _OPTIONS["build-curl"] or _OPTIONS["all-build"] then local curl_common_defs = { "BUILD_CURL_EXE=OFF", - "BUILD_SHARED_LIBS=OFF", "BUILD_STATIC_CURL=OFF", -- "Build curl executable with static libcurl" + + "BUILD_SHARED_LIBS=OFF", "BUILD_STATIC_LIBS=ON", "BUILD_MISC_DOCS=OFF", "BUILD_TESTING=OFF", @@ -544,6 +545,8 @@ if _OPTIONS["build-curl"] or _OPTIONS["all-build"] then "ENABLE_CURL_MANUAL=OFF", "CURL_USE_OPENSSL=OFF", "CURL_ZLIB=ON", + + -- fix building on Arch Linux "CURL_USE_LIBSSH2=OFF", "CURL_USE_LIBPSL=OFF", "USE_LIBIDN2=OFF",